how jump to application start address?

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

how jump to application start address?

Jump to solution
1,467 Views
rlaxortn
Contributor IV

i am useing s32ds, RTD 4.0.0 and mcu is s32k314. 

i am developing bootloader. 

 

i check to write flash memory in mcu. 

but, after i jump application memory address, it is not work well.

 

my setting. 

bootloader address : 0x00400000

application address : 0x00500000

 

my souce code for jumping to application memory

APP_BASE : 0x00500000

vtor1.jpg

 

i checked flash write.

 - memory after wiring flash.

i compared bin file, it work well.

vtor2.jpg

 

- application(firmware)  id filevtor4.jpg

 

- bootloader ld file

vtor5.jpg 

 

1. Isn't app_base the application start address?

2. If APP_BASE is 0x00500000, app_reset will be trapped in the while(1) of the commented if statement., is it right?

3. Looking at the flash memory, the first start data is 0xa55aa55a. Is this correct? The bin files of other projects are the same, but I don't know what it means or how to interpret it.

4. what is wrong source code and how i fix and what i check?

Tags (2)
0 Kudos
Reply
1 Solution
1,123 Views
rlaxortn
Contributor IV

@Senlent 

hello senlent. 

if i set 0x00500000, it don't work well. mcu did not work well. 

because 0x00500000 is not for starting vector table. so mcu could not find reset handler and other handler.

so i set 0x00502000 for starting vector table, mcu work well. 

View solution in original post

0 Kudos
Reply
4 Replies
1,124 Views
rlaxortn
Contributor IV

@Senlent 

hello senlent. 

if i set 0x00500000, it don't work well. mcu did not work well. 

because 0x00500000 is not for starting vector table. so mcu could not find reset handler and other handler.

so i set 0x00502000 for starting vector table, mcu work well. 

0 Kudos
Reply
1,444 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@rlaxortn

Your jump code implementation has a problem; for example, the jump address and the interrupt redirection address are incorrect.

Please refer to the jump code below and try again.

 

#define AppStartAddress 0x00500000U
static void (*JumpTpApplication)(void) = NULL;
uint32_t JumpAddress = 0 , stack_point;

 

Jumper to App

__asm("cpsid i");

stack_point = *(volatile uint32_t *)(AppStartAddress+0x0c);

JumpAddress = *(volatile uint32_t *)(stack_point+0x04);

JumpTpApplication = (void (*)(void))JumpAddress;

S32_SCB->VTOR = *(volatile uint32_t *)(AppStartAddress+0x0c);

asm volatile("MSR msp, %0\n":: "r" (stack_point));
__asm volatile("MSR psp, %0\n":: "r" (stack_point));

JumpTpApplication();

 

0 Kudos
Reply
1,432 Views
rlaxortn
Contributor IV

hi @Senlent 

 

i think that is wrong. that is right i set ld file, bootloader start address is 0x00400000 and firmware start address is 0x00500000. 

and i fixed source code like you propose. 

but it is not work well. 

so i checked a map file. 

but 0x00500000 is boot header. 

vtor6.jpg

Tags (2)
0 Kudos
Reply
1,425 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@rlaxortn

"but 0x00500000 is boot header. "

Is there a problem with this? Isn't this correct?

