stm32f722x芯片的iap跳转问题
以前在stm32的f0和f4系列单片机中实现了完整的基于uart的iap处理,包括iap程序,和app程序,通过下面的函数调用就能直接跳转到app运行。static void jump_to_app(void)
{
if(((*(__IO uint32_t *)FLASH_APP_ADDR) & 0x2FFE0000) == 0x20000000) //检查栈顶地址是否合法.0x20000000是sram的起始地址,也是程序的栈顶地址
{
//DeInit();
jump2func = (iapfun) * (__IO uint32_t *)(FLASH_APP_ADDR + 4); //用户代码区第二个字为程序开始地址(复位地址)
__set_MSP(*(__IO uint32_t *)FLASH_APP_ADDR); //初始化应用堆栈指针(用户代码区的第一个字用于存放栈顶地址)
jump2func(); //跳转到应用.
}
}
在app的main函数最前面调用下面函数
#if (defined ( __CC_ARM ))
__IO uint32_t VectorTable __attribute__((at(0x20000000)));
#elif (defined (__ICCARM__))
#pragma location = 0x20000000
__no_init __IO uint32_t VectorTable;
#elif defined (__GNUC__)
__IO uint32_t VectorTable __attribute__((section(".RAMVectorTable")));
#elif defined ( __TASKING__ )
__IO uint32_t VectorTable __at(0x20000000);
#endif
void iap_app_init(void)
{
uint32_t i = 0;
/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
/* Copy the vector table from the Flash (mapped at the base of the application
load address 0x08003000) to the base address of the SRAM at 0x20000000. */
for(i = 0; i < 48; i++)
{
VectorTable = *(__IO uint32_t *)(FLASH_APP_ADDR + (i << 2));
}
/* Enable the SYSCFG peripheral clock*/
//RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
__HAL_RCC_SYSCFG_CLK_ENABLE();
/* Remap SRAM at 0x00000000 */
//SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
__HAL_SYSCFG_REMAPMEMORY_FMC_SDRAM();
}
在iap中,调用上面的jump_to_app函数就能成功跳转到app程序。
现在想把该框架移植到stm32f722x芯片上,结果调用jump_to_app函数后就死掉了,不会运行app的代码。我把app的keil工程的IROM1起始地址修改成0800000后,直接烧写到08000000后,是可以正常运行的。各位对这种情况有什么建议没有?到底是哪里出现问题呢?
IAP没毛病,APPmain前面不用加啥东西,和正常一样写,修改systeminit中的中断向量偏移那一行即可,MDK中IROM1改成APP_ADDR就行。
芯片不知道会不会有区别,
而且,你说的移植到F7,是移植完整了吗?
IAP JMP关键:
1 跳之前关中断。
2 跳到CORE,立刻重定向中断向量。
3 地址修改对。
可以参考:https://www.stmcu.org.cn/module/forum/thread-617410-1-1.html
页:
[1]