S32K314 app jump to bootloader question

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

S32K314 app jump to bootloader question

Jump to solution
305 Views
Faith-Herio
Contributor II

hellow,I encountered a rather tricky problem. I am using BootLoader+APP mode on S32K314. The same code works fine when the BootLoader jumps to the APP, but it triggers a hard fault when the app jumps back to the BootLoader. During debugging, I found that there was an error in setting up the stack. I can't think of a good solution for this issue and would like to ask if anyone has any suggestions?

The code and the values of the variables look like this:

 

    addr =0x00400000
    static void (*jump_to_bootloader)(void);
    static uint32_t stack_pointer;
    uint32_t appEntry, appStack;
 
    appStack = *(uint32_t *)(addr + 4096);
    appEntry = *(uint32_t *)(addr + 4096 + 4);
   
    jump_to_bootloader = (void (*)(void))appEntry;
    stack_pointer = appStack;
  
    S32_SCB->VTOR = (uint32_t)addr;
   
    __asm volatile("MSR msp, %0\n" : : "r"(stack_pointer) : "sp");
    __asm volatile("MSR psp, %0\n" : : "r"(stack_pointer) : "sp");
   
    jump_to_bootloader();
 
0 Kudos
1 Solution
278 Views
Faith-Herio
Contributor II
0 Kudos
2 Replies
148 Views
shuaige
Contributor I

hello ,can you teach me how to address this question?Thank you?Why not jump?

0 Kudos
279 Views
Faith-Herio
Contributor II

已解决

0 Kudos