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();
}
Hello @AlvinLin1933
The BOOT ROM of lpc5536 support dual image, how about directly use it? There is a simple demo under blow thread:
BR
Alice