question about bootloader for S32DS

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

question about bootloader for S32DS

跳至解决方案
2,660 次查看
yangbo1
Contributor III

I write bootloader and relative user application in S32DS. Now the bootloader can download user application firmware to dedicated flash area, but when invoke the function _startup for user application, seems crash,  nothing happened after that. Does this process have problem? Is there anything ignored by me?

Thanks for your attention!

0 项奖励
回复
1 解答
2,611 次查看
stanish
NXP Employee
NXP Employee

Hi,

Please check this thread:

https://community.nxp.com/t5/S32-Design-Studio/MPC5748G-bootloader-to-application-jump-issue/m-p/920...

 

Alternatively you can use C code to jump to the application:

typedef void (*func_ptr)(); // pointer to function type

void main(void)

{

...

JumpToApp(0xC000)

}


void JumpToApp(unsigned int AppStart)
{
(*(func_ptr)AppStart)(); // Jump at Startup
}

在原帖中查看解决方案

6 回复数
2,612 次查看
stanish
NXP Employee
NXP Employee

Please check this thread:

https://community.nxp.com/t5/S32-Design-Studio/MPC5748G-bootloader-to-application-jump-issue/m-p/920...

Alternativelly you can use C code to jump to the bootloader:

 

typedef void (*func_ptr)(); // pointer to function type

void JumpToApp(unsigned int AppStart)
{
  (*(func_ptr)AppStart)(); // Jump at Application start address
}


void main(void)
{
...
 JumpToApp(0xC000);

}

 

 

0 项奖励
回复
2,650 次查看
stanish
NXP Employee
NXP Employee

Hi,

if it crashes at the very begining of your user app. it may indicate the adress is wrong or wrongly aligned.

Are you jumping from bootloader at right starting address of your user application?

Please note: it is recommended to de-init all peripherals used by the bootloader so after jumping into the app there is no pending interrupt that jumps into unhandled exception.

There are many thread related to bootloader issues e.g:

https://community.nxp.com/t5/S32K/S32K146-BOOTLOADER/m-p/1058945

https://community.nxp.com/t5/S32K/S32K144-Bootloader-gt-JumpToApplication-Problem/m-p/889807

Hope it helps.

Stan

0 项奖励
回复
2,646 次查看
yangbo1
Contributor III

I think no problem with starting address(at 0xC000) for user application. I think the problem is I don't know how to jump to the user application correctly. The chip is MPC5607B. I use S32DS. The code snippet is shown as below.

void jump_to_app(void)

{

            __asm__(" " " e_b 0x0000C000" " ");

}

It doesn't working correctly. I am not familiar with powerpc assembly language. How to write it?

Thanks for your attention!

0 项奖励
回复
2,612 次查看
stanish
NXP Employee
NXP Employee

Hi,

Please check this thread:

https://community.nxp.com/t5/S32-Design-Studio/MPC5748G-bootloader-to-application-jump-issue/m-p/920...

 

Alternatively you can use C code to jump to the application:

typedef void (*func_ptr)(); // pointer to function type

void main(void)

{

...

JumpToApp(0xC000)

}


void JumpToApp(unsigned int AppStart)
{
(*(func_ptr)AppStart)(); // Jump at Startup
}
2,349 次查看
yangbo1
Contributor III

Hi, @stanish 

Thank you for your suggestion!

I use C code to jump to the application. It is another way. The address of jumping is boot block start address + 4 for my chip. Please refer to the Reference Manual

the code is as below.

( *( void(*)(void) ) ) ( *(uint32_t*)(boot_block_start_address + 4) );

0 项奖励
回复
2,535 次查看
yangbo1
Contributor III

Hi, @stanish 

Thank you very much! the asm code in that thread works.

please refer a pertinent suggestion from another thread.

https://community.nxp.com/t5/S32-Design-Studio/S32R274-bootloader-jump-to-app-project/m-p/1094380

completely de-init everything before jump. Most important - disable interrupts on all levels - by MSR[EE], by local enable bits in peripherals, by priority registers.

0 项奖励
回复