This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Code Loader - Jumping to Compiler Startup Code

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.

Parents
  • Erik is talking about something else - that a program that doesn't feel "well" should not try to jump to the startup code in an attempt to reset/repair itself. That is way dangerous, and a real hardware reset should be performed.

    Your original problem was how a boot loader should start a downloaded application. It should not jump to main(). Instead, all downloaded versions should contain their own startup code that should be called from the boot loader. That is required, to make sure that a bug in the startup code may be corrected by downloading new startup code. Also, the symbol main() may not be at a fixed location. Depending on what changes to do to the source, the linker may move it forward or backward.

    The startup code is responsible for setting up initialized variables. If the boot loader jumps directly to main(), the application code must initialize variables instead. If c++, the startup code is responsible for constructing global C++ objects. The startup code also adjusts any heap.

Reply
  • Erik is talking about something else - that a program that doesn't feel "well" should not try to jump to the startup code in an attempt to reset/repair itself. That is way dangerous, and a real hardware reset should be performed.

    Your original problem was how a boot loader should start a downloaded application. It should not jump to main(). Instead, all downloaded versions should contain their own startup code that should be called from the boot loader. That is required, to make sure that a bug in the startup code may be corrected by downloading new startup code. Also, the symbol main() may not be at a fixed location. Depending on what changes to do to the source, the linker may move it forward or backward.

    The startup code is responsible for setting up initialized variables. If the boot loader jumps directly to main(), the application code must initialize variables instead. If c++, the startup code is responsible for constructing global C++ objects. The startup code also adjusts any heap.

Children
No data