BOOT跳转APP

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

BOOT跳转APP

995 Views
ZzzzzZzzzz
Contributor III

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!

0 Kudos
Reply
5 Replies

975 Views
danielmartynek
NXP TechSupport
NXP TechSupport

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

 

 

 

0 Kudos
Reply

969 Views
ZzzzzZzzzz
Contributor III

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,

0 Kudos
Reply

938 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @ZzzzzZzzzz,

Check the address you are jumping to both in the .map file and in the flash.

 

BR, Daniel

0 Kudos
Reply

930 Views
ZzzzzZzzzz
Contributor III

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.

0 Kudos
Reply

925 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Can you step through the jump in disassembly?

Does it end up in Unimplemented opcode trap interrupt?

 

Regards,

Daniel

0 Kudos
Reply