LPC5536 bootloader issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC5536 bootloader issue

3,404 Views
AlvinLin1933
Contributor I

MCU is LPC5536JBD64, refer the AN13497, when run to  _set_PSP(s_stackPointer), will report HardFault interrupt. Please refer below and attached, need your advise or how to locate the HardFault details.

void JumpToImage(uint32_t addr)
{
     uint32_t sp;
     uint32_t pc;
    if(Bsp_Flash_Read(addr,(uint8_t *)&sp,4) == 0)
    {
        return;
    }
    if(Bsp_Flash_Read(addr+4,(uint8_t *)&pc,4) == 0)
    {
        return;
    }
    if ((sp == 0xffffffff) || (pc == 0xffffffff)||(sp == 0x0)||(pc == 0x0))
    {
        return;
    }

    typedef void(*app_entry_t)(void);

    static uint32_t s_stackPointer = 0;
    static uint32_t s_applicationEntry = 0;
    static app_entry_t s_application = 0;

    s_stackPointer = sp;
    s_applicationEntry = pc;
    s_application = (app_entry_t)s_applicationEntry;

    INT_ALL_DISABLE();//跳转前,关闭中断,防止跳转后主程序误跳到中断处理
   
    // Change MSP and PSP
    __set_MSP(s_stackPointer);
    __set_PSP(s_stackPointer);

    SCB->VTOR = addr;
    // Jump to application
    s_application();

    // Should never reach here.
    __NOP();
}

0 Kudos
Reply
2 Replies

3,370 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @AlvinLin1933 

 

The BOOT ROM of lpc5536 support dual image, how about directly use it? There is a simple demo under blow thread:

https://community.nxp.com/t5/LPC-Microcontrollers/Internal-flash-dual-image-boot-on-LPC5536/td-p/158...   

 

BR

Alice

0 Kudos
Reply

3,364 Views
AlvinLin1933
Contributor I

Hi Alice :

   Attached the referenced demo and document.

0 Kudos
Reply