使用新唐M487做ota,boot(非rtt代码)跳转rtt应用失败,进入hardfault.使用非rtt程序跳转是没问题的。请大神帮忙看看问题出哪了。
使用的是APRPM含IAP的配置
int main()
{
upgradeTypedef upgradeParam;
SYS_Init(); /* Init System, IP clock and multi-function I/O */
UART0_Init(); /* Initialize UART0 */
/* Configure SPI_FLASH_PORT as a master, MSB first, 8-bit transaction, SPI Mode-0 timing, clock is 20MHz */
SPI_Open(SPI_FLASH_PORT, SPI_MASTER, SPI_MODE_0, 8, 20000000);
/* Disable auto SS function, control SS signal manually. */
SPI_DisableAutoSS(SPI_FLASH_PORT);
SYS_UnlockReg(); /* Unlock register lock protect */
FMC_Open(); /* Enable FMC ISP function */
// printf("w25q16 ID:%04x\n", SpiFlash_ReadMidDid());
upgradeParam = get_upgrade_mark();
if(upgradeParam.mark == 0x01) //升级文件已经下载
{
if(0 != copy_new_firmware(upgradeParam)) //拷贝失败,回退
{
restore_factory_settings();
}
}
iap_load_app(APP_1_ADDR);
while(1){}
}
跳转程序如下:
#define APP_1_ADDR 0x00003000
void iap_load_app(__IO uint32_t appAddr)
{
int i;
if (((*(__IO uint32_t*)appAddr) & 0x2FFC0000 ) == 0x20000000)
{
FMC_Close(); /* Disable FMC ISP function */
SYS_LockReg();
printf("Jump to application running ... \n");
JumpAddress = *(__IO uint32_t*) (appAddr + 4);
Jump_To_Application = (pFunc) JumpAddress;
__disable_irq();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
for( i=0;i<8;i++)
{
NVIC->ICER = 0xFFFFFFFF;
NVIC->ICPR = 0xFFFFFFFF;
}
__set_MSP(*(__IO uint32_t*) appAddr);
__set_CONTROL(0);
__ISB();
Jump_To_Application();//执行函数跳转
printf("Qboot jump to application fail.\n");
}
else
printf("No legitimate application.\n");
}
APP代码中,linker和utilites配置如下:
boot代码配置的keil配置和ICP配置如下:
改的简单的非rtt点灯程序就可以正常跳转
|