Skip to content

Commit ec7503f

Browse files
committed
Update bootloader options
1 parent b725b5c commit ec7503f

File tree

8 files changed

+173
-27
lines changed

8 files changed

+173
-27
lines changed

boards/adafruit_clue_nrf52840.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,32 @@
2525
"mcu": "nrf52840_xxaa",
2626
"variant": "clue_nrf52840"
2727
},
28-
"bootloaders": {
29-
"adafruit": "0xFF000"
30-
},
28+
"bootloaders": [
29+
{
30+
"name": "adafruit_s140_v6",
31+
"bootloader_file": "nrf52840_s140_v6_adabl.hex",
32+
"linker_script": "nrf52840_s140_v6_adabl.ld",
33+
"max_size": 827392,
34+
"max_ram_size": 237568
35+
},
36+
{
37+
"name": "adafruit_s140_v7",
38+
"bootloader_file": "nrf52840_s140_v7_adabl.hex",
39+
"linker_script": "nrf52840_s140_v7_adabl.ld",
40+
"max_size": 823296,
41+
"max_ram_size": 237568
42+
},
43+
{
44+
"name": "adafruit_serial",
45+
"bootloader_file": "nrf52840_serial_adabl.hex",
46+
"linker_script": "nrf52840_serial_adabl.ld",
47+
"max_size": 978944,
48+
"max_ram_size": 262136
49+
}
50+
],
51+
52+
"default_bootloader": "adafruit_s140_v6",
53+
3154
"connectivity": [
3255
"bluetooth"
3356
],

boards/adafruit_cplaynrf52840.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,32 @@
2525
"mcu": "nrf52840_xxaa",
2626
"variant": "circuitplayground_nrf52840"
2727
},
28-
"bootloaders": {
29-
"adafruit": "0xFF000"
30-
},
28+
"bootloaders": [
29+
{
30+
"name": "adafruit_s140_v6",
31+
"bootloader_file": "nrf52840_s140_v6_adabl.hex",
32+
"linker_script": "nrf52840_s140_v6_adabl.ld",
33+
"max_size": 827392,
34+
"max_ram_size": 237568
35+
},
36+
{
37+
"name": "adafruit_s140_v7",
38+
"bootloader_file": "nrf52840_s140_v7_adabl.hex",
39+
"linker_script": "nrf52840_s140_v7_adabl.ld",
40+
"max_size": 823296,
41+
"max_ram_size": 237568
42+
},
43+
{
44+
"name": "adafruit_serial",
45+
"bootloader_file": "nrf52840_serial_adabl.hex",
46+
"linker_script": "nrf52840_serial_adabl.ld",
47+
"max_size": 978944,
48+
"max_ram_size": 262136
49+
}
50+
],
51+
52+
"default_bootloader": "adafruit_s140_v6",
53+
3154
"connectivity": [
3255
"bluetooth"
3356
],

boards/adafruit_feather_nrf52840.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,32 @@
2929
"mcu": "nrf52840_xxaa",
3030
"variant": "feather_nrf52840_express"
3131
},
32-
"bootloaders": {
33-
"adafruit": "0xFF000"
34-
},
32+
"bootloaders": [
33+
{
34+
"name": "adafruit_s140_v6",
35+
"bootloader_file": "nrf52840_s140_v6_adabl.hex",
36+
"linker_script": "nrf52840_s140_v6_adabl.ld",
37+
"max_size": 827392,
38+
"max_ram_size": 237568
39+
},
40+
{
41+
"name": "adafruit_s140_v7",
42+
"bootloader_file": "nrf52840_s140_v7_adabl.hex",
43+
"linker_script": "nrf52840_s140_v7_adabl.ld",
44+
"max_size": 823296,
45+
"max_ram_size": 237568
46+
},
47+
{
48+
"name": "adafruit_serial",
49+
"bootloader_file": "nrf52840_serial_adabl.hex",
50+
"linker_script": "nrf52840_serial_adabl.ld",
51+
"max_size": 978944,
52+
"max_ram_size": 262136
53+
}
54+
],
55+
56+
"default_bootloader": "adafruit_s140_v6",
57+
3558
"connectivity": [
3659
"bluetooth"
3760
],

boards/adafruit_feather_nrf52840_sense.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,32 @@
2929
"mcu": "nrf52840_xxaa",
3030
"variant": "feather_nrf52840_sense"
3131
},
32-
"bootloaders": {
33-
"adafruit": "0xFF000"
34-
},
32+
"bootloaders": [
33+
{
34+
"name": "adafruit_s140_v6",
35+
"bootloader_file": "nrf52840_s140_v6_adabl.hex",
36+
"linker_script": "nrf52840_s140_v6_adabl.ld",
37+
"max_size": 827392,
38+
"max_ram_size": 237568
39+
},
40+
{
41+
"name": "adafruit_s140_v7",
42+
"bootloader_file": "nrf52840_s140_v7_adabl.hex",
43+
"linker_script": "nrf52840_s140_v7_adabl.ld",
44+
"max_size": 823296,
45+
"max_ram_size": 237568
46+
},
47+
{
48+
"name": "adafruit_serial",
49+
"bootloader_file": "nrf52840_serial_adabl.hex",
50+
"linker_script": "nrf52840_serial_adabl.ld",
51+
"max_size": 978944,
52+
"max_ram_size": 262136
53+
}
54+
],
55+
56+
"default_bootloader": "adafruit_s140_v6",
57+
3558
"connectivity": [
3659
"bluetooth"
3760
],

