emte 0 Posted January 29, 2007 Report Share Posted January 29, 2007 (edited) Alright, this is where i am at: i have figured out how to hijack the void _startup(void) function, butit is not allowing me to redefine the contents. This is an issue because it chews up 4 instructions just going into main, and to load most bootloaders you need to issue the bootloader jump within the first four instructions. So my question is how to redefine or override _startup? It should be possible as a pure asm file works just fine. The code compiles without an issue, i belive it is a linker problem or perhaps a flag that i am missing. The nice semiObscure error is: Failure NoSourceFile function redefinition: _startup(void) in C:\TEMP\EE-Bootloader\main.c Which i can only guess that "NoSourceFile" might actually mean not allowed to define in a source file. If that is the case, work around anyone? Edited January 29, 2007 by emte Quote Link to post Share on other sites
Dave 0 Posted January 29, 2007 Report Share Posted January 29, 2007 Alright, this is where i am at:i have figured out how to hijack the void _startup(void) function, butit is not allowing me to redefine the contents. This is an issue because it chews up 4 instructions just going into main, and to load most bootloaders you need to issue the bootloader jump within the first four instructions. So my question is how to redefine or override _startup? It should be possible as a pure asm file works just fine. <{POST_SNAPBACK}> Overridding the startup code is not possible. If I was trying to right a bootloader I would do it like this: 1) Split program into 2, application and bootloader. 2) Compile BootLoader in low memory. 3) Compile application to use memory above bootloader - use linker option -rb Bootloader code will get executed first for both reset and interrupt. Pass control onto application code using somthing like: //Jump To Application Code asm { //Set pclath #if defined( _16F877 ) || defined( _16F876 ) movlw0x1E #elif defined( _16F874 ) || defined( _16F873 ) movlw0x0E #elif defined( _16F871 ) || defined( _16F870 ) movlw0x06 #endif movwf_pclath //set pcl movlw0x00 movwf_pcl } This code is from the EK Bootloader on the samples page. Regards Dave Quote Link to post Share on other sites
emte 0 Posted January 29, 2007 Author Report Share Posted January 29, 2007 (edited) hmmm... so your suggesting placing the bootloader at the start instead of the normal ICD debug space? Your idea of breaking it up has given me another idea though, lets see if it pans out. Edited January 29, 2007 by emte Quote Link to post Share on other sites
Dave 0 Posted January 29, 2007 Report Share Posted January 29, 2007 emte, hmmm... so your suggesting placing the bootloader at the start instead of the normal ICD debug space? <{POST_SNAPBACK}> Yep.Microchip provide configuration bits on some devices that allow the low memory area to be protected from flash table writes eg PIC18F4520 has 0x800 bytes of ROM that can be protected for boot loader usage. Regards Dave Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.