I read AN4723 and built separately bootloader and application in 2 projects for S12ZVML. Both of them have start-up Code.
In Linkerfile of bootloader I added application, i.e HEXFILE Application.sx
In source code of bootloader I let the µC jump to the application.
If the pointer APPLICATION_START_ADD points to main function of application, everything works well.
If the pointer APPLICATION_START_ADD points to the beginning of flash of application, it jumps to Start-up Code of application. After executing function DoZeroOut, it returns to the programm of bootloader (line FF8018). The function DoCopyDown or main of application below will not be executed.
Because the address of the main function of application will be changed from time to time, I'm thinking about a solution, i.e.:
- Define fixed address for main function of application. Then jump from bootloader to this address
- Somehow disable Start-up of application. Jump from bootloader to the beginning of flash
- Somehow let start-up code of application execute completely.
Can someone please give me an idea to solve this problem.
Thank you so much.