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
Hi @Alice_Yang
is it possible that the problem is the REDLIB? We can't find any other ideas to solve the issue.
BR
Marco
Hi @Alice_Yang
Can I share in a private way?
Hello @MarcoGiammarini
I received your projects. Which IDE do you used?
After import it into MCUXprsso IDE, it seems not works well. Not shows the code you mentioned above.
Just as below:
Also linker file not right.
BR
Alice
Sorry @Alice_Yang , I miss some parts of the project. Usually we save the application code outside the project. I'll send you now the correct version!
BR
Marco
Hello @MarcoGiammarini
How about send a project that I can directly build. You can send your project to others to test first.
Without any change, on my side:
I think maybe there is issue with the linker file of application project. While project can not build well on my side, so I don't know which linker file do you used. Use IDE to config? Or use the files under linkscripts folder?
BR
Alice
Hi @Alice_Yang
I am so sorry, but from my side both project compile well with MCUXpresso. I tried different PC to check it.
For the application project, I am using the linker file inside the folder of your screenshot. When I compile for using the application without the bootloader I am using the configuration without the _BOOT at the end, instead when I compile the application project to put it on the specific part where the bootloader jump I am using the configuration with _BOOT at the end.
Thanks for yuor help
BR
Marco
Hello @MarcoGiammarini
Because I can not build your project on my side, recommend you use a simple led SDK project, not your own project. confirm it can works well. Then change flash start address to 0xE000. Build, confirm the .hex file start address is 0xE000. Program it into your chip. Then use bootloader to test.
BR
Alice
Hello @MarcoGiammarini
1) I haven't find issue with your code.
You can first test whether application can well without bootloader. To do this, edit the launch configuration (by double clicking on the .launch file that will have been created in your project) and change the "reset handling" option to "SOFT".
Detail you can refer to:
2) Pay attention do not erased application code when program bootloader project.
BR
Alice
Hi @Alice_Yang
thanks for yuor reply.
On the launch file, there isn't the flag that you mention:
Can I do/check other flags?
BR
Marco