您现在的位置: 主页 > MCU > 单片机技术应用 > Stm32F030用Coocox工程进行Bootloader升级时程序跑飞 -
本文所属标签:
为本文创立个标签吧:

Stm32F030用Coocox工程进行Bootloader升级时程序跑飞 -

来源: 网络用户发布,如有版权联系网管删除 2018-09-07 

[导读]
最近做STM32F030C8的Bootloader升级,使用的是Coocox的工程,发现Bootloader可以正常跳转,但是到应用程序时,就直接跑飞,经过仔细查看,发现是中断向量表没有映射,但是在把中断向量表映射后,程序依

最近做STM32F030C8的Bootloader升级,使用的是Coocox的工程,发现Bootloader可以正常跳转,但是到应用程序时,就直接跑飞,经过仔细查看,发现是中断向量表没有映射,但是在把中断向量表映射后,程序依旧跑飞。一直自己找了好几天,在Nick的帮助下,终于解决了,方法如下:

本文引用地址: http://www.21ic.com/app/mcu/201806/764539.htm

1、在Bootloader里设置跳转:

/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
Jump_To_Application = (pFunction) JumpAddress;

/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);

/* Jump to application */
Jump_To_Application();

2、在Application里重新映射中断向量表;并修改连接文件,十分重要的是不能用Coocox自带的连接文件,要重新向Coocox公司要一份新的,否则向量映射不成功,程序就跑飞。

#if (defined ( __CC_ARM ))
__IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));
#elif (defined (__ICCARM__))
#pragma location = 0x20000000
__no_init __IO uint32_t VectorTable[48];
#elif defined ( __GNUC__ )
__IO uint32_t VectorTable[48] __attribute__((section(".RAMVectorTable")));
#elif defined ( __TASKING__ )
__IO uint32_t VectorTable[48] __at(0x20000000);
#else
#error "it should define the vector table"
#endif

int main(void)
{
#if 1
uint32_t i;

/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/

for(i = 0; i < 48; i++)
{
VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
}

/* Enable the SYSCFG peripheral clock*/
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* Remap SRAM at 0x00000000 */
SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);
#endif
}

在以上完成中断向量映射后,就要修改连接文件了,我对比了Coocox自带的link文件和向Coocox要的link文件,发现自带的link文件,缺少向量重新映射的配置代码,具体如下:

.ARM.attributes 0 : { *(.ARM.attributes) }
/* RAM space for the vector table */
.RAMVectorTable(NOLOAD): {*(.RAMVectorTable)} >VTRAM

当把以上的代码加在自带的link文件_sidata = __etext;代码后面,重新编译生成bin文件,再次用Bootloader升级后,发现程序正常执行。




              查看评论 回复



嵌入式交流网主页 > MCU > 单片机技术应用 > Stm32F030用Coocox工程进行Bootloader升级时程序跑飞 -
 

"Stm32F030用Coocox工程进行Bootloader升级时程序跑飞 -"的相关文章

网站地图

围观()