OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3319|回复: 4

STM32F0-Discovery开发板 HID程序问题

[复制链接]

1

主题

4

帖子

0

精华

新手上路

积分
20
金钱
20
注册时间
2017-4-22
在线时间
3 小时
发表于 2017-4-22 18:49:47 | 显示全部楼层 |阅读模式
3金钱
最近使用做一个DFU USB升级程序,使用的是STM32CubeF0_V1.7.0中的例程,但是应用程序部分编译时总是出现一个问题,换用STM32CubeF0_V1.6.0中的例程也是一样;换一台电脑也是一样。试了很多方法不能解决。报错如下:STM32F072B-Discovery_USB\STM32F072B-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


可见问题出在这里,请高手指导! 谢谢!

最佳答案

查看完整内容[请看2#楼]

搞定了,把RAM加偏移就好了
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

1

主题

4

帖子

0

精华

新手上路

积分
20
金钱
20
注册时间
2017-4-22
在线时间
3 小时
 楼主| 发表于 2017-4-22 18:49:48 | 显示全部楼层
搞定了,把RAM加偏移就好了
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2017-4-24 00:48:24 | 显示全部楼层
帮顶
回复

使用道具 举报

1

主题

4

帖子

0

精华

新手上路

积分
20
金钱
20
注册时间
2017-4-22
在线时间
3 小时
 楼主| 发表于 2017-4-24 08:54:26 | 显示全部楼层
别沉啊! 高手大哥帮忙啊!
回复

使用道具 举报

1

主题

4

帖子

0

精华

新手上路

积分
20
金钱
20
注册时间
2017-4-22
在线时间
3 小时
 楼主| 发表于 2017-4-24 16:04:08 | 显示全部楼层
别沉啊!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-8-21 11:55

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表