Hi guys,
I want to write a secondary boot loader for the LPC1547, but it always fail to jump to application. Is anybody have ever write a secondary boot loader for LPC15xx? It will be very pleasure if any body can give me a help. Both boot loader and application project is very simple, and they can run up independently.
The boot loader is jump to application directly.
The application blink two LEDs only.
Boot loader and user application in flash:
Hanz,
I use a bunch of LPC1549 in projects, and my bootloader is used in all projects
I have a function:
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
static __asm void BootJump(unsigned int firmwareStartAddress) {
LDR R1, [R0]
MSR MSP, R1 ; Load MSP with new stack pointer address
LDR SP, [R0] ;Load new stack pointer address
LDR PC, [R0, #4] ;Load new program counter address
}
Which I call like this:
#define FW_ENTRY_CM3 0x4000
if (*(unsigned int*)FW_ENTRY_CM3 != 0xFFFFFFFF) {
// Disable all interrupts
NVIC->ICER[0] = 0xFFFFFFFF;
NVIC->ICER[1] = 0x0000001F;
// Clear all pending interrupts
NVIC->ICPR[0] = 0xFFFFFFFF;
NVIC->ICPR[1] = 0x0000001F;
tsk_lock();
// IRQ vectors at BASE of firmware
SCB->VTOR = FW_ENTRY_CM3 & 0x1FFFFF80;
// Lets go..
BootJump(FW_ENTRY_CM3);
}
My main firmware is located at 0x4000. The call to tsk_lock() stops the RTOS (Keil RTX) from running (basically disables timertick for the task scheduling).
This works, the same is used on a bunch of different NXP Cortex processors...
The check
if (*(unsigned int*)FW_ENTRY_CM3 != 0xFFFFFFFF) {
simply checks if there is something in the Flash at 0x4000, if not (Flash is erased) it will not try and jump to it. You can add more check to this if you need, basically the jump works.
Hello,
I would like to know why is necessary to put 0x1FFFFF80?
SCB->VTOR = FW_ENTRY_CM3 & 0x1FFFFF80;
I am trying this code, and the micro is still not running.
Thanks in advance.
Carsten,
Thank you very much! I was busy on other things these days. Your code looks better, I will try it later. ^_^