I have been using SAMD51 core and set BOOPROT to 0 bytes to allow bootloader customization.
My workspace have 2 projects:
bootloader
application
The application
.ld flash area starts at 0xC000. Also, I have added the offset attribute into platformio.ini:
board_upload.offset_address= 0xC000
The bootloader
app, just run the code below to jump tp the application address:
#define APP_ADDRESS 0xC000
static void run_application(void)
{
uint32_t fw_start_address = APP_ADDRESS + 4;
/* Rebase the Stack Pointer */
__set_MSP(*(uint32_t*)(APP_ADDRESS));
/* Rebase the vector table base address */
SCB->VTOR = ((uint32_t)APP_ADDRESS & SCB_VTOR_TBLOFF_Msk);
asm("bx %0" ::"r"(*(uint32_t*)(fw_start_address)));
}
If i set #define APP_ADDRESS 0x0
, bootloader app restarts properly.
However, when #define APP_ADDRESS 0xC000
, application never gets called.
SP
and PC` get lost.
Using atmelsam arduino framework.
Am I missing something here?
Thanks.