lpcware

Help Needed, LPC1850 bootloader fails jump to application with around 50% probability

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by hitpony on Thu Nov 06 06:50:12 MST 2014
I am using a LPC1850, with NORFLASH at 0x1C000000, and SDRAM at 0x28000000, Bootloader is saved in NORFLASH 0x1C000000, and application saved at 0x1C008000. after poweron, bootloader will copy (via memcpy) the application from 0x1C008000 to 0x28000000, and bootloader will jump to the application with following functions, but I can only jump to the application with 50% successful rate.

In the bootloader, A check is put after the memcpy, the copy is always successful, this proves the NORFLASH and SDRAM should be OK, I guess the failure always happend after  boot_jump(addr); and before main() fuction of the Application.

I have tried to add a watchdog in the bootloader, but when the application failed to be lauched, the system can NOT be reset, and need to press the reset button to restart the system.

The bootloader is via KEIL v4.54, and the application is done via IAR v6.60, and at the start of applicaion, IRQ is enabled.

Can anyone provide a help to see, why the application can only be launched with around 50% probability? and what is the possible reason the watchdog can not reset the system when jump fails.

================== APPLICATION ====================
int main (void)
{
    __enable_irq();

    .....

}

================== BOOTLOADER ====================
int main (void)
{
    ...
    //copy
    memcpy((char *)0x28000000, (uint8_t *)0x1c008000, length);

    //check, and err alwasy is 0
    for(cnt = 0; cnt < (length>>2); cnt++)
    {
         if( (*(((uint32_t *)0x28000000)+cnt)) != (*(((uint32_t *)0x1c008000)+cnt)) )
         {
              err++;
         }
    }

    //jump to application
    ExecuteUserCode(0x28000000);
    ....
}

__asm void boot_jump( uint32_t address )
{
    LDR SP, [R0];Load new stack pointer address
    LDR PC, [R0, #4]        ;Load new program counter address
}

void ExecuteUserCode(uint32_t addr)
{
    __disable_irq();
    SysTick->CTRL = 0;
    SCB->VTOR = addr & 0xFFFFFF80;
    boot_jump(addr);
}

Outcomes