S32K312 bootloader jump to application issue

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

S32K312 bootloader jump to application issue

Jump to solution
476 Views
Vandarkholme
Contributor I

Hello! I'm developing s32k312 bootloader, but when jump to app, it always stuck in "HardFault_Handler".

Bootloader range: 0x400000 - 0x4fffff,App range: 0x500000 - end, RTD version: 3.0.0

This is my jump code in bootloader:

Vandarkholme_0-1706235328073.png

Boot & app already downloaded by Jlink, so I put jump code before bsp_init

Vandarkholme_1-1706235473126.png

This is app's map

Vandarkholme_2-1706236042357.png

I tried a lot solutions in forum, but not work. Should I do some remapping stuff or something else?

Best Regards! 

 

0 Kudos
1 Solution
432 Views
Vandarkholme
Contributor I

Hi @danielmartynek ,

Thanks for your support! I tried your code but still stuck in hardfault_handler.

So I search same topic again, finally found the solution, now my code jump normally:

已解决: UsageFault: The processor has attempted to execute... - NXP Community

Maybe your code should update to this:

uint32 func = *(uint32 volatile *)(APP_STARTADDR+ 0xC);
func = *(uint32 volatile *)(((uint32)func) + 0x4);
func = ((((uint32)func) & 0xFFFFFFFEU) | 1u); // with "|1u" code worked 
(* (void (*) (void)) func)();

View solution in original post

0 Kudos
2 Replies
449 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @Vandarkholme,

Can you use this code?

func = *(UINT32 volatile *)(0x500000 + 0xC);
func = *(UINT32 volatile *)(((UINT32)func) + 0x4);
func = (((UINT32)func) & 0xFFFFFFFEU);
(* (void (*) (void)) func)();

Please check the code in the memory view.

At 0x500000 there should be 0x5AA55AA5
At 0x500000 + 0xC, there is the Cortex-M7_0 core start address.
(RM rev7, Table 189. Image vector table).

 

BR, Daniel

0 Kudos
433 Views
Vandarkholme
Contributor I

Hi @danielmartynek ,

Thanks for your support! I tried your code but still stuck in hardfault_handler.

So I search same topic again, finally found the solution, now my code jump normally:

已解决: UsageFault: The processor has attempted to execute... - NXP Community

Maybe your code should update to this:

uint32 func = *(uint32 volatile *)(APP_STARTADDR+ 0xC);
func = *(uint32 volatile *)(((uint32)func) + 0x4);
func = ((((uint32)func) & 0xFFFFFFFEU) | 1u); // with "|1u" code worked 
(* (void (*) (void)) func)();

0 Kudos