From 39a805dd40df53a8a442720d90c4362b1c840587 Mon Sep 17 00:00:00 2001 From: Just Chen <111217154+moment-NEW@users.noreply.github.com> Date: Sun, 8 Feb 2026 19:56:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?Docs:(STM32=E7=B3=BB=E5=88=97BSP=E5=88=B6?= =?UTF-8?q?=E4=BD=9C=E6=95=99=E7=A8=8B.md)=E6=9B=B4=E6=96=B0=E4=BA=86SCons?= =?UTF-8?q?cript=E7=9A=84=E7=BC=96=E5=86=99=E6=95=99=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated instructions for modifying SConscript scripts and project templates in the STM32 BSP documentation. --- ...66\344\275\234\346\225\231\347\250\213.md" | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git "a/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" "b/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" index 4fb48c67579..a0dce17137a 100644 --- "a/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" +++ "b/bsp/stm32/docs/STM32\347\263\273\345\210\227BSP\345\210\266\344\275\234\346\225\231\347\250\213.md" @@ -210,13 +210,35 @@ BSP 的制作过程分为如下五个步骤: #### 3.4.2 修改构建脚本 -**SConscript** 脚本决定 MDK/IAR 工程的生成以及编译过程中要添加文件。 +**SConscript** 脚本决定 MDK/IAR 工程的生成以及编译过程中要添加的文件。 -在这一步中需要修改芯片型号以及芯片启动文件的地址,修改内容如下图所示: +在这一步中需要修改芯片型号以及芯片启动文件的地址,在BSP目录中存在两个SConscript文件,其中只有根目录下的需要修改,修改内容如下所示: -![修改启动文件和芯片型号](./figures/SConscript.png) +```diff +# for module compiling +import os +Import('RTT_ROOT') +Import('env') +from building import * -注意:如果在文件夹中找不到相应系列的 .s 文件,可能是多个系列的芯片重用了相同的启动文件,此时可以在 CubeMX 中生成目标芯片的工程,查看使用了哪个启动文件,然后再修改启动文件名。 +cwd = GetCurrentDir() +objs = [] +list = os.listdir(cwd) + +- # 修改前模板中的存在如下宏定义语句: +- env.Append(CPPDEFINES = ['STM32H723xx'])# 目标芯片宏定义,hal库将使用这个宏定义作判断 ++ # 修改宏定义为对应的芯片型号,例如对于STM32F103xB,修改后的内容如下: ++ env.Append(CPPDEFINES = ['STM32F103xB']) +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + objs = objs + SConscript(os.path.join(d, 'SConscript')) + +Return('objs') + + +``` +注意:由于BSP瘦身计划,template目录下的模板已经过时,SConscript文件可能与示例有所差异,请参考实际BSP或等待更新。 #### 3.4.3 修改工程模板 @@ -233,8 +255,11 @@ BSP 的制作过程分为如下五个步骤: ![配置下载方式](./figures/template_3.png) ### 3.5 重新生成工程 +工程生成需要使用 Env 工具。 + +在进行工程生成前,必须在 Env 工具中执行 `pkgs --update` 命令。 -重新生成工程需要使用 Env 工具。 +该命令会根据 Kconfig 配置自动拉取对应的 HAL 库软件包,这是后续编译成功的关键。 #### 3.5.1 重新生成 rtconfig.h 文件 From 096c8d5f41303769c56921ca98b5c922396c4f1e Mon Sep 17 00:00:00 2001 From: Just Chen <111217154+moment-NEW@users.noreply.github.com> Date: Sun, 8 Feb 2026 20:23:54 +0800 Subject: [PATCH 2/3] Update file How to make a STM32 BSP for RT-Thread.md --- .../How to make a STM32 BSP for RT-Thread.md | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md b/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md index d8afb417334..5d1880b5ead 100644 --- a/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md +++ b/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md @@ -54,7 +54,7 @@ Modify the configuration file in the board folder. The modified content is shown | Item | Instruction | | ------------------------- | ------------------------------------------------------------ | -| CubeMX_Config (folder) | CubeMX project | +| CubeMX_Config (folder�� | CubeMX project | | linker_scripts (folder) | BSP link script | | board.c/h | System clock, GPIO initialization function, chip memory size | | Kconfig | Chip series, peripheral resources | @@ -166,11 +166,32 @@ The other two link script files are link.icf used by IAR and link.lds used by th The **SConscript** script determines the files to be added during the generation and compilation of the MDK/IAR project. -In this step, you need to modify the chip model and the address of the chip startup file. The modification content is shown in the figure below: +In this step, you need to modify the chip model and the address of the chip startup file. There are two SConscript files in the BSP directory, and only the one in the root directory needs to be modified, as shown below: -![Modify the startup file and chip model](./figures_en/SConscript.png) +```diff +# for module compiling +import os +Import('RTT_ROOT') +Import('env') +from building import * -Note: If you cannot find the .s file of the corresponding series in the folder, it may be that multiple series of chips reuse the same startup file. At this time, you can generate the target chip project in CubeMX to see which startup file is used. Then modify the startup file name. +cwd = GetCurrentDir() +objs = [] +list = os.listdir(cwd) + +- # The following macro definition statement exists in the template before modification: +- env.Append(CPPDEFINES = ['STM32H723xx'])# Target chip macro definition, hal library will use this macro definition for judgment ++ # Modify the macro definition to the corresponding chip model. For example, for STM32F103xB, the modified content is as follows: ++ env.Append(CPPDEFINES = ['STM32F103xB']) +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + objs = objs + SConscript(os.path.join(d, 'SConscript')) + +Return('objs') +``` + +Note: Due to the BSP weight loss plan, the templates in the template directory are outdated, and the SConscript file may be different from the example. Please refer to the actual BSP or wait for an update. #### 3.4.3 Modify the project template @@ -190,6 +211,10 @@ Modify the program download method: Env tool is required to regenerate the project. +Before regenerating the project, you must execute the `pkgs --update` command in the Env tool. + +This command will automatically pull the corresponding HAL library package according to the Kconfig configuration, which is the key to subsequent compilation success. + #### 3.5.1 Regenerate the rtconfig.h file Enter the command menuconfig in the Env interface to configure the project and generate a new rtconfig.h file. As shown below: @@ -255,5 +280,4 @@ The specifications of making STM32 BSP are mainly divided into three aspects: en - Only submit documents necessary for the BSP and delete irrelevant intermediate documents. Please check other BSPs for documents that can be submitted. - When submitting libraries of different series of STM32, please refer to the HAL libraries of f1/f4 series and delete redundant library files. - Compile and test the BSP before submission to ensure that it compiles properly under different compilers. -- Perform functional tests on the BSP before submission to ensure that the BSP meets the requirements in the engineering configuration chapter before submission. - +- Perform functional tests on the BSP before submission to ensure that the BSP meets the requirements in the engineering configuration chapter before submission. From bad54fbe9d5a1e6ae623afcfeec2f7bda4107f7e Mon Sep 17 00:00:00 2001 From: Just Chen <111217154+moment-NEW@users.noreply.github.com> Date: Sun, 8 Feb 2026 20:39:22 +0800 Subject: [PATCH 3/3] Docs:Fix typo in documentation for STM32 BSP setup line 57 ,typo problem --- bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md b/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md index 5d1880b5ead..95a798b17a3 100644 --- a/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md +++ b/bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md @@ -54,7 +54,7 @@ Modify the configuration file in the board folder. The modified content is shown | Item | Instruction | | ------------------------- | ------------------------------------------------------------ | -| CubeMX_Config (folder�� | CubeMX project | +| CubeMX_Config (folder) | CubeMX project | | linker_scripts (folder) | BSP link script | | board.c/h | System clock, GPIO initialization function, chip memory size | | Kconfig | Chip series, peripheral resources |