lpcware

Secondary bootloader error

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 16, 2016 by Juan Padilla
Content originally posted in LPCWare by michaelleekun on Thu Sep 03 13:51:06 MST 2015
I am using a LPCXpresso54102 board (cortex M4 only now) and I am trying to upgrade the user application with the secondary bootloader. It will copy the new binary to the "Sector 1 (0x00008000)" which was downloaded by the old user application to the other sector of flash area.

- Seconday bootloader runs at Sector 0 (0x00000000)


#include "board.h"

typedef void (*USER_ENTRY_PFN)();
#define SBL_SLV_FIRMWARE_START(0x8000)

int main(void)
{
    USER_ENTRY_PFN user_entry;
    user_entry = (USER_ENTRY_PFN)*((uint32_t*)(SBL_SLV_FIRMWARE_START +4));

    /* Generic Initialization */
    Board_Init();
    Board_LED_Set(0, TRUE);

    __disable_irq();
   SCB->VTOR = SBL_SLV_FIRMWARE_START;
    __enable_irq();

    __set_MSP(SCB->VTOR);//load stackpointer with initial value
    (user_entry)();

    /* Loop forever */
while (1) {
__WFI();}

    return 0;
}


I have compiled (using LPCXpresso) the user application changing the start address to 0x8000. This one is working fine with the "AN11610: LPC5410x I2C SPI Secondary Bootloader" which means it should work if my Secondary Bootloader (above codes) is fine. 

But if I run the Secondary Bootloader code, this one does not jump to the user application. The "user_entry" is set to "0x81FD" and the debugger stops working. I am not sure but I am missing something here.

Thank you in advance.

Outcomes