最近使用做一个DFU USB升级程序,使用的是STM32CubeF0_V1.7.0中的例程,但是应用程序部分编译时总是出现一个问题,换用STM32CubeF0_V1.6.0中的例程也是一样;换一台电脑也是一样。试了很多方法不能解决。报错如下:STM32F072B-Discovery_USBSTM32F072B-Discovery_USB.axf: Error: L6971E: stm32f072b_discovery.o(.data) type RW incompatible with main.o(.ARM.__AT_0x20000000) type ZI in er RW_IRAM1.
代码如下:
#include "main.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
#define APPLICATION_ADDRESS (uint32_t)0x08007000 //0x08007000
#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")));
#endif
USBD_HandleTypeDef USBD_Device;
/* Private function prototypes -----------------------------------------------*/
static void SystemClock_Config(void);
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
HAL_Init();
for(uint8_t i = 0; i < 48; i++)
{
VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
}
/* Configure the system clock to get correspondent USB clock source */
__HAL_RCC_SYSCFG_CLK_ENABLE();
__HAL_SYSCFG_REMAPMEMORY_SRAM();
SystemClock_Config();
/* Configure LED3, LED4, LED5 and LED6 */
BSP_LED_Init(LED_GREEN);
BSP_LED_Init(LED_ORANGE);
BSP_LED_Init(LED_RED);
BSP_LED_Init(LED_BLUE);
/* Configure User button for remote wakeup */
BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);
/* Init Device Library */
USBD_Init(&USBD_Device, &HID_Desc, 0);
/* Register the HID class */
USBD_RegisterClass(&USBD_Device, &USBD_HID);
/* Start Device Process */
USBD_Start(&USBD_Device);
while (1)
{
}
}
如果屏蔽掉如下部分,就可以编译通过:
#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")));
#endif
可见问题出在这里,请高手指导! 谢谢!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>