大家好! 最近在调试stm32f030串口升级功能,分别测试IAP代码和APP代码都能正常工作, IAP的跳转代码如下: void Restart ( void ) { jump reboot; __set_MSP ( * ( volatile uint32_t * ) 0x08000000 ); reboot = ( jump ) * ( volatile uint32_t * ) 0x08000004; reboot(); } void AppJump ( void ) { jump appjump; __set_MSP ( * ( volatile uint32_t* ) APP1_IMG_BEG_ADDRESS ); appjump = ( jump ) * ( volatile uint32_t * ) ( APP1_IMG_BEG_ADDRESS + 4 ); appjump(); }复制代码我在IAP代码里面测试这两个跳转代码,Restart函数可以让IAP正常复位,所以推测AppJump函数应该也是可以正常跳转的; 另外再APP代码里面我添加了如下中断向量重映射代码: void VectorTableRemap ( 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 APP_IMAG_LOCATION) to the base address of the SRAM at 0x20000000. */ for ( i = 0; i < 48; i++ ) { VectorTable[i] = * ( volatile uint32_t* ) ( APP1_IMG_BEG_ADDRESS + ( i << 2 ) ); } /* Enable the SYSCFG peripheral clock*/ __HAL_RCC_SYSCFG_CLK_ENABLE(); /* Remap SRAM at 0x00000000 */ __HAL_SYSCFG_REMAPMEMORY_SRAM(); } 复制代码现在在联调的时候发现,IAP升级的时候APP不能工作,按照帖子前面几步测试的结果,IAP是正常跳转到APP的,但是APP没起来,推测是重映射出问题,所以单独运行APP代码,并将重映射修改如下: void VectorTableRemap ( 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 APP_IMAG_LOCATION) to the base address of the SRAM at 0x20000000. */ for ( i = 0; i < 48; i++ ) { VectorTable[i] = * ( volatile uint32_t* ) ( 0x08000000 + ( i << 2 ) ); } /* Enable the SYSCFG peripheral clock*/ __HAL_RCC_SYSCFG_CLK_ENABLE(); /* Remap SRAM at 0x00000000 */ __HAL_SYSCFG_REMAPMEMORY_SRAM(); }复制代码测试发现APP代码可以正常运行,这样推测重映射也是没问题的,所以现在不清楚到底是哪里出了问题,希望了解细节的朋友指点一二,谢谢!!!
评分
查看全部评分
评分
查看全部评分
评分
查看全部评分
忘了修改中断表地址了,现在IAP可以跳到APP,并且正常运行,但是APP跳回IAP不行,可以跳到IAP,但是IAP运行死机,推测是中断的问题,可是我已经把APP的中断关了。
评分
查看全部评分
评分
查看全部评分
我觉得仅仅关闭中断还是不行,在IAP里面可能会无意打开,最好把APP里用到的外设恢复到复位状态,假装单片机进行了一次复位操作在调到IAP,另外IAP里面的中断表地址也需要修改
评分
查看全部评分