Hi! Please Look at this problem for me.
In the bootloader,the code is:
uint32_t *appVectorTable = (uint32_t *)APPLICATION_ADDRESS;
applicationAddress = appVectorTable[kInitialPC];
stackPointer = appVectorTable[kInitialSP];
jump_to_application(applicationAddress,stackPointer);
void jump_to_application(uint32_t applicationAddress, uint32_t stackPointer)
{
#if BL_FEATURE_OTFAD_MODULE
quadspi_cache_clear();
oftfad_resume_as_needed();
#endif
shutdown_cleanup(kShutdownType_Shutdown);
// Create the function call to the user application.
// Static variables are needed since changed the stack pointer out from under the compiler
// we need to ensure the values we are using are not stored on the previous stack
static uint32_t s_stackPointer = 0;
s_stackPointer = stackPointer;
static void (*farewellBootloader)(void) = 0;
farewellBootloader = (void (*)(void))applicationAddress;
// Set the VTOR to the application vector table address.
SCB->VTOR = (uint32_t)APP_VECTOR_TABLE;
// Set stack pointers to the application stack pointer.
__set_MSP(s_stackPointer);
__set_PSP(s_stackPointer);
// Jump to the application.
farewellBootloader();
// Dummy fcuntion call, should never go to this fcuntion call
shutdown_cleanup(kShutdownType_Shutdown);
}
This file named MIMXRT1062xxxxx_flexspi_nor.scf is in the App.
Hi,@Jing,
The bootloader is working in external flash.The PC and stack address are 0x60040415 and 0x20020000, respectively, by reading back.
Please see the file named <MIMXRT1062xxxxx_flexspi_nor.scf> for the relevant configuration.
Hi @shengbing ,
I tested your bootloader. At first it can't work too. Then I set the compile optimization option to -O1. It can work. After that, Then I exchange the __set_MSP() and __set_PSP() position and return back to -O0, it can work too.
__ISB() and __DSB() is useless to this case. So I think this is compiler problem but I don't know why.
Regards,
Jing