AnsweredAssumed Answered

S32K144 fails to jump to App

Question asked by Kevin Lau on Jun 27, 2019
Latest reply on Jul 8, 2019 by stanish

Hi Dear Reader(s),

 

I used S32DS, no SDK, no RTOS to create these two programs in C.

1) Bootloader, starts at 0x0000,

2) Application, starts at 0x3000.

 

I ran these programs via S32DS, started them at their entry points (0x0000 or 0x3000), both worked perfectly with no issue.

 

Then I linked these two together using this function,

 

Calls via this,

#define APP_START_ADDRESS 0x3000

JumpToUserApplication(*((uint32_t*)APP_START_ADDRESS), *((uint32_t*)(APP_START_ADDRESS + 4)));

 

 

/**
* Used to jump to the entry point of the user application
* The Vector table of the user application must be located at 0x3000
*
* */
void JumpToUserApplication( unsigned int userSP, unsigned int userStartup)
{
/* Check if Entry address is erased and return if erased */
if(userSP == 0xFFFFFFFF){
return;
}

/* Set up stack pointer */3
__asm("msr msp, r0");
__asm("msr psp, r0");

/* Relocate vector table */
S32_SCB->VTOR = (uint32_t)APP_START_ADDRESS;

/* Jump to application PC (r1) */
__asm("mov pc, r1");
}

 

Finally I flashed these two program onto the flash memory, if I started the App at 0x3000. The Application worked.  But  the application failed if I started at 0x0000, then jump to 0x3000.

 

Is there any extra steps that I must do before/after the jump from the bootloader or application?

 

Thanks in advance if you can give me hint(s)?

 

Thanks,

Kevin

Outcomes