HI ,
Am developing a secondary bootloader for LPC1517.
Current status: Able to load new firmware from UART to the location 0x8000. Now i have to give access to the new firmware. Currently, the code is written as below
asm volatile("ldr r0, =0x8000");
asm volatile("ldr r0, [r0]");
asm volatile("mov sp, r0");/* Load program counter with application reset vector address, located at
second word of application area. */
asm volatile("ldr r0, =0x8004");
asm volatile("ldr r0, [r0]");
asm volatile("mov pc, r0");
Bootloader linker memory code
MEMORY
{
/* Define each memory region */
MFlash256 (rx) : ORIGIN = 0x0, LENGTH = 0x8000 /* 256K bytes (alias Flash) */
Ram0_16 (rwx) : ORIGIN = 0x2000000, LENGTH = 0x4000 /* 16K bytes (alias RAM) */
Ram1_16 (rwx) : ORIGIN = 0x2004000, LENGTH = 0x4000 /* 16K bytes (alias RAM2) */
Ram2_4 (rwx) : ORIGIN = 0x2008000, LENGTH = 0x1000 /* 4K bytes (alias RAM3) */
}/* Define a symbol for the top of each memory region */
__base_MFlash256 = 0x0 ; /* MFlash256 */
__base_Flash = 0x0 ; /* Flash */
__top_MFlash256 = 0x0 + 0x2000 ; /* 256K bytes */
__top_Flash = 0x0 + 0x2000 ; /* 256K bytes */
Application code linker
/* Define each memory region */
MFlash64 (rx) : ORIGIN = 0x8000, LENGTH = 0x8000 /* 64K bytes */
Ram0_4 (rwx) : ORIGIN = 0x2000000, LENGTH = 0x1000 /* 4K bytes */
Ram1_4 (rwx) : ORIGIN = 0x2001000, LENGTH = 0x1000 /* 4K bytes */
Ram2_4 (rwx) : ORIGIN = 0x2004000, LENGTH = 0x1000 /* 4K bytes */
}
/* Define a symbol for the top of each memory region */
__top_MFlash64 = 0x8000 + 0x8000;
__top_Ram0_4 = 0x2000000 + 0x1000;
__top_Ram1_4 = 0x2001000 + 0x1000;
__top_Ram2_4 = 0x2004000 + 0x1000;
Following things done :
1) Unticked managed linked script.
1)is there anything additional to be done, to give access to the program at 0x8000 ?
Hi AKHIL JOY,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
1. Linker modification
The application is able to use the full area of RAM after jumping successful, so you'd better increase the size of RAM.
In my opinion, drive the “managed
linker script” mechanism in MCUXpresso or LPCXpresso IDE is the best way to generate an appropriate linker file, you can give a try.
2)is there anything additional to be done, to give access to the program at 0x8000?
You need to reconfigure the Vector Table Offset Register register, just like the below code shows.
SCB->VTOR = VTOR_NEW_ADDR
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jeremyzhou ,
Thanks for your reply,
SCB->VTOR = 0x8000 ;
// boot_jump(0x8000);
asm volatile("ldr r0, =0x8000");
asm volatile("ldr r0, [r0]");
asm volatile("mov sp, r0");/* Load program counter with application reset vector address, located at
second word of application area. */
asm volatile("ldr r0, =0x8004");
asm volatile("ldr r0, [r0]");
asm volatile("mov pc, r0");
I changed the code to above, and still, didn't worked.
i verified the SP and PC which is getting the correct values.
Also tried the below
SCB->VTOR = 0x8000 & 0x1FFFFF80;
and regarding the managed linker script. So don't we need to change the TOP flash address in application linker file ?
Hi AKHIL JOY,
Thanks for your reply.
In addition to configuring the application firmware's address, the clock mode should be identical, in other words, the clock status of bootloader before jumping should be as same as the initialization clock status of application firmware.
In further, I'd highly recommend you to refer to the thread to adapt your jump function.
Clean bootloader to application Jump
Back to your question, So don't we need to change the TOP flash address in application linker file? The answer is no.
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------