S32K144 fails to jump to App

cancel
Showing results for 
Search instead for 
Did you mean: 

S32K144 fails to jump to App

1,154 Views
klau
Contributor II

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

0 Kudos
3 Replies

677 Views
stanish
NXP Employee
NXP Employee

Hi Kevin,

Please check this thread, it contains several hints about jumping from bootloader to app.

https://community.nxp.com/message/1111769

Hope it helps.

Stan

0 Kudos

677 Views
klau
Contributor II

Hi Stan,

I have located the issue, and I am looking at it now.

The issue is that I can NOT reconfigure the UART0 that I have used in the

bootloader before jumping to the application.

I tried the following code to change the baud from 19200 to 9600.

PCC->PCCn[PCC_LPUART0_INDEX] &= ~PCC_PCCn_CGC_MASK;

PCC->PCCn[PCC_LPUART0_INDEX] |= PCC_PCCn_PCS(2) | PCC_PCCn_CGC_MASK;

LPUART0->BAUD = LPUART_BAUD_SBR(0x34) |LPUART_BAUD_RXEDGIE(1) |

LPUART_BAUD_OSR(15);

LPUART0->CTRL = LPUART_CTRL_RIE_MASK | LPUART_CTRL_RE_MASK |

LPUART_CTRL_TE_MASK;

Do you see anything that I am missing?

Thanks,

Kevin

0 Kudos

676 Views
stanish
NXP Employee
NXP Employee

Hi Kevin,

I'd recommend to setup the LPUART module as close as possible into after-reset state.

You can try to first perform software reset of LPUART peripheral (GLOBAL register -> RST bit)

and then setup the peripheral according to the application requirements.

Hope it helps.

Stan

0 Kudos