zhulaoda

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

bootload跳转到app层后死机,查了以下发现F0系列需要把中断映射表复制到RAM里。

解决方法一:

在bootload程序跳转前添加代码

    memcpy((void*)0x20000000, (void*)APPLICATION_ADDRESS, 0xC0);        // 将应用程序的中断向量表从Flash中拷贝到RAM中,0xC0是中断向量表大小48*4
    SYSCFG->CFGR1 |= 0x03;                                              // 设置STM32F0xx中断向量表位于RAM中
    
    /* Jump to user application */
    JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
    JumpToApplication = (pFunction) JumpAddress;
    /* Initialize user application's Stack Pointer */
    __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
    JumpToApplication();

方法二:

在应用层函数里添加代码

    __IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));
/* 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 0x08004000) to the base address of the SRAM at 0x20000000. */ for(int i = 0; i < 48; i++) { VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2)); } /* Enable the SYSCFG peripheral clock*/ __HAL_RCC_SYSCFG_CLK_ENABLE(); /* Remap SRAM at 0x00000000 */ __HAL_SYSCFG_REMAPMEMORY_SRAM();

上面两个方法任选一种。

应用层还需设置IRAM1 IRAM2

 

posted on 2020-08-07 11:45  zhulaoda  阅读(1076)  评论(0)    收藏  举报