Hello,
AN112 provides three different methods for code loader designs.
However, we are considering having our Code Loader jump to the compiler's C_C51Startup function of our Main Application instead of its Main function. This would allow us to leverage the functionality that the compiler's startup code provides (clearing data; initialization of globals, statics; setting stack pointer; etc.).
Also, our Code Loader (and many others) never needs to run after it passes control to the Main Application. So we believe that we would not need to ensure that the data areas for the two applications do not overlap.
These two ideas seem to work well together. The C_C51Startup should ensure that the data area is initialized before the Main function of the Application runs even if it overlaps the data area of the Code Loader.
Are there any problems or drawbacks in the Code Loader jumping to the Application's C_C51Startup function and having the data areas of the Code Loader and Application overlap? It seems simpler and safer to us.
Not sure what you mean by AN112. However this application note may help:
http://www.keil.com/appnotes/docs/apnt_180.asp
Sorry, AN112 is provided by the device manufacturer (Silicon Labs).
However, my questions are more related to the Keil compiler startup code and boot strategies. Once again: 1. Is it better for the Boot Loader to jump to the Application's C_C51STARTUP routine instead of jumping to the Application's Main function? It seems to me that jumping to the C_C51STARTUP routine is preferable since the application can have all of its globals, statics and stack pointer initialized. 2. If the boot loader jumps to the Application's C_C51STARTUP routine instead of jumping to the Application's Main function and control is never passed back to the Boot Loader, then is it safe to allow the data areas of the Boot Loader and Application to overlap?
The boot loader should not call main(), since you may need to change the startup script.
If main never returns, you can let the boot loader share memory with the application - as long as the application doesn't try to configure the memory to keep it's value after a reboot.
let the watchdog time out and get a REAL reset.
Many have been 'surprised' when they did a reset by software. e.g. this little pesky SFR is not in the reset state.
Erik
The "best" surprise is when interrupts are still enabled (because the SFR keeps their contents) and the initialization code plays with a couple of settings and gets an interrupt without a valid stack.
View all questions in Keil forum