LPC1547 secondary bootloader cannot jump to application

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC1547 secondary bootloader cannot jump to application

1,901件の閲覧回数
andersonhanz
Contributor I

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:

1523502344(1).jpg

Debug result:
1523500129(1)_看图王.jpg
1523501332(1).jpg
ラベル(5)
0 件の賞賛
返信
3 返答(返信)

1,369件の閲覧回数
carstengroen
Senior Contributor II

Hanz,

I use a bunch of LPC1549 in projects, and my bootloader is used in all projects Smiley Happy

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.

0 件の賞賛
返信

1,369件の閲覧回数
juan_moya
Contributor I

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.

0 件の賞賛
返信

1,369件の閲覧回数
andersonhanz
Contributor I

Carsten,

Thank you very much! I was busy on other things these days. Your code looks better, I will try it later. ^_^

0 件の賞賛
返信