I know that the topic of bootloaders has been covered a number of times here before and I have found the information quite useful (thanks especially to Jens-Michael) but I have not satisfactorily found a neat way of getting the tools (CCSv4) to do what is required.
I am comfortable with the concept of the boot loader having a 'protected' flash section containing the default reset and interrupt vectors that executes code to determine if the main application requires updating at reset and jumping to the main application when action is taken (or not taken). I also understand that the default interrupt vectors need to point to another vector table in the main application's flash space in order to cope with the changing addresses of the interrupt handlers.
So my question is how do I get CCS to accomplish this?
I had initially thought to maintain two separate CCS projects (one for the main application and one for the boot loader) and merge the two project output .txt files to initially use in programming the entire flash and extract the appropriate sections of the main project to use as the update file. The linker command files for each project would have nicely located everything where it should. The two downsides that I have found to this are finding a tool to automate combining the two files as a post build command and that the main project can't be debugged separately because the reset and interrupt vectors are not where they should be. Is there a way around this?
My second thought was to compile the boot loader into an object file and link it into the appropriate section of flash during the main project's linking stage. This would mean the complete flash image would be generated at the end of the build process of the main project and could be debugged as normal (the bootloader would run first and then jump to the main application). But this is where my knowledge of the low level tool details start to get a bit scratchy.
- Is it possible to link in the bootloader's object file to it's own section of flash?
- And if so would having all the C run time initialisation code in the bootloader's object file clash with the main project?
- In that case would the bootloader code need to be placed in a different code section and can you do that for the entire bootloader project or would it be easier to code the bootloader in assembly to avoid the run time initialisation and place it in the correct code section?
Cheers
Adam