Skip to content

Commit 4306dff

Browse files
authored
Merge pull request #21767 from crasbe/pr/guide_stm32_flashing
doc/guides: add STM32 Flashing Guide
2 parents f3781c8 + 0c9c643 commit 4306dff

File tree

4 files changed

+81
-21
lines changed

4 files changed

+81
-21
lines changed
File renamed without changes.

doc/guides/board_specific/stm32.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: STM32 Flashing
3+
description: Guide on how to flash STM32 boards
4+
---
5+
6+
## Flashing the Board Using OpenOCD
7+
8+
The ST Nucleo32, 64 and 144 boards include an on-board ST-LINK programmer
9+
and can be flashed using OpenOCD (use version 0.11.0 at least).
10+
OpenOCD is the standard programmer for all Nucleo boards, so no explicit
11+
`PROGRAMMER` environment variable has to be set.
12+
13+
To flash this board, just use the following command (replace the `xxxxx`
14+
with your Nucleo variant):
15+
16+
```shell
17+
make BOARD=nucleo-xxxxx flash -C examples/basic/hello-world
18+
```
19+
20+
If your board does not have OpenOCD set as the default programmer, you can
21+
select it by explicitly setting the `PROGRAMMER` variable:
22+
23+
```shell
24+
make BOARD=xxxxx PROGARMMER=openocd flash
25+
```
26+
27+
## Flashing the Board Using the ST-LINK Mass Storage Device
28+
29+
The on-board ST-Link programmer found on all Nucleo32, 64 and 144 boards
30+
will show up as a mass storage device when plugged in via USB.
31+
Copying a HEX file to the mass storage device will trigger the flashing
32+
sequence of the ST-Link. This can either be done manually or with the
33+
`cpy2remed` (copy to removable media) PROGRAMMER script. To use this programmer,
34+
you can use the following command:
35+
36+
```shell
37+
make BOARD=nucleo-xxxx PROGRAMMER=cpy2remed flash
38+
```
39+
40+
:::note
41+
If the flash operation fails for some reason, it is possible that
42+
the embedded ST-Link firmware is either too old or has bugs that have been
43+
fixed in the meantime. You can find updates for the ST-Link on
44+
[this STM webpage](https://www.st.com/en/development-tools/stsw-link007.html).
45+
:::
46+
47+
## Flashing the Board using stm32flash
48+
49+
It is possible to automatically boot the STM32 board into the in-ROM bootloader
50+
that `stm32flash` communicates with for flashing by connecting the RST pin to
51+
DTR and the BOOT pin (or BOOT0 for STM32 MCU families with BOOT0 and BOOT1 pins)
52+
to RTS of the TTL adapter. In addition, set `STM32FLASH_RESET` to `1` via
53+
environment or command line to actually issue a reset with BOOT (or BOOT0)
54+
pulled high prior flashing to enter the bootloader, and a second reset with BOOT
55+
(or BOOT0) pulled low to reboot into the application. `STM32FLASH_RESET`
56+
defaults to `0` as of know, as with `PROGRAMMER=stm32flash STM32FLASH_RESET=1`
57+
additional terminal flags are set, so that `make term` doesn't accidentally
58+
keep the reset signal pulled low or boots the board into the bootloader.
59+
60+
```shell
61+
make BOARD=xxxx PROGRAMMER=stm32flash STM32FLASH_RESET=1 flash
62+
```
63+
64+
The TTL adapter this was tested with had inverted RTS and DTR signal. By setting
65+
`STM32FLASH_RESET_INVERT` to `1` RIOT will assume RTS and DTR signals to be
66+
inverted, by setting it to `0` non-inverted signals will be generated. As of
67+
now, `STM32FLASH_RESET_INVERT` is by default `1`. This may change if it
68+
becomes evident that non-inverted TTL adapters are in fact more common than
69+
inverted adapters.

doc/guides/build-system/flashing.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ see [Adafruit nRF52 Bootloader Common](https://doc.riot-os.org/group__boards__co
124124
- `cpy2remed` (requires integrated ST-Link programmer, e.g. Nucleo boards)
125125
- `robotis-loader` (requires robotis bootloader, only one board supported)
126126

127+
See also: [STM32 Flashing Guide](/board_specific/stm32)
128+
127129
## Programmer Configuration
128130

129131
This section will list additional configuration options to control the behavior
@@ -189,26 +191,6 @@ JTAG. Also JTAG requires more signal lines to be connected compared to SWD and
189191
some internal programmers only have the SWD signal lines connected, so that
190192
JTAG will not be possible.
191193

192-
### stm32flash Configuration
193-
194-
It is possible to automatically boot the STM32 board into the in-ROM bootloader
195-
that `stm32flash` communicates with for flashing by connecting the RST pin to
196-
DTR and the BOOT pin (or BOOT0 for STM32 MCU families with BOOT0 and BOOT1 pins)
197-
to RTS of the TTL adapter. In addition, set `STM32FLASH_RESET` to `1` via
198-
environment or command line to actually issue a reset with BOOT (or BOOT0)
199-
pulled high prior flashing to enter the bootloader, and a second reset with BOOT
200-
(or BOOT0) pulled low to reboot into the application. `STM32FLASH_RESET`
201-
defaults to `0` as of know, as with `PROGRAMMER=stm32flash STM32FLASH_RESET=1`
202-
additional terminal flags are set, so that `make term` doesn't accidentally
203-
keeps the reset signal pulled low or boot the board into the bootloader.
204-
205-
The TTL adapter this was tested with had inverted RTS and DTR signal. By setting
206-
`STM32FLASH_RESET_INVERT` to `1` RIOT will assume RTS and DTR signals to be
207-
inverted, by setting it to `0` non-inverted signals will be generated. As of
208-
now, `STM32FLASH_RESET_INVERT` is by default `1`. This may change if it
209-
becomes evident that non-inverted TTL adapters are in fact more common than
210-
inverted adapters.
211-
212194
### MSPDEBUG Configuration
213195

214196
All options can be passed as environment variables or as make arguments.

doc/starlight/astro.config.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,17 @@ export default defineConfig({
152152
"build-system/debugging_aids",
153153
],
154154
},
155+
{
156+
label: "Board Specific",
157+
items: [
158+
"board_specific/stm32",
159+
"board_specific/io_mapping_and_shields",
160+
],
161+
},
155162
{
156163
label: "Miscellaneous",
157164
items: [
158165
"misc/dev_best_practices",
159-
"misc/io_mapping_and_shields",
160166
"misc/roadmap",
161167
"misc/lost_and_found",
162168
"misc/release_cycle",
@@ -182,6 +188,9 @@ export default defineConfig({
182188
},
183189
}),
184190
],
191+
redirects: {
192+
"/misc/io_mapping_and_shields": "/board_specific/io_mapping_and_shields",
193+
},
185194
vite: {
186195
server: {
187196
fs: {

0 commit comments

Comments
 (0)