【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
二、编译结果
-
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 汇编文件),链接器找不到程序入口(复位向量、栈初始化)。
- 缺少了
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 在工程中添加该文件
- 选取startup_stm32f10x_md.s文件,重新编译。
3.3 结果
- 完成!