S32K144 fails to jump to App

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

S32K144 fails to jump to App

1,716 次查看
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

标记 (3)
0 项奖励
3 回复数

1,239 次查看
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 项奖励

1,239 次查看
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 项奖励

1,238 次查看
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 项奖励