Issue in Jumping from Bootloader to Application

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

Issue in Jumping from Bootloader to Application

1,160 Views
lakshmi_s
Contributor I

Hi 

I am using S32K144, i have custom Boot loader project and Application project separately which have separate linker file. My Application starts from 0x1000 to 0xC000. I am facing issue while jumping from bootloder to Application.  

#define APP_VECTOR_TABLE           0x1000

void JumpToUserApplication(void)
{

if(APP_RESET_ADDRESS == 0xFFFFFFFF){
return;
}

S32_SCB->VTOR = (uint32_t)APP_VECTOR_TABLE;
JumpApplication(*((uint32_t*)APP_VECTOR_TABLE), *((uint32_t*)(APP_VECTOR_TABLE + 4)));

}
void JumpApplication( unsigned int userSP, unsigned int userStartup)
{
/* Check if Entry address is erased and return if erased */

/* Set up stack pointer */
__asm("ldr r0,=0x1000");
__asm("msr msp, r0");
__asm("msr psp, r0");

/* Jump to application PC (r1) */
__asm("ldr r1,=0x1005");
__asm("blx r1");
}

Everything seems ok until right before the branch (blx r1) then it is jumping to 0x1478 and stucks here.

/* Disassembly */

0000146d: strb r0, [r0, #0]
0000146f: movs r0, #0
00001471: push {r0, r2, r6, r7}
00001473: movs r0, r0
00001475: cbz r1, 0x14de
00001477: movs r0, r0
00001479: b.w 0x1478          <------------   PC is not come out of this
0000147d: cbnz r3, 0x1494
0000147f: cbnz r2, 0x1494
00001481: cmp r1, #0
00001483: it eq
00001485: cmpeq r0, #0 

Where i Did Mistake?

Please help me to sort out this issue.

Thanks in Advance.

0 Kudos
Reply
1 Reply

1,109 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

first point which I recommend to everyone - make sure that you have disabled all interrupts before jump (on all levels: in the core and also by local enable bits in peripherals) and it's good practice to put everything back to default state before jumping to application. This can save a lot of troubles.

Does r1 contain correct entry point address? Is bit[0] set to '1'?

pastedImage_3.png

Regards,

Lukas

0 Kudos
Reply