Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[bsp][stm32][bluepill] README「快速上手」缺少重新生成 MDK 工程这一步,按文档操作无法编译通过

未关闭 适合新手
#11,818 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
活跃
技术栈
c

调研方向

比较 README_zh.md 中的「快速上手」和「进阶使用」部分,然后检查 bsp/stm32/stm32f103-blue-pill/SConstruct 和 project.uvprojx,以确认 package 如何进入 MDK project。在 pkgs --update 后运行 scons --target=mdk5,并验证生成的 project 引用了所需的 HAL/CMSIS 文件且可以编译。

由索引模型根据 Issue 内容生成。

描述

问题描述

README_zh.md 的「快速上手」章节操作,无法编译通过

该章节写明(第 69-75 行,原文):

请注意!!!
在执行编译工作前请先打开 ENV 执行以下指令(该指令用于拉取必要的HAL库及CMSIS库,否则无法通过编译):

pkgs --update

但仓库里 checked-in 的 project.uvprojx没有引用 packages/ 目录下的任何路径,
工程的文件列表里也没有任何 HAL 源文件:

  • project.uvprojx<IncludePath> 中,与库相关的只有
    ..\libraries\HAL_Drivers..\libraries\HAL_Drivers\drivers
    ..\libraries\HAL_Drivers\drivers\config
  • 全文检索该工程文件,package / cmsis / stm32f1xx_hal 均无匹配
  • 工程的 <RTE> 段为空(<apis /><components /><files />

也就是说,即使执行完 pkgs --update 把 HAL 拉到 <bsp>/packages/ 下,
Keil 工程本身仍然不会去这些路径找头文件和源文件,编译依然会失败。

复现步骤
  1. git clone https://github.com/RT-Thread/rt-thread.git
  2. 用 Keil MDK 打开 bsp/stm32/stm32f103-blue-pill/project.uvprojx
  3. 命令行编译:UV4.exe -j0 -b project.uvprojx -o build.log
  4. 结果(MDK 5.06 update 7 / AC5):
board\board.h(14): error:  #5: cannot open source input file "stm32f1xx.h": No such file or directory
  #include <stm32f1xx.h>
"no source": Error:  #5: cannot open source input file "..\libraries\HAL_Drivers\drivers\drv_gpio.c": No such file or directory
"no source": Error:  #5: cannot open source input file "..\libraries\HAL_Drivers\drivers\drv_usart.c": No such file or directory
"no source": Error:  #5: cannot open source input file "..\libraries\HAL_Drivers\drv_common.c": No such file or directory
board\CubeMX_Config\Inc\main.h(31): error:  #5: cannot open source input file "stm32f1xx_hal.h": No such file or directory
  #include "stm32f1xx_hal.h"
".\build\keil\Obj\rt-thread.axf" - 6 Error(s), 1 Warning(s).
Target not created.

stm32f1xx.h 属于 Cube HAL/CMSIS device 头文件。本机已安装 Keil.STM32F1xx_DFP 2.4.1
但该包只提供标准外设库的 stm32f10x.h,不含 Cube HAL 的 stm32f1xx.h,所以靠 DFP 包解决不了。)

相关背景

bsp/stm32/stm32f103-blue-pill/SConstruct 里有 bsp_pkg_check(),会检查三个软件包目录:

check_paths = [
    os.path.join("packages", "CMSIS-Core-latest"),
    os.path.join("packages", "stm32f1_cmsis_driver-latest"),
    os.path.join("packages", "stm32f1_hal_driver-latest")
]

.config 里也确实开启了 CONFIG_PKG_USING_STM32F1_HAL_DRIVER=yCONFIG_PKG_USING_STM32F1_CMSIS_DRIVER=y
所以包机制是通的,缺的是把这套路径同步进 Keil 工程这一步。

我注意到 bsp/stm32:Separate STM32F1 HAL drivers (#10209) 这个提交之后,
HAL 被拆成了独立软件包,而「快速上手」章节大概没有同步更新。

建议

「快速上手」的步骤 1 之后,可能还需要加上重新生成工程这一步,即 README_zh.md
「进阶使用」章节里已有的:

scons --target=mdk5

另外想请教下:pkgs --update 是否会同时更新 MDK 工程?如果会,那我上面的推断就是错的,
麻烦指正 —— 我没有 ENV 工具环境,无法实测这一步,只能从工程文件内容反推。

环境
  • RT-Thread master dc3da6d (2026-09-11)
  • Keil MDK 5,ARMCC V5.06 update 7 (build 960)
  • Windows 11

@Liang1795 麻烦帮忙确认下这个推断是否成立,谢谢!

主要语言
C
星标
12.2k
派生
5.4k
平均合并
5 天 14 小时
30 天内合并 PR
48

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

RT-Thread/rt-thread 的其他 Issue

查看 RT-Thread/rt-thread 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。