Hi,
we developed a custom bootloader for the LPC55S06 (we know that the microcontroller has a bootloader inside). The bootloader is at 0x0 and the application is at 0xE000. The application was relocated at this address by using linker script.
When the bootloader start, everything is ok until the jump to the application where it jump into a RAM address. We can't understand why. The code is the same that we use a lot of times for M4 and M0 core.
The code is the following:
static uint32_t s_stackPointer = 0;
uint32_t *vect_mem = 0;
vect_mem = (uint32_t*)APP_VECTOR_TABLE;
s_stackPointer = vect_mem[0];
static void (*farewellBootloader)(void) = 0;
farewellBootloader = (void (*)(void))vect_mem[1];
if (is_valid_application_location((uint32_t)farewellBootloader))
{
GPIO_PinWrite(BOARD_INITPINS_LED_ACTIVE_GPIO,
BOARD_INITPINS_LED_ACTIVE_PORT,
BOARD_INITPINS_LED_ACTIVE_PIN,1);
// Set the VTOR to the application vector table address.
SCB->VTOR = (uint32_t)vect_mem;
// Set stack pointers to the application stack pointer.
__set_MSP(s_stackPointer);
__set_PSP(s_stackPointer);
// Jump to the application.
farewellBootloader();
}
else
{
// TODO app is not valid
while(1){
GPIO_PortToggle(BOARD_INITPINS_LED_ERROR_GPIO,
BOARD_INITPINS_LED_ERROR_PORT,
(1 << BOARD_INITPINS_LED_ERROR_PIN));
App_mDelay(1000);
}
}
where #define APP_VECTOR_TABLE 0x0000E000
Where is the error?!
Best,
Marco