Skip to content

Commit 096c8d5

Browse files
committed
Update file How to make a STM32 BSP for RT-Thread.md
1 parent 39a805d commit 096c8d5

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

bsp/stm32/docs/How to make a STM32 BSP for RT-Thread.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Modify the configuration file in the board folder. The modified content is shown
5454

5555
| Item | Instruction |
5656
| ------------------------- | ------------------------------------------------------------ |
57-
| CubeMX_Config (folder | CubeMX project |
57+
| CubeMX_Config (folder�� | CubeMX project |
5858
| linker_scripts (folder) | BSP link script |
5959
| board.c/h | System clock, GPIO initialization function, chip memory size |
6060
| 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
166166

167167
The **SConscript** script determines the files to be added during the generation and compilation of the MDK/IAR project.
168168

169-
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:
169+
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:
170170

171-
![Modify the startup file and chip model](./figures_en/SConscript.png)
171+
```diff
172+
# for module compiling
173+
import os
174+
Import('RTT_ROOT')
175+
Import('env')
176+
from building import *
172177

173-
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.
178+
cwd = GetCurrentDir()
179+
objs = []
180+
list = os.listdir(cwd)
181+
182+
- # The following macro definition statement exists in the template before modification:
183+
- env.Append(CPPDEFINES = ['STM32H723xx'])# Target chip macro definition, hal library will use this macro definition for judgment
184+
+ # Modify the macro definition to the corresponding chip model. For example, for STM32F103xB, the modified content is as follows:
185+
+ env.Append(CPPDEFINES = ['STM32F103xB'])
186+
for d in list:
187+
path = os.path.join(cwd, d)
188+
if os.path.isfile(os.path.join(path, 'SConscript')):
189+
objs = objs + SConscript(os.path.join(d, 'SConscript'))
190+
191+
Return('objs')
192+
```
193+
194+
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.
174195

175196
#### 3.4.3 Modify the project template
176197

@@ -190,6 +211,10 @@ Modify the program download method:
190211

191212
Env tool is required to regenerate the project.
192213

214+
Before regenerating the project, you must execute the `pkgs --update` command in the Env tool.
215+
216+
This command will automatically pull the corresponding HAL library package according to the Kconfig configuration, which is the key to subsequent compilation success.
217+
193218
#### 3.5.1 Regenerate the rtconfig.h file
194219

195220
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
255280
- Only submit documents necessary for the BSP and delete irrelevant intermediate documents. Please check other BSPs for documents that can be submitted.
256281
- When submitting libraries of different series of STM32, please refer to the HAL libraries of f1/f4 series and delete redundant library files.
257282
- Compile and test the BSP before submission to ensure that it compiles properly under different compilers.
258-
- Perform functional tests on the BSP before submission to ensure that the BSP meets the requirements in the engineering configuration chapter before submission.
259-
283+
- Perform functional tests on the BSP before submission to ensure that the BSP meets the requirements in the engineering configuration chapter before submission.

0 commit comments

Comments
 (0)