Skip to content

Commit cd74d9e

Browse files
committed
update makeboards to use f-string
1 parent 878ef4f commit cd74d9e

File tree

1 file changed

+93
-72
lines changed

1 file changed

+93
-72
lines changed

tools/makeboards.py

Lines changed: 93 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -26,92 +26,92 @@ def get_mcu(name):
2626
def build_upload(name):
2727
mcu = get_mcu(name)
2828
print("# Upload")
29-
print("%s.bootloader.tool=bootburn" % name)
30-
print("%s.upload.tool=nrfutil" % name)
31-
print("%s.upload.protocol=nrfutil" % name)
29+
print(f"{name}.bootloader.tool=bootburn")
30+
print(f"{name}.upload.tool=nrfutil")
31+
print(f"{name}.upload.protocol=nrfutil")
3232
if mcu == 52832:
33-
print("%s.upload.use_1200bps_touch=false" % name)
34-
print("%s.upload.wait_for_upload_port=false" % name)
35-
print("%s.upload.native_usb=false" % name)
33+
print(f"{name}.upload.use_1200bps_touch=false")
34+
print(f"{name}.upload.wait_for_upload_port=false")
35+
print(f"{name}.upload.native_usb=false")
3636
else:
37-
print("%s.upload.use_1200bps_touch=true" % name)
38-
print("%s.upload.wait_for_upload_port=true" % name)
39-
print("%s.upload.maximum_size=%d" % (name, mcu_dict[mcu]['flash_size']))
40-
print("%s.upload.maximum_data_size=%d" % (name, mcu_dict[mcu]['data_size']))
37+
print(f"{name}.upload.use_1200bps_touch=true")
38+
print(f"{name}.upload.wait_for_upload_port=true")
39+
print(f"{name}.upload.maximum_size={mcu_dict[mcu]['flash_size']}")
40+
print(f"{name}.upload.maximum_data_size={mcu_dict[mcu]['data_size']}")
4141
print()
4242

4343

4444
def build_header(name, variant, vendor_name, product_name, boarddefine, vid, pid_list):
4545
prettyname = vendor_name + " " + product_name
4646
print()
4747
print("# -----------------------------------")
48-
print("# %s" % prettyname)
48+
print(f"# {prettyname}")
4949
print("# -----------------------------------")
50-
print("%s.name=%s" % (name, prettyname))
50+
print(f"{name}.name={prettyname}")
5151
print()
5252

5353
print("# VID/PID for Bootloader, Arduino & CircuitPython")
5454
for i in range(len(pid_list)):
55-
print("%s.vid.%d=%s" % (name, i, vid))
56-
print("%s.pid.%d=%s" % (name, i, pid_list[i]))
55+
print(f"{name}.vid.{i}={vid}")
56+
print(f"{name}.pid.{i}={pid_list[i]}")
5757
print()
5858

5959
build_upload(name)
6060

6161
print("# Build")
62-
print("%s.build.mcu=cortex-m4" % name)
63-
print("%s.build.f_cpu=64000000" % name)
64-
print("%s.build.board=%s" % (name, boarddefine))
65-
print("%s.build.core=nRF5" % name)
66-
print("%s.build.variant=%s" % (name, variant))
67-
print('%s.build.usb_manufacturer="%s"' % (name, vendor_name))
68-
print('%s.build.usb_product="%s"' % (name, product_name))
62+
print(f"{name}.build.mcu=cortex-m4")
63+
print(f"{name}.build.f_cpu=64000000")
64+
print(f"{name}.build.board={boarddefine}")
65+
print(f"{name}.build.core=nRF5")
66+
print(f"{name}.build.variant={variant}")
67+
print(f'{name}.build.usb_manufacturer="{vendor_name}"')
68+
print(f'{name}.build.usb_product="{product_name}"')
6969

7070
mcu = get_mcu(name)
71-
print("%s.build.extra_flags=%s" % (name, mcu_dict[mcu]['extra_flags']))
72-
print("%s.build.ldscript=%s" % (name, mcu_dict[mcu]['ldscript']))
71+
print(f"{name}.build.extra_flags={mcu_dict[mcu]['extra_flags']}")
72+
print(f"{name}.build.ldscript={mcu_dict[mcu]['ldscript']}")
7373
if mcu != 52832:
74-
print("%s.build.vid=%s" % (name, vid))
75-
print("%s.build.pid=%s" % (name, pid_list[0]))
74+
print(f"{name}.build.vid={vid}")
75+
print(f"{name}.build.pid={pid_list[0]}")
7676
print()
7777

7878

7979
def build_softdevice(name):
8080
print("# SoftDevice Menu")
8181
if get_mcu(name) == 52832:
82-
print("%s.menu.softdevice.s132v6=S132 6.1.1" % name)
83-
print("%s.menu.softdevice.s132v6.build.sd_name=s132" % name)
84-
print("%s.menu.softdevice.s132v6.build.sd_version=6.1.1" % name)
85-
print("%s.menu.softdevice.s132v6.build.sd_fwid=0x00B7" % name)
82+
print(f"{name}.menu.softdevice.s132v6=S132 6.1.1")
83+
print(f"{name}.menu.softdevice.s132v6.build.sd_name=s132")
84+
print(f"{name}.menu.softdevice.s132v6.build.sd_version=6.1.1")
85+
print(f"{name}.menu.softdevice.s132v6.build.sd_fwid=0x00B7")
8686
else:
87-
print("%s.menu.softdevice.s140v6=S140 6.1.1" % name)
88-
print("%s.menu.softdevice.s140v6.build.sd_name=s140" % name)
89-
print("%s.menu.softdevice.s140v6.build.sd_version=6.1.1" % name)
90-
print("%s.menu.softdevice.s140v6.build.sd_fwid=0x00B6" % name)
87+
print(f"{name}.menu.softdevice.s140v6=S140 6.1.1")
88+
print(f"{name}.menu.softdevice.s140v6.build.sd_name=s140")
89+
print(f"{name}.menu.softdevice.s140v6.build.sd_version=6.1.1")
90+
print(f"{name}.menu.softdevice.s140v6.build.sd_fwid=0x00B6")
9191
print()
9292

9393

9494
def build_debug(name):
9595
print("# Debug Menu")
96-
print("%s.menu.debug.l0=Level 0 (Release)" % name)
97-
print("%s.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0" % name)
98-
print("%s.menu.debug.l1=Level 1 (Error Message)" % name)
99-
print("%s.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1" % name)
100-
print("%s.menu.debug.l2=Level 2 (Full Debug)" % name)
101-
print("%s.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2" % name)
102-
print("%s.menu.debug.l3=Level 3 (Segger SystemView)" % name)
103-
print("%s.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3" % name)
104-
print("%s.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1" % name)
96+
print(f"{name}.menu.debug.l0=Level 0 (Release)")
97+
print(f"{name}.menu.debug.l0.build.debug_flags=-DCFG_DEBUG=0")
98+
print(f"{name}.menu.debug.l1=Level 1 (Error Message)")
99+
print(f"{name}.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1")
100+
print(f"{name}.menu.debug.l2=Level 2 (Full Debug)")
101+
print(f"{name}.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2")
102+
print(f"{name}.menu.debug.l3=Level 3 (Segger SystemView)")
103+
print(f"{name}.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3")
104+
print(f"{name}.menu.debug.l3.build.sysview_flags=-DCFG_SYSVIEW=1")
105105
print()
106106

107107
def build_debug_output(name):
108108
print("# Debug Output Menu")
109-
print("%s.menu.debug_output.serial=Serial" % name)
110-
print("%s.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0" % name)
111-
print("%s.menu.debug_output.serial1=Serial1" % name)
112-
print("%s.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG" % name)
113-
print("%s.menu.debug_output.rtt=Segger RTT" % name)
114-
print("%s.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL" % name)
109+
print(f"{name}.menu.debug_output.serial=Serial")
110+
print(f"{name}.menu.debug_output.serial.build.logger_flags=-DCFG_LOGGER=0")
111+
print(f"{name}.menu.debug_output.serial1=Serial1")
112+
print(f"{name}.menu.debug_output.serial1.build.logger_flags=-DCFG_LOGGER=1 -DCFG_TUSB_DEBUG=CFG_DEBUG")
113+
print(f"{name}.menu.debug_output.rtt=Segger RTT")
114+
print(f"{name}.menu.debug_output.rtt.build.logger_flags=-DCFG_LOGGER=2 -DCFG_TUSB_DEBUG=CFG_DEBUG -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL")
115115

116116
def build_global_menu():
117117
print("menu.softdevice=SoftDevice")
@@ -125,44 +125,65 @@ def make_board(name, variant, vendor_name, product_name, boarddefine, vid, pid_l
125125
build_debug_output(name)
126126

127127

128+
# ------------------------------
129+
# main
130+
# ------------------------------
128131
build_global_menu()
129132

130-
make_board("feather52832", "feather_nrf52832", "Adafruit", "Feather nRF52832", "NRF52832_FEATHER",
131-
"0x239A", [])
132-
make_board("feather52840", "feather_nrf52840_express", "Adafruit", "Feather nRF52840 Express", "NRF52840_FEATHER",
133-
"0x239A", ["0x8029", "0x0029", "0x002A", "0x802A"])
133+
# ------------------------------
134+
# Adafruit Boards
135+
# ------------------------------
134136

135-
make_board("feather52840sense", "feather_nrf52840_sense", "Adafruit", "Feather nRF52840 Sense", "NRF52840_FEATHER_SENSE",
136-
"0x239A", ["0x8087", "0x0087", "0x0088", "0x8088"])
137+
adafruit_boards_list = [
138+
["feather52832", "feather_nrf52832", "Adafruit", "Feather nRF52832", "NRF52832_FEATHER",
139+
"0x239A", []],
137140

138-
make_board("itsybitsy52840", "itsybitsy_nrf52840_express", "Adafruit", "ItsyBitsy nRF52840 Express", "NRF52840_ITSYBITSY -DARDUINO_NRF52_ITSYBITSY",
139-
"0x239A", ["0x8051", "0x0051", "0x0052", "0x8052"])
141+
["feather52840", "feather_nrf52840_express", "Adafruit", "Feather nRF52840 Express", "NRF52840_FEATHER",
142+
"0x239A", ["0x8029", "0x0029", "0x002A", "0x802A"]],
140143

141-
make_board("cplaynrf52840", "circuitplayground_nrf52840", "Adafruit", "Circuit Playground Bluefruit", "NRF52840_CIRCUITPLAY",
142-
"0x239A", ["0x8045", "0x0045", "0x8046"])
144+
["feather52840sense", "feather_nrf52840_sense", "Adafruit", "Feather nRF52840 Sense", "NRF52840_FEATHER_SENSE",
145+
"0x239A", ["0x8087", "0x0087", "0x0088", "0x8088"]],
143146

144-
make_board("cluenrf52840", "clue_nrf52840", "Adafruit", "CLUE", "NRF52840_CLUE",
145-
"0x239A", ["0x8071", "0x0071", "0x8072"])
147+
["itsybitsy52840", "itsybitsy_nrf52840_express", "Adafruit", "ItsyBitsy nRF52840 Express", "NRF52840_ITSYBITSY -DARDUINO_NRF52_ITSYBITSY",
148+
"0x239A", ["0x8051", "0x0051", "0x0052", "0x8052"]],
146149

147-
make_board("ledglasses_nrf52840", "ledglasses_nrf52840", "Adafruit", "LED Glasses Driver nRF52840", "NRF52840_LED_GLASSES",
148-
"0x239A", ["0x810D", "0x010D", "0x810E"])
150+
["cplaynrf52840", "circuitplayground_nrf52840", "Adafruit", "Circuit Playground Bluefruit", "NRF52840_CIRCUITPLAY",
151+
"0x239A", ["0x8045", "0x0045", "0x8046"]],
149152

150-
make_board("mdbt50qrx", "raytac_mdbt50q_rx", "Raytac", "nRF52840 Dongle", "MDBT50Q_RX",
151-
"0x239A", ["0x810B", "0x010B", "0x810C"])
153+
["cluenrf52840", "clue_nrf52840", "Adafruit", "CLUE", "NRF52840_CLUE",
154+
"0x239A", ["0x8071", "0x0071", "0x8072"]],
152155

153-
make_board("metro52840", "metro_nrf52840_express", "Adafruit", "Metro nRF52840 Express", "NRF52840_METRO",
154-
"0x239A", ["0x803F", "0x003F", "0x0040", "0x8040"])
156+
["ledglasses_nrf52840", "ledglasses_nrf52840", "Adafruit", "LED Glasses Driver nRF52840", "NRF52840_LED_GLASSES",
157+
"0x239A", ["0x810D", "0x010D", "0x810E"]],
158+
159+
["mdbt50qrx", "raytac_mdbt50q_rx", "Raytac", "nRF52840 Dongle", "MDBT50Q_RX",
160+
"0x239A", ["0x810B", "0x010B", "0x810C"]],
161+
162+
["metro52840", "metro_nrf52840_express", "Adafruit", "Metro nRF52840 Express", "NRF52840_METRO",
163+
"0x239A", ["0x803F", "0x003F", "0x0040", "0x8040"]],
164+
]
165+
166+
for b in adafruit_boards_list:
167+
make_board(*b)
168+
169+
# ------------------------------
170+
# 3rd Party Boards
171+
# ------------------------------
155172

156173
print()
157174
print()
158175
print("# -------------------------------------------------------")
159-
print("#")
160176
print("# Boards that aren't made by Adafruit")
161-
print("#")
177+
print("# and are not officially supported")
162178
print("# -------------------------------------------------------")
163179

164-
make_board("pca10056", "pca10056", "Nordic", "nRF52840 DK", "NRF52840_PCA10056",
165-
"0x239A", ["0x8029", "0x0029"])
180+
thirdparty_boards_list = [
181+
["pca10056", "pca10056", "Nordic", "nRF52840 DK", "NRF52840_PCA10056",
182+
"0x239A", ["0x8029", "0x0029"]],
183+
184+
["particle_xenon", "particle_xenon", "Particle", "Xenon", "PARTICLE_XENON",
185+
"0x239A", ["0x8029", "0x0029"]],
186+
]
166187

167-
make_board("particle_xenon", "particle_xenon", "Particle", "Xenon", "PARTICLE_XENON",
168-
"0x239A", ["0x8029", "0x0029"])
188+
for b in thirdparty_boards_list:
189+
make_board(*b)

0 commit comments

Comments
 (0)