s32K311 bootloader quesiton

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

s32K311 bootloader quesiton

Jump to solution
1,602 Views
scott071209
Contributor II

Hello ,

I have used same program. for K344, it's OK to jump from bootloader to APP. But when I used same way to test K311. it doesn't jump. Could you give some suggestion? Thanks.

 
 
        appStack= *(uint32_t *)(APP_START_ADDRESS);
        appEntry= *(uint32_t *)(APP_START_ADDRESS+0XC);
        //appEntry= *(uint32_t *)(APP_START_ADDRESS);
        appEntry= *(uint32_t *)((uint32_t)appEntry+0X4);
        //appEntry = (((uint32_t)appEntry)& 0xFFFFFFFEU);
        //(* (void (*) (void)) appEntry)();
        Bootup_Application(appEntry,appStack);
 
 
#define APP_START_ADDRESS 0X440200// APP 开始地址
void Bootup_Application(uint32_t appEntry, uint32_t appStack)
{
static void(*jump_to_application)(void);
static uint32_t stack_pointer;
/*把应用程序入口地址赋值给函数指针*/
jump_to_application = (void(*)(void))appEntry;
stack_pointer = appStack;
/*重新定向中断向量表*/
S32_SCB->VTOR = (uint32_t)APP_START_ADDRESS;
/*设置堆栈指针*/
__asm volatile("cpsie i": : : "memory");//关闭总中断指令
__asm volatile("MSR msp, %0 \n" : : "r" (stack_pointer) : "sp");//设置堆栈到mSP
__asm volatile("MSR psp, %0 \n" : : "r" (stack_pointer) : "sp");//设置堆栈到pSP
jump_to_application();
 
}
0 Kudos
Reply
1 Solution
1,548 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Ok, it jumps to the application. But it fails on ITCM initialization. I found that it's caused by MPU configuration - ITCM is obviously protected against write. If I clear ENABLE bit in core register MPU_CTRL, it works. So, you should deinit also the MPU before the jump.

Regards,

Lukas

View solution in original post

7 Replies
1,582 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @scott071209 

if you step the asm code, where does it fail exactly? Can you see if correct address is used for jump?

Regards,

Lukas

0 Kudos
Reply
1,570 Views
scott071209
Contributor II

I  think it's right address.please see my code. Look foward your reply.Thanks.

344.png

0 Kudos
Reply
1,563 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

I'm afraid the attached projects do not correspond to your screenshot. I loaded them to my board and I can see:

lukaszadrapa_0-1705487598742.png

Which leads to this after the jump:

lukaszadrapa_1-1705487627488.png

... as expected considering the value in appEntry.

Regards,

Lukas

 

0 Kudos
Reply
1,557 Views
scott071209
Contributor II

Hello ,

 Sorry, It's old version. please see this latest version. Look forward your reply.Thanks.

23.jpg24.jpg

0 Kudos
Reply
1,549 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Ok, it jumps to the application. But it fails on ITCM initialization. I found that it's caused by MPU configuration - ITCM is obviously protected against write. If I clear ENABLE bit in core register MPU_CTRL, it works. So, you should deinit also the MPU before the jump.

Regards,

Lukas

1,181 Views
scott071209
Contributor II

Dear,

    I want to know how to confirm ITCM initialization fail. I check attachment picture. there is no fault.

Also please tell why ITCM initialization fail will have an effect on jump? Thanks.

0 Kudos
Reply
1,533 Views
scott071209
Contributor II
Hello Lukas,
It's Ok. Thanks .
0 Kudos
Reply