Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#11,818 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c

Direzione di ricerca

Confronta le sezioni「快速上手」e「进阶使用」di README_zh.md, quindi esamina bsp/stm32/stm32f103-blue-pill/SConstruct e project.uvprojx per confermare come i pacchetti entrano nel progetto MDK. Esegui scons --target=mdk5 dopo pkgs --update e verifica che il progetto generato faccia riferimento ai file HAL/CMSIS richiesti e possa essere compilato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

问题描述

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

Lingua principale
C
Stelle
12.2k
Fork
5.4k
Merge medio
5g 14h
PR unite (30g)
48

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di RT-Thread/rt-thread

Tutte le issue di RT-Thread/rt-thread

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.