您的位置:首页 > 其它

Keil开发STM32更换MCU造成的编译不通过解决办法

2016-10-02 12:33 459 查看
1.更换MCU型号(我从STM32F103ZET6换成C8T6)

改选STM32F103C8

出现的编译错误:
*** Using Compiler 'V5.06 update 3 (build 300)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'USART1(interrupt)'
compiling stm32f10x_it.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\stm32f10x_it.c: 1 warning, 1 error
compiling main.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\main.c: 1 warning, 1 error
compiling init.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\init.c: 1 warning, 1 error
compiling kalman.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\kalman\kalman.c: 1 warning, 1 error
compiling scheduler.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\scheduler.c: 1 warning, 1 error
compiling mpu6050_measure.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\mpu6050_measure.c: 1 warning, 1 error
compiling bsp_usart1.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\usart\bsp_usart1.c: 1 warning, 1 error
compiling bsp_SysTick.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\SysTick\bsp_SysTick.c: 1 warning, 1 error
compiling attitude computation.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\attitude computation.c: 1 warning, 1 error
compiling bsp_i2c.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\i2c\bsp_i2c.c: 1 warning, 1 error
compiling bsp_mpu6050.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\mpu6050\bsp_mpu6050.c: 1 warning, 1 error
compiling bsp_encoder.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\User\encoder\bsp_encoder.c: 1 warning, 1 error
assembling startup_stm32f10x_hd.s...
compiling core_cm3.c...
compiling system_stm32f10x.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\CMSIS\system_stm32f10x.c: 1 warning, 1 error
compiling misc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\misc.c: 1 warning, 1 error
compiling stm32f10x_adc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_adc.c: 1 warning, 1 error
compiling stm32f10x_bkp.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_bkp.c: 1 warning, 1 error
compiling stm32f10x_can.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!&l
4000
t; ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_can.c: 1 warning, 1 error
compiling stm32f10x_cec.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_cec.c: 1 warning, 1 error
compiling stm32f10x_crc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_crc.c: 1 warning, 1 error
compiling stm32f10x_dac.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_dac.c: 1 warning, 1 error
compiling stm32f10x_dbgmcu.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_dbgmcu.c: 1 warning, 1 error
compiling stm32f10x_dma.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_dma.c: 1 warning, 1 error
compiling stm32f10x_exti.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_exti.c: 1 warning, 1 error
compiling stm32f10x_flash.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_flash.c: 1 warning, 1 error
compiling stm32f10x_fsmc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_fsmc.c: 1 warning, 1 error
compiling stm32f10x_gpio.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_gpio.c: 1 warning, 1 error
compiling stm32f10x_i2c.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_i2c.c: 1 warning, 1 error
compiling stm32f10x_iwdg.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_iwdg.c: 1 warning, 1 error
compiling stm32f10x_pwr.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_pwr.c: 1 warning, 1 error
compiling stm32f10x_rcc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_rcc.c: 1 warning, 1 error
compiling stm32f10x_rtc.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_rtc.c: 1 warning, 1 error
compiling stm32f10x_sdio.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_sdio.c: 1 warning, 1 error
compiling stm32f10x_spi.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_spi.c: 1 warning, 1 error
compiling stm32f10x_tim.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_tim.c: 1 warning, 1 error
compiling stm32f10x_usart.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_usart.c: 1 warning, 1 error
compiling stm32f10x_wwdg.c...
..\..\Libraries\CMSIS\stm32f10x.h(298): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\..\Libraries\CMSIS\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\..\Libraries\FWlib\src\stm32f10x_wwdg.c: 1 warning, 1 error
"..\..\Output\Template.axf" - 36 Error(s), 36 Warning(s).
Target not created.
Build Time Elapsed:  00:00:11

这个问题是因为对应处理器内部资源少于启动文件中提及的内部资源,启动文件中某一部分寄存器地址在F103C8中没有,才会编译出错。

2.更换启动文件宏定义
由于STM32F103系列的不同型号MCU内部ROM和RAM不同,其地址区间也有些许差异
所以需要选择与型号对应的启动文件,并配置对应的宏定义

startup_stm32f10x_cl.s
互联型的器件,STM32F105xx,STM32F107xx

startup_stm32f10x_hd.s
大容量的STM32F101xx,STM32F102xx,STM32F103xx

startup_stm32f10x_hd_vl.s
大容量的STM32F100xx

startup_stm32f10x_ld.s
小容量的STM32F101xx,STM32F102xx,STM32F103xx

startup_stm32f10x_ld_vl.s
小容量的STM32F100xx

startup_stm32f10x_md.s
中容量的STM32F101xx,STM32F102xx,STM32F103xx

startup_stm32f10x_md_vl.s
中容量的STM32F100xx

startup_stm32f10x_xl.s FLASH在512K到1024K字节的STM32F101xx,STM32F102xx,STM32F103xx

cl:互联型产品,stm32f105/107系列

vl:超值型产品,stm32f100系列

xl:超高密度产品,stm32f101/103系列

ld:低密度产品,FLASH小于64K

md:中等密度产品,FLASH=64 or 128
hd:高密度产品,FLASH大于128

ZET6的启动文件配置:

把STM32F10X_HD换成STM32F10X_MD

编译结果(能够通过):

做到这一步应该就可以用了,但是我还没有检查具体的内存地址空间,可以找个最小系统板下载一下就知道能不能用了。

现在存在的问题是启动文件用的还是HD版本的,能够编译MD通过但是还是想换成MD。

3.更换启动文件
更换前:

更换过程:

添加新的md文件,然后把hd文件删除
编译后能够通过。

4.可能出现的问题
error: L6235E: More than one section matches selector - cannot all be FIRST/LAST.

网上的解决方案:
http://www.cnblogs.com/wellrun/archive/2011/03/21/1990074.html

编译环境:RVMDK

CPU :STM32F103VC

错误:.\obj\movSERVO.sct(7): error: L6235E: More than one section matches selector - cannot all be FIRST/LAST.

原因:项目中同时包含以下启动文件,

   startup_stm32f10x_hd.s

        startup_stm32f10x_md.s

        startup_stm32f10x_ld.s

     ......

        应该针对不同的CPU选择不同的启动文件。

解决办法1:从项目中删除不相关的启动文件

解决办法2:右击不相关的启动文件,点击 options for file 'startup_stm32f10x_md.s'...

                在弹出的对话框中的properties页,勾去灰化的'Include in Target Build'和‘Always Build’两项。

这个博客已经说明了问题的原因,但是导致问题的原因在Keil本身。
keil的这个地方有时候会出现一个选项,下方这个截图里没有出现。我在用Keil 5.14时会出现,刚才升级到5.21a后就没有再次出现。
那个选项里面会出现不少启动文件和相关文件,这些文件也自动加入编译,导致了有多个启动文件造成冲突,

解决方案:
右键,点击第一行

把Use for all project targets前面的勾选取消,点击ok

再编译就没有这个冲突了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  STM32 Keil
相关文章推荐