Hello everyone.
First of all please forgive me my bad English.
I'm quite new to programming microcontrollers never the less i'd like to run a boot loader, that loads an application on LPC11u68.
Let's say I want to locate demos_switch_blinky in flash at 0x2000 and want to execute it by running a boot loader. Am I right to store 0x2000 in VTOR-register, update sp and finally branch there? Like this:
ldr r0, =0xE000ED08 /*VTOR*/
ldr r1, =0x20000 /*base adress of application in flash*/
str r1, [r0]
ldr r0, [r1]
mov sp, r0
ldr r0, [r1, #4]
bx r0
But how can I locate an application at a certain address in flash with lpcxpresso explicitly?
many thanks for any help in advance
Use the memory configuration editor (documented in the LPCXpresso IDE User Guide) to modify the memory layout of your application. That way you don't need to touch the linker scripts directly.
More background information on LPCXpresso IDE's use of linker scripts can be found in the FAQ Using your own linker scripts
Note : The code that jeremyzhou posted is missing the setup of the stack pointer.
Regards,
LPCXpresso Support
Hi Jonas Spahn,
1. You can refer to the following demo to jump to the application code.
void execute_user_code(void)
{
void (*user_code_entry)(void);
unsigned *p; // used for loading address of reset handler from user flash
/* Change the Vector Table to the USER_FLASH_START
in case the user application uses interrupts */
SCB->VTOR = USER_FLASH_START ;
// Load contents of second word of user flash - the reset handler address
// in the applications vector table
p = (unsigned *)(USER_FLASH_START +4);
// Set user_code_entry to be the address contained in that second word
// of user flash
user_code_entry = (void *) *p;
// Jump to user application
user_code_entry();
}
2. The relocation implementation should be done in the linker file .ld file and you can learn the more information about the linker file through the path: C:\nxp\LPCXpresso_8.0.0_526\lpcxpresso\tools\share\doc\gcc-arm-none-eabi\html\ld.html\index.html
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi jeremyzhou
Thanks for responding
I read about Linker Scripts and with the MCU-Settings I was able to split the flash memory in two sections. By unticking the "Manage linker script"-option and using my own linker script, I was even able to locate the Application in the second Flash section completely. But when I tried to debug it there was an error. Anyway. With the article I'm convinced to handle it somehow.
My other question refers to the example described in the link
Creating an embedded bootloader with VisualGDB | VisualGDB Tutorials
In this example the application is "merged" with the bootloader by modifying the makefile. Is there a similar way to do that in lpcxpresso?