- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've got a KL17, I'm attempting to write a bootloader to allow for OTA updating. I'm having trouble jumping to user app, this is what I'm attempting.
void JumpToUserApplication(uint32_t userSP, uint32_t userStartup){printf("MSP BEFORE: %x \n", __get_MSP());printf("PSP BEFORE: %x \n", __get_PSP()); SCB->VTOR = userSP; // SET UP INTERUPT VECTOR TABLE FOR APP// set up stack pointer__set_MSP(userSP);__set_PSP(userStartup);void (*user_app)(void) = userStartup;user_app(); printf("BAD MSP AFTER: %x \n", __get_MSP());printf("BAD PSP AFTER: %x \n", __get_PSP());}
I call it as such:
JumpToUserApplication(PROGRAM_ADDRESS, (PROGRAM_ADDRESS+0x4));
I expect it to jump to the app, however what happens instead is the boot loader actually restarts as if it goes back to the bootloader reset...
WELCOME TO THE BOOTLOADER! MSP BEFORE: 20005fc0 PSP BEFORE: 20006000 WELCOME TO THE BOOTLOADER! MSP BEFORE: 20005fc0 PSP BEFORE: 20006000... and so on.
I've looked through the disassembly and there is stuff going on at the expected address.
I've got this set up in two projects, with the following memory maps.
Solved! Go to Solution.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Your settings have some problems.You can try the following code.
#define BL_APP_VECTOR_TABLE_ADDRESS 0x7d00
#define APP_VECTOR_TABLE ((uint32_t *)BL_APP_VECTOR_TABLE_ADDRESS)
void goToApp()
{
static void (*farewellBootloader)(void) = 0;
farewellBootloader = (void (*)(void))(APP_VECTOR_TABLE[1]);
SCB->VTOR = (uint32_t)APP_VECTOR_TABLE;
__set_MSP(APP_VECTOR_TABLE[0]);
__set_PSP(APP_VECTOR_TABLE[0]);
farewellBootloader();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I received the same return from NXP on this case:
- Project: AlarmSyatemG2
- Case: 00333667
- Date Opened:02/09/2021
- Subject: LPC54616 - Jumping to a Custimized Legacy Boot Image
I Implemented the above code on my solution... Thanks!!!!


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Your settings have some problems.You can try the following code.
#define BL_APP_VECTOR_TABLE_ADDRESS 0x7d00
#define APP_VECTOR_TABLE ((uint32_t *)BL_APP_VECTOR_TABLE_ADDRESS)
void goToApp()
{
static void (*farewellBootloader)(void) = 0;
farewellBootloader = (void (*)(void))(APP_VECTOR_TABLE[1]);
SCB->VTOR = (uint32_t)APP_VECTOR_TABLE;
__set_MSP(APP_VECTOR_TABLE[0]);
__set_PSP(APP_VECTOR_TABLE[0]);
farewellBootloader();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That works perfectly, thank you!
