Using MC9S12G128, Boot jumps normally after updating the APP, but the second time it updates another APP, the program runs away. For comparison, the two apps just add a variable and set it to 1. Also, do you need to turn off the interrupt when BOOT jumps to the APP? Do the peripherals need to be turned off? How do they turn them off?
Thanks!
Hi @ZzzzzZzzzz,
This is probably because the application linker file and startup allocates and initializes variable before the _Startup() is allocated.
This creates an offset for the _Startup() routine address.
You can check that in the .map files of the two applications.
Please refer to this bootloader:
https://www.nxp.com/docs/en/application-note/AN4258.pdf
https://www.nxp.com/docs/en/application-note-software/AN4258SW.zip
It is better to jump to the application just after a system reset.
If you need to jump from the bootloader after the application has been loaded without reset, it is recommended non only masking the interrupts but disabling them in the peripherals (together with the peripherals) and clearing all the interrupt flags.
Please refer to the datasheet for more information on how to disable a specific peripheral.
Best regards,
Daniel
Hi Daniel,
I tried to turn off interrupts and peripherals and clear the interrupt flag before jumping to the APP in BOOT,but the program cannot jump successfully when entering the APP.For the same APP, it can jump in the implementation, but on this APP software, only one variable is modified for testing, it can't jump. My test steps are: burn BOOT program, update APP program through CAN communication, and then update APP2 on this basis,it is fail. The difference between APP1 and APP2 is only an addition of a variable.Updating either APP1 or APP2 alone would have been successful.
Best regards,
Hi @ZzzzzZzzzz,
Check the address you are jumping to both in the .map file and in the flash.
BR, Daniel
Hi Daniel,
I checked the jump address is correct. Now the problem is that if I flush APP1 through UDS under BOOT, it can jump even I flush it many times, or it can jump if I only flush APP2, but if I flush APP1 first, and then flush APP2, the program will run away.
Can you step through the jump in disassembly?
Does it end up in Unimplemented opcode trap interrupt?
Regards,
Daniel