Bootloader jump_to_addr questions

It appears that an incorrect value is being used as the reset handler address so that the jump from bootloader to application is to the wrong address.

I am porting a bootloader / application to the nrf52810.  The bootloader and app use a custom RF protocol (no softdevice) and currently work for the nrf52833 and nrf52840.  I'm using the nrf52832 as an emulator for the 810.

The issue I'm having now is when the bootloader jumps to the application on the nrf52810, the processor seems to hang.  It seems that the jump_to_addr function in nrf_bootloader_app_start_final.c is jumping to the wrong address.

Here is the sequence of events captured with the debugger:

1. New stack pointer and reset handler are loaded to R0 and R1

2. R0 and R1 are stored in the new stack frame.  A copy of the new msp is loaded into R3.  R3 is stored to SP[12]

3. The new stack pointer is loaded from SP[12] into R3.  MSP is updated from R3 to 0x20006000.

4. Load R3 with the value of SP[0], address 0x20006000, then branch to address pointed to in R3.  

If I change the value in R3 to the correct address of the reset handler, it works as expected and the app starts executing.  If the value at 0x20006000 is garbage, then I get a hard fault.

Related