Skip to content

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

Description

@Ren6694

问题描述

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 麻烦帮忙确认下这个推断是否成立,谢谢!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions