Skip to content

Commit 6895798

Browse files
committed
[board] Cleanup use of custom openocd configs
1 parent d5798ee commit 6895798

File tree

44 files changed

+134
-484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+134
-484
lines changed

src/modm/board/black_pill_f103/module.lb

+7-40
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,19 @@
1111
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
1212
# -----------------------------------------------------------------------------
1313

14-
description = """
14+
def init(module):
15+
module.name = ":board:black-pill-f103"
16+
module.description = """
1517
# Black Pill
1618
1719
STM32F103C8T6 "Black Pill" Minimum System Development Board
1820
1921
Cheap and bread-board-friendly board for STM32 F1 series.
20-
Sold for less than 2 USD on well known Internet shops from China.
22+
Sold for less than 2 USD on Aliexpress.
2123
2224
https://stm32-base.org/boards/STM32F103C8T6-Black-Pill.html
23-
24-
## Programming
25-
26-
Since the board doesn't have a programmer on-board, you need to use your
27-
own and *specify* which one you're using in a custom `openocd.cfg` file:
28-
29-
```
30-
# Replace this with your custom programmer
31-
source [find interface/stlink-v2.cfg]
32-
33-
# If you use the clone CKS32F103C8T6 chip you need to overwrite this ID
34-
#set CPUTAPID 0x2ba01477
35-
36-
# To select a specific programmer you can specify its serial number
37-
#hla_serial "\\x53\\x3f\\x6f\\x06\\x50\\x77\\x50\\x57\\x12\\x17\\x14\\x3f"
38-
# You can discover the serial via `stlink --hla-serial` or `st-info --hla-serial`.
39-
```
40-
41-
Then include this file in your build options like so:
42-
43-
```xml
44-
<library>
45-
<extends>modm:black-pill</extends>
46-
<options>
47-
<option name="modm:build:openocd.cfg">openocd.cfg</option>
48-
</options>
49-
</library>
50-
```
5125
"""
5226

53-
def init(module):
54-
module.name = ":board:black-pill-f103"
55-
module.description = description
56-
5727
def prepare(module, options):
5828
if not options[":target"].partname.startswith("stm32f103c8t"):
5929
return False
@@ -76,9 +46,6 @@ def build(env):
7646
env.copy('.')
7747

7848
env.outbasepath = "modm/openocd/modm/board/"
79-
env.copy(repopath("tools/openocd/modm/stm32f103_blue_pill.cfg"), "stm32f103_blue_pill.cfg")
80-
env.collect(":build:openocd.source", "modm/board/stm32f103_blue_pill.cfg")
81-
82-
# Warn the user if they forgot to set a custom openocd config
83-
if env.has_option(":build:openocd.cfg") and not len(env.get(":build:openocd.cfg", "")):
84-
env.log.warning("You need to provide the programmer via a custom OpenOCD config!\n" + description)
49+
env.template(repopath("tools/openocd/modm/stm32_swd.cfg.in"), "board.cfg",
50+
substitutions={"target": "stm32f1x"})
51+
env.collect(":build:openocd.source", "modm/board/board.cfg")

src/modm/board/black_pill_f401/module.lb

+5-23
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
def init(module):
1414
module.name = ":board:black-pill-f401"
15-
module.description = """\
15+
module.description = """
1616
# Black Pill F401
1717
1818
STM32F401CCU "Mini-F401" Minimum System Development Board
1919
2020
Cheap and bread-board-friendly board for STM32F401 series.
21-
Sold for less than 4 USD on well known Internet shops from China.
21+
Sold for less than 4 USD on Aliexpress.
2222
Attention: There are two variants: Mini-F411 and the cheaper Mini-F401.
2323
2424
https://stm32-base.org/boards/STM32F401CEU6-WeAct-Black-Pill-V3.0
@@ -32,25 +32,6 @@ A DFU command is integrated into the `modm:build:scons` tool and can be called a
3232
```
3333
scons program-dfu
3434
```
35-
36-
Alternatively you can go for an external programmer
37-
and *specify* which one you're using in a custom `openocd.cfg` file:
38-
39-
```
40-
# Replace this with your custom programmer
41-
source [find interface/stlink-v2.cfg]
42-
```
43-
44-
Then include this file in your build options like so:
45-
46-
```xml
47-
<library>
48-
<extends>modm:black-pill-f401</extends>
49-
<options>
50-
<option name="modm:build:openocd.cfg">openocd.cfg</option>
51-
</options>
52-
</library>
53-
```
5435
"""
5536

5637
def prepare(module, options):
@@ -75,5 +56,6 @@ def build(env):
7556
env.copy('../black_pill_f411/board.hpp', 'board.hpp')
7657

7758
env.outbasepath = "modm/openocd/modm/board/"
78-
env.copy(repopath("tools/openocd/modm/stm32f4x1_mini_f4x1.cfg"), "stm32f4x1_mini_f4x1.cfg")
79-
env.collect(":build:openocd.source", "modm/board/stm32f4x1_mini_f4x1.cfg")
59+
env.template(repopath("tools/openocd/modm/stm32_swd.cfg.in"), "board.cfg",
60+
substitutions={"target": "stm32f4x"})
61+
env.collect(":build:openocd.source", "modm/board/board.cfg")

src/modm/board/black_pill_f411/module.lb

+5-23
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
def init(module):
1414
module.name = ":board:black-pill-f411"
15-
module.description = """\
15+
module.description = """
1616
# Black Pill F411
1717
1818
STM32F411CEU "Mini-F411" Minimum System Development Board
1919
2020
Cheap and bread-board-friendly board for STM32F411 series.
21-
Sold for less than 5 USD on well known Internet shops from China.
21+
Sold for less than 5 USD on Aliexpress.
2222
Attention: There are two variants: Mini-F411 and the cheaper Mini-F401.
2323
2424
https://stm32-base.org/boards/STM32F401CEU6-WeAct-Black-Pill-V3.0
@@ -32,25 +32,6 @@ A DFU command is integrated into the `modm:build:scons` tool and can be called a
3232
```
3333
scons program-dfu
3434
```
35-
36-
Alternatively you can go for an external programmer
37-
and *specify* which one you're using in a custom `openocd.cfg` file:
38-
39-
```
40-
# Replace this with your custom programmer
41-
source [find interface/stlink-v2.cfg]
42-
```
43-
44-
Then include this file in your build options like so:
45-
46-
```xml
47-
<library>
48-
<extends>modm:black-pill-f411</extends>
49-
<options>
50-
<option name="modm:build:openocd.cfg">openocd.cfg</option>
51-
</options>
52-
</library>
53-
```
5435
"""
5536

5637
def prepare(module, options):
@@ -75,5 +56,6 @@ def build(env):
7556
env.copy('.')
7657

7758
env.outbasepath = "modm/openocd/modm/board/"
78-
env.copy(repopath("tools/openocd/modm/stm32f4x1_mini_f4x1.cfg"), "stm32f4x1_mini_f4x1.cfg")
79-
env.collect(":build:openocd.source", "modm/board/stm32f4x1_mini_f4x1.cfg")
59+
env.template(repopath("tools/openocd/modm/stm32_swd.cfg.in"), "board.cfg",
60+
substitutions={"target": "stm32f4x"})
61+
env.collect(":build:openocd.source", "modm/board/board.cfg")

src/modm/board/blue_pill_f103/module.lb

+7-40
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,19 @@
1111
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
1212
# -----------------------------------------------------------------------------
1313

14-
description = """
14+
def init(module):
15+
module.name = ":board:blue-pill-f103"
16+
module.description = """
1517
# Blue Pill
1618
1719
STM32F103C8T6 "Blue Pill" Minimum System Development Board
1820
1921
Cheap and bread-board-friendly board for STM32 F1 series.
20-
Sold for less than 2 USD on well known Internet shops from China.
22+
Sold for less than 2 USD on Aliexpress.
2123
2224
https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill.html
23-
24-
## Programming
25-
26-
Since the board doesn't have a programmer on-board, you need to use your
27-
own and *specify* which one you're using in a custom `openocd.cfg` file:
28-
29-
```
30-
# Replace this with your custom programmer
31-
source [find interface/stlink-v2.cfg]
32-
33-
# If you use the clone CKS32F103C8T6 chip you need to overwrite this ID
34-
#set CPUTAPID 0x2ba01477
35-
36-
# To select a specific programmer you can specify its serial number
37-
#hla_serial "\\x53\\x3f\\x6f\\x06\\x50\\x77\\x50\\x57\\x12\\x17\\x13\\x3f"
38-
# You can discover the serial via `stlink --hla-serial` or `st-info --hla-serial`.
39-
```
40-
41-
Then include this file in your build options like so:
42-
43-
```xml
44-
<library>
45-
<extends>modm:blue-pill-f103</extends>
46-
<options>
47-
<option name="modm:build:openocd.cfg">openocd.cfg</option>
48-
</options>
49-
</library>
50-
```
5125
"""
5226

53-
def init(module):
54-
module.name = ":board:blue-pill-f103"
55-
module.description = description
56-
5727
def prepare(module, options):
5828
if not options[":target"].partname.startswith("stm32f103c8t"):
5929
return False
@@ -76,9 +46,6 @@ def build(env):
7646
env.copy('.')
7747

7848
env.outbasepath = "modm/openocd/modm/board/"
79-
env.copy(repopath("tools/openocd/modm/stm32f103_blue_pill.cfg"), "stm32f103_blue_pill.cfg")
80-
env.collect(":build:openocd.source", "modm/board/stm32f103_blue_pill.cfg")
81-
82-
# Warn the user if they forgot to set a custom openocd config
83-
if env.has_option(":build:openocd.cfg") and not len(env.get(":build:openocd.cfg", "")):
84-
env.log.warning("You need to provide the programmer via a custom OpenOCD config!\n" + description)
49+
env.template(repopath("tools/openocd/modm/stm32_swd.cfg.in"), "board.cfg",
50+
substitutions={"target": "stm32f1x"})
51+
env.collect(":build:openocd.source", "modm/board/board.cfg")

src/modm/board/devebox_stm32f4xx/module.lb

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ def build(env):
4040
env.copy('.')
4141

4242
env.outbasepath = "modm/openocd/modm/board/"
43-
env.copy(repopath("tools/openocd/modm/stm32f4x1_mini_f4x1.cfg"), "stm32f4x1_mini_f4x1.cfg")
44-
env.collect(":build:openocd.source", "modm/board/stm32f4x1_mini_f4x1.cfg")
43+
env.template(repopath("tools/openocd/modm/stm32_swd.cfg.in"), "board.cfg",
44+
substitutions={"target": "stm32f4x"})
45+
env.collect(":build:openocd.source", "modm/board/board.cfg")

src/modm/board/devebox_stm32h750vb/module.lb

+6-39
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
1111
# -----------------------------------------------------------------------------
1212

13-
description = """
13+
def init(module):
14+
module.name = ":board:devebox-stm32h750vb"
15+
module.description = """
1416
# STM32F750VB mcudev DevEBox
1517
1618
[STM32F750VB mcudev DevEBox H7xx](https://github.com/mcauser/MCUDEV_DEVEBOX_H7XX_M)
@@ -32,40 +34,8 @@ target option in your `project.xml`:
3234
</options>
3335
</library>
3436
```
35-
36-
## Programming
37-
38-
Since the board doesn't have a programmer on-board, you need to use your
39-
own and *specify* which one you're using in a custom `openocd.cfg` file:
40-
41-
```
42-
# Replace this with your custom programmer
43-
source [find interface/stlink.cfg]
44-
45-
# If you use the clone CKS32F103C8T6 chip you need to overwrite this ID
46-
#set CPUTAPID 0x2ba01477
47-
48-
# To select a specific programmer you can specify its serial number
49-
#hla_serial "\\x53\\x3f\\x6f\\x06\\x50\\x77\\x50\\x57\\x12\\x17\\x13\\x3f"
50-
# You can discover the serial via `stlink --hla-serial` or `st-info --hla-serial`.
51-
```
52-
53-
Then include this file in your build options like so:
54-
55-
```xml
56-
<library>
57-
<extends>modm:devebox-stm32h750vb</extends>
58-
<options>
59-
<option name="modm:build:openocd.cfg">openocd.cfg</option>
60-
</options>
61-
</library>
62-
```
6337
"""
6438

65-
def init(module):
66-
module.name = ":board:devebox-stm32h750vb"
67-
module.description = description
68-
6939
def prepare(module, options):
7040
if not options[":target"].partname.startswith("stm32h750vbt"):
7141
return False
@@ -90,9 +60,6 @@ def build(env):
9060
env.copy('.')
9161

9262
env.outbasepath = "modm/openocd/modm/board/"
93-
env.copy(repopath("tools/openocd/modm/stm32h7xx_devebox.cfg"), "stm32h7xx_devebox.cfg")
94-
env.collect(":build:openocd.source", "modm/board/stm32h7xx_devebox.cfg")
95-
96-
# Warn the user if they forgot to set a custom openocd config
97-
if env.has_option(":build:openocd.cfg") and not len(env.get(":build:openocd.cfg", "")):
98-
env.log.warning("You need to provide the programmer via a custom OpenOCD config!\n" + description)
63+
env.template(repopath("tools/openocd/modm/stm32_swd.cfg.in"), "board.cfg",
64+
substitutions={"target": "stm32h7x"})
65+
env.collect(":build:openocd.source", "modm/board/board.cfg")

src/modm/board/feather_m0/module.lb

-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,3 @@ def build(env):
4747
}
4848
env.template("../board.cpp.in", "board.cpp")
4949
env.copy('.')
50-
51-
# env.outbasepath = "modm/openocd/modm/board/"
52-
# env.copy(repopath("tools/openocd/modm/stm32f103_blue_pill.cfg"), "stm32f103_blue_pill.cfg")
53-
# env.collect(":build:openocd.source", "modm/board/stm32f103_blue_pill.cfg");

src/modm/board/feather_rp2040/module.lb

+1-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,4 @@ def build(env):
4343
}
4444
env.template("../board.cpp.in", "board.cpp")
4545
env.copy('.')
46-
47-
env.outbasepath = "modm/openocd/modm/board/"
48-
env.copy(repopath("tools/openocd/modm/rp2040_picoprobe.cfg"), "rp2040_picoprobe.cfg")
49-
env.collect(":build:openocd.source", "modm/board/rp2040_picoprobe.cfg")
46+
env.collect(":build:openocd.source", "interface/picoprobe.cfg", "target/rp2040.cfg")

src/modm/board/module.md

+39
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,45 @@ int main()
6666
same functions resulting in naming conflicts.
6767

6868

69+
## Programming
70+
71+
Most development boards have a programmer on-board and the BSPs are configured
72+
to use them automatically.
73+
74+
However, for development boards without a programmer on-board, you need to use
75+
your own and *specify* which one you're using. For simple configuration, adding
76+
a collector is enough:
77+
78+
```xml
79+
<library>
80+
<collectors>
81+
<collect name="modm:build:openocd.source">interface/stlink.cfg</collect>
82+
</collectors>
83+
</library>
84+
```
85+
86+
For more complex configuration, add a custom `openocd.cfg` file:
87+
88+
```tcl
89+
# Replace this with your custom programmer
90+
source [find interface/stlink.cfg]
91+
92+
# To select a specific programmer you can specify its serial number
93+
hla_serial "\\x53\\x3f\\x6f\\x06\\x50\\x77\\x50\\x57\\x12\\x17\\x14\\x3f"
94+
# You can discover the serial via `lsusb -v`.
95+
```
96+
97+
Then include this file in your build options like so:
98+
99+
```xml
100+
<library>
101+
<options>
102+
<option name="modm:build:openocd.cfg">openocd.cfg</option>
103+
</options>
104+
</library>
105+
```
106+
107+
69108
## Customization
70109

71110
The BSPs contain an opinionated set of pre-defined functionality and settings.

src/modm/board/nucleo_c031c6/module.lb

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ def build(env):
3939
env.copy("../nucleo64_arduino_c0.hpp", "nucleo64_arduino.hpp")
4040

4141
env.outbasepath = "modm/openocd/modm/board/"
42-
env.copy(repopath("tools/openocd/modm/st_nucleo_c0.cfg"), "st_nucleo_c0.cfg")
43-
env.collect(":build:openocd.source", "modm/board/st_nucleo_c0.cfg")
42+
env.template(repopath("tools/openocd/modm/st_nucleo_swd.cfg.in"), "board.cfg",
43+
substitutions={"target": "stm32c0x"})
44+
env.collect(":build:openocd.source", "modm/board/board.cfg")

src/modm/board/nucleo_g070rb/module.lb

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,4 @@ def build(env):
3535
}
3636
env.template("../board.cpp.in", "board.cpp")
3737
env.copy("../nucleo_g071rb/board.hpp", "board.hpp")
38-
39-
env.outbasepath = "modm/openocd/modm/board/"
40-
env.copy(repopath("tools/openocd/modm/st_nucleo_g0.cfg"), "st_nucleo_g0.cfg")
41-
env.collect(":build:openocd.source", "modm/board/st_nucleo_g0.cfg")
38+
env.collect(":build:openocd.source", "board/st_nucleo_g0.cfg")

0 commit comments

Comments
 (0)