Hi,
MSP and PSP keep the stack address. In interrupt vector table, the first word is stack address. Bootloader will get this address and put into MSP and PSP. Below is extract from bl_main.c
static 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);
}
MCUXpresso can generate link file. It will put vector table at the top of image.
You can put your application image at anywhere, but you must change the bootloader to tell it the address. It defined in bootloader_config.h
#define BL_APP_VECTOR_TABLE_ADDRESS (0x60040000u)
You can trace this definition to see how it deal with application image.
Regards,
Jing