【STM32CubeMX】 生成 Keil 工程报错:error L6236E No section matches selector - no section

0 阅读1分钟

【STM32CubeMx】生成的keil工程报错:error L6236E No section matches selector - no section to be FIRSTLAST

一、问题复现

  • 打开STM32CubeMx ==> Start My project from MCU ==> access to mcu selector

  • 在弹出的新界面 左上角,输入芯片型号,右下角选择对应型号;

  • 弹出新界面,在左边Project栏选好地址,填好名称、在Code Generator ==> 中间栏选上"生成项目分.c.h文件"

  • 点击右上角 ==> generate code


二、编译结果

1_编译结果.png

  • Build started: Project: 0503
    *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'E:\Keil5\keil\v5\ARM\ARMCC\Bin'
    Build target '0503'
    linking...
    0503\0503.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAST.
    Not enough information to list image symbols.
    Not enough information to list load addresses in the image map.
    Finished: 2 information, 0 warning and 1 error messages.
    "0503\0503.axf" - 1 Error(s), 0 Warning(s).
    Target not created.
    Build Time Elapsed:  00:00:00
    
  • 原因是工程里没有启动文件(startup_xxx.s 汇编文件),链接器找不到程序入口(复位向量、栈初始化)。

2_目标文件夹.png

  • 缺少了startup_stm32f10x_md.s文件

三、解决方法

3.1 下载startup_stm32f10x_md.s文件

  • 下载startup_stm32f10x_md.s,放在xxxx\MDK-ARM目录底下。
通过网盘分享的文件:startup_stm32f10x_md.s
链接: https://pan.baidu.com/s/1dfuVhJQQAGlaSaTDusFc4Q 提取码: 2222

3.2 在工程中添加该文件

3_添加目标文件.png

  • 选取startup_stm32f10x_md.s文件,重新编译。

3.3 结果

结果.png

  • 完成!