boards/adafruit_itsybitsy_nrf52840.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,32 @@
2929
"mcu": "nrf52840_xxaa",
3030
"variant": "itsybitsy_nrf52840_express"
3131
},
32-
"bootloaders": {
33-
"adafruit": "0xFF000"
34-
},
32+
"bootloaders": [
33+
{
34+
"name": "adafruit_s140_v6",
35+
"bootloader_file": "nrf52840_s140_v6_adabl.hex",
36+
"linker_script": "nrf52840_s140_v6_adabl.ld",
37+
"max_size": 827392,
38+
"max_ram_size": 237568
39+
},
40+
{
41+
"name": "adafruit_s140_v7",
42+
"bootloader_file": "nrf52840_s140_v7_adabl.hex",
43+
"linker_script": "nrf52840_s140_v7_adabl.ld",
44+
"max_size": 823296,
45+
"max_ram_size": 237568
46+
},
47+
{
48+
"name": "adafruit_serial",
49+
"bootloader_file": "nrf52840_serial_adabl.hex",
50+
"linker_script": "nrf52840_serial_adabl.ld",
51+
"max_size": 978944,
52+
"max_ram_size": 262136
53+
}
54+
],
55+
56+
"default_bootloader": "adafruit_s140_v6",
57+
3558
"connectivity": [
3659
"bluetooth"
3760
],

boards/generic_nrf52840.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@
1010
"mcu": "nrf52840_xxaa",
1111
"variant": "Generic"
1212
},
13+
"bootloaders": [
14+
{
15+
"name": "adafruit_s140_v6",
16+
"bootloader_file": "nrf52840_s140_v6_adabl.hex",
17+
"linker_script": "nrf52840_s140_v6_adabl.ld",
18+
"max_size": 827392,
19+
"max_ram_size": 237568
20+
},
21+
{
22+
"name": "adafruit_s140_v7",
23+
"bootloader_file": "nrf52840_s140_v7_adabl.hex",
24+
"linker_script": "nrf52840_s140_v7_adabl.ld",
25+
"max_size": 823296,
26+
"max_ram_size": 237568
27+
},
28+
{
29+
"name": "adafruit_serial",
30+
"bootloader_file": "nrf52840_serial_adabl.hex",
31+
"linker_script": "nrf52840_serial_adabl.ld",
32+
"max_size": 978944,
33+
"max_ram_size": 262136
34+
}
35+
],
36+
37+
"default_bootloader": "none",
38+
1339
"connectivity": [
1440
"bluetooth"
1541
],

builder/frameworks/arduino/nrf5.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,28 +162,33 @@
162162
if not board.get("build.ldscript", ""):
163163
env.Replace(LDSCRIPT_PATH=board.get("build.arduino.ldscript", ""))
164164

165-
bootloader_opts = board.get("bootloaders", "")
165+
bootloader_opts = board.get("bootloaders", [])
166166
bootloader_sel = env.GetProjectOption("board_bootloader", "")
167167
ldscript = board.get("build.arduino.ldscript", "")
168168

169169
if bootloader_opts:
170+
# Use board JSON default if no project option is set
170171
if not bootloader_sel:
171-
sys.stderr.write("Error. Board type requires board_bootloader to be specified\n")
172-
env.Exit(1)
172+
bootloader_sel = board.get("default_bootloader", "none")
173+
174+
selected_bl = None
175+
for bl in bootloader_opts:
176+
if bl.get("name") == bootloader_sel:
177+
selected_bl = bl
178+
break
173179

174-
if bootloader_sel not in bootloader_opts and bootloader_sel != "none":
180+
if not selected_bl and bootloader_sel != "none":
175181
sys.stderr.write(
176182
"Error. Invalid board_bootloader selection. Options are: %s or none\n" %
177-
" ".join(k for k in bootloader_opts.keys()))
183+
" ".join(bl.get("name", "") for bl in bootloader_opts))
178184
env.Exit(1)
179185

180-
if bootloader_sel == "adafruit":
181-
env.Replace(BOOTLOADERHEX=join(FRAMEWORK_DIR, "variants", board.get("build.variant", ""), "ada_bootloader.hex"))
182-
# Update the linker file for bootloader use and set a flag for the build.
186+
if selected_bl:
187+
env.Replace(BOOTLOADERHEX=join(FRAMEWORK_DIR, "variants", board.get("build.variant", ""), selected_bl.get("bootloader_file", "")))
183188
env.Append(CPPDEFINES=["USE_ADA_BL"])
184-
env.Replace(LDSCRIPT_PATH=ldscript[:-3] + "_adabl" + ldscript[-3:])
185-
board.update("upload.maximum_size", board.get("upload.maximum_size") - 53248)
186-
board.update("upload.maximum_ram_size", board.get("upload.maximum_ram_size") - 8)
189+
env.Replace(LDSCRIPT_PATH=selected_bl.get("linker_script", ldscript))
190+
board.update("upload.maximum_size", selected_bl.get("max_size", board.get("upload.maximum_size")))
191+
board.update("upload.maximum_ram_size", selected_bl.get("max_ram_size", board.get("upload.maximum_ram_size")))
187192

188193
cpp_defines = env.Flatten(env.get("CPPDEFINES", []))
189194

platform.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"framework-n-able-arduino": {
3232
"type": "framework",
3333
"optional": false,
34-
"version": "https://github.com/h2zero/n-able-Arduino.git@0.3.0"
34+
"version": "https://github.com/h2zero/n-able-Arduino.git#update-linker/bootloaders"
3535
},
3636
"toolchain-gccarmnoneeabi": {
3737
"type": "toolchain",

0 commit comments

Comments
 (0)