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!
已解决! 转到解答。
Hi,
Please check this thread:
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
}
Please check this thread:
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);
}
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
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!
Hi,
Please check this thread:
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
}
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) );
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.