Have you tested the jump code I provided? You said your test failed? Then please provide me with your test demo.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2325345%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ehow%20jump%20to%20application%20start%20address%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2325345%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Ei%20am%20useing%20s32ds%2C%20RTD%204.0.0%20and%20mcu%20is%20s32k314.%26nbsp%3B%3C%2FP%3E%3CP%3Ei%20am%20developing%20bootloader.%26nbsp%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Ei%20check%20to%20write%20flash%20memory%20in%20mcu.%26nbsp%3B%3C%2FP%3E%3CP%3Ebut%2C%20after%20i%20jump%20application%20memory%20address%2C%20it%20is%20not%20work%20well.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3Emy%20setting.%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Ebootloader%20address%20%3A%200x00400000%3C%2FP%3E%3CP%3Eapplication%20address%20%3A%200x00500000%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3Emy%20souce%20code%20for%20jumping%20to%20application%20memory%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3EAPP_BASE%20%3A%200x00500000%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22vtor1.jpg%22%20style%3D%22width%3A%20726px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22vtor1.jpg%22%20style%3D%22width%3A%20726px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22vtor1.jpg%22%20style%3D%22width%3A%20726px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F378158iC44A677B9F83FC1A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22vtor1.jpg%22%20alt%3D%22vtor1.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Ei%20checked%20flash%20write.%3C%2FP%3E%3CP%3E%26nbsp%3B-%20memory%20after%20wiring%20flash.%3C%2FP%3E%3CP%3Ei%20compared%20bin%20file%2C%20it%20work%20well.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22vtor2.jpg%22%20style%3D%22width%3A%20996px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22vtor2.jpg%22%20style%3D%22width%3A%20996px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22vtor2.jpg%22%20style%3D%22width%3A%20996px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F378159iB30C65EAEC882A79%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22vtor2.jpg%22%20alt%3D%22vtor2.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E-%20application(firmware)%26nbsp%3B%26nbsp%3Bid%20file%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22vtor4.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22vtor4.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22vtor4.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F378160i85E4951C1771A376%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22vtor4.jpg%22%20alt%3D%22vtor4.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E-%20bootloader%20ld%20file%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22vtor5.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22vtor5.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22vtor5.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F378161i2938BEF7020577D9%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22vtor5.jpg%22%20alt%3D%22vtor5.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E1.%26nbsp%3BIsn't%20app_base%20the%20application%20start%20address%3F%3C%2FP%3E%3CP%3E2.%26nbsp%3BIf%20APP_BASE%20is%200x00500000%2C%20app_reset%20will%20be%20trapped%20in%20the%20while(1)%20of%20the%20commented%20if%20statement.%2C%20is%20it%20right%3F%3C%2FP%3E%3CP%3E3.%26nbsp%3BLooking%20at%20the%20flash%20memory%2C%20the%20first%20start%20data%20is%200xa55aa55a.%20Is%20this%20correct%3F%20The%20bin%20files%20of%20other%20projects%20are%20the%20same%2C%20but%20I%20don't%20know%20what%20it%20means%20or%20how%20to%20interpret%20it.%3C%2FP%3E%3CP%3E4.%20what%20is%20wrong%20source%20code%20and%20how%20i%20fix%20and%20what%20i%20check%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2325883%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20how%20jump%20to%20application%20start%20address%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2325883%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%40%3CSPAN%3Erlaxortn%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%22%3CSPAN%3Ebut%200x00500000%20is%20boot%20header.%26nbsp%3B%3C%2FSPAN%3E%22%3C%2FP%3E%0A%3CP%3EIs%20there%20a%20problem%20with%20this%3F%20Isn't%20this%20correct%3F%3C%2FP%3E%0A%3CP%3EHave%20you%20tested%20the%20jump%20code%20I%20provided%3F%20You%20said%20your%20test%20failed%3F%20Then%20please%20provide%20me%20with%20your%20test%20demo.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2325825%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20how%20jump%20to%20application%20start%20address%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2325825%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Ehi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F188029%22%20target%3D%22_blank%22%3E%40Senlent%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CBR%20%2F%3E%3CP%3Ei%20think%20that%20is%20wrong.%20that%20is%20right%20i%20set%20ld%20file%2C%20bootloader%20start%20address%20is%200x00400000%20and%20firmware%20start%20address%20is%200x00500000.%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20i%20fixed%20source%20code%20like%20you%26nbsp%3B%3CSPAN%3Epropose.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Ebut%20it%20is%20not%20work%20well.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Eso%20i%20checked%20a%20map%20file.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Ebut%200x00500000%20is%20boot%20header.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22vtor6.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22vtor6.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22vtor6.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F378248i92C44B374FCDEEDF%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22vtor6.jpg%22%20alt%3D%22vtor6.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2325447%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20how%20jump%20to%20application%20start%20address%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2325447%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22mailto%3AHi%40rlaxortn%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHi%40rlaxortn%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EYour%20jump%20code%20implementation%20has%20a%20problem%3B%20for%20example%2C%20the%20jump%20address%20and%20the%20interrupt%20redirection%20address%20are%20incorrect.%3C%2FP%3E%0A%3CP%3EPlease%20refer%20to%20the%20jump%20code%20below%20and%20try%20again.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%23define%20AppStartAddress%200x00500000U%0Astatic%20void%20(*JumpTpApplication)(void)%20%3D%20NULL%3B%0Auint32_t%20JumpAddress%20%3D%200%20%2C%20stack_point%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3EJumper%20to%20App%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E__asm(%22cpsid%20i%22)%3B%0A%0Astack_point%20%3D%20*(volatile%20uint32_t%20*)(AppStartAddress%2B0x0c)%3B%0A%0AJumpAddress%20%3D%20*(volatile%20uint32_t%20*)(stack_point%2B0x04)%3B%0A%0AJumpTpApplication%20%3D%20(void%20(*)(void))JumpAddress%3B%0A%0AS32_SCB-%26gt%3BVTOR%20%3D%20*(volatile%20uint32_t%20*)(AppStartAddress%2B0x0c)%3B%0A%0Aasm%20volatile(%22MSR%20msp%2C%20%250%5Cn%22%3A%3A%20%22r%22%20(stack_point))%3B%0A__asm%20volatile(%22MSR%20psp%2C%20%250%5Cn%22%3A%3A%20%22r%22%20(stack_point))%3B%0A%0AJumpTpApplication()%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2333153%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20how%20jump%20to%20application%20start%20address%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2333153%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F188029%22%20target%3D%22_blank%22%3E%40Senlent%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ehello%20senlent.%26nbsp%3B%3C%2FP%3E%3CP%3Eif%20i%20set%200x00500000%2C%20it%20don't%20work%20well.%20mcu%20did%20not%20work%20well.%26nbsp%3B%3C%2FP%3E%3CP%3Ebecause%200x00500000%20is%20not%20for%20starting%20vector%20table.%20so%20mcu%20could%20not%20find%20reset%20handler%20and%20other%20handler.%3C%2FP%3E%3CP%3Eso%20i%20set%200x00502000%20for%20starting%20vector%20table%2C%20mcu%20work%20well.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E