I am working on bootloader of kea128, i download the DEMOCODE from INTERNET, and convert it from Codewarrior to Keil, but the function jumptoapplication() doesn't work. In debugging, the sp register is 0x4000, the pc register is not 0x4000, it can not jump to application from boot .the code is like this :
void JumpToApplication(uint32_t sp, uint32_t pc)
{
JumpToPtr pJumpTo;
uint16_t i;
static uint32_t s_stackPointer = 0;
uint32_t *pNewAppEntry;
pNewAppEntry = (uint32_t *)pc;
s_stackPointer = sp;
SCB->VTOR=0X4000;
__set_MSP(s_stackPointer);
__set_PSP(s_stackPointer);
pJumpTo = ((JumpToPtr)(*pNewAppEntry));
// s_application();
pJumpTo();
while(1)
{
i++;
}
}
who can help me?
Hi,
This scatter file show that your code start from address 0. Obviously, it can't run at 0x4000.
Please refer to the scatter file in NXP_Kinetis_Bootloader_2_0_0\apps\led_demo\MKL25Z4\mdk\led_demo_freedom_8000.
Regards,
Jing
Hi,
First please make sure that in your application the interrupt vector table is really locate at 0x4000.
In the interrupt vector table, for example 0x4000, (*(unsigned int*)0x4000) always be the Stack Pointer address. And (*(unsigned int*)0x4004) always be the application's entry address.
The address value in (unsigned int*)0x4004) is the real entry address +1. For example, if the application's entry address is 0x4100, the the value will be 0x4101.
Regards,
jing
dear jing,
How to locate the vector table at 0x4000 in my application ? i should check the application code or the software configration of keil5?
regards
deng
Hi,
You should modify the keil link file if you want to remap. You can download MCUboot package
Check the demo project NXP_Kinetis_Bootloader_2_0_0\apps\led_demo\MKL25Z4\mdk\led_demo_freedom_8000.
You can refer to its sct file.
Regards,
Jing
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x00000000 0x00020000 { ; load region size_region
ER_IROM1 0x00000000 0x00020000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x1FFFF000 0x00004000 { ; RW data
.ANY (+RW +ZI)
}
}
this is the sct file of my project, it seems no problems, can you help me find the problems?
regards
deng