Jump to app failing custom bootloader.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Jump to app failing custom bootloader.

ソリューションへジャンプ
3,266件の閲覧回数
mitch1
Contributor II

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.

ラベル(1)
タグ(4)
1 解決策
3,077件の閲覧回数
nxf56274
NXP Employee
NXP Employee

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();

}

元の投稿で解決策を見る

3 返答(返信)
2,761件の閲覧回数
OliveiraNxp
Contributor II

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!!!!

Oliveira
0 件の賞賛
3,078件の閲覧回数
nxf56274
NXP Employee
NXP Employee

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();

}

3,077件の閲覧回数
mitch1
Contributor II

That works perfectly, thank you!

0 件の賞賛