Skip to content

Commit b0e84b2

Browse files
Create a different json for the new boards
1 parent 06ab23b commit b0e84b2

File tree

3 files changed

+66
-48
lines changed

3 files changed

+66
-48
lines changed

generator/boards.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,5 @@
7474
"arduino:mbed_nano:nanorp2040connect": {
7575
"moduleName": "NINA",
7676
"versions": ["1.4.5", "1.4.6", "1.4.7", "1.4.8", "1.5.0"]
77-
},
78-
"arduino:renesas_uno:unor4wifi": {
79-
"moduleName": "ESP32-S3",
80-
"versions": ["0.1.0", "0.2.0"]
8177
}
8278
}

generator/generator.py

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -222,36 +222,7 @@ def create_upload_data(fqbn, installed_cores): # noqa: C901
222222
return upload_data
223223

224224

225-
def generate_boards_json(input_data, arduino_cli_path):
226-
boards = {
227-
"arduino:samd:mkr1000": {"fqbn": "arduino:samd:mkr1000", "firmware": []},
228-
"arduino:samd:mkrwifi1010": {
229-
"fqbn": "arduino:samd:mkrwifi1010",
230-
"firmware": [],
231-
},
232-
"arduino:samd:nano_33_iot": {
233-
"fqbn": "arduino:samd:nano_33_iot",
234-
"firmware": [],
235-
},
236-
"arduino:samd:mkrvidor4000": {
237-
"fqbn": "arduino:samd:mkrvidor4000",
238-
"firmware": [],
239-
},
240-
"arduino:megaavr:uno2018": {"fqbn": "arduino:megaavr:uno2018", "firmware": []},
241-
"arduino:mbed_nano:nanorp2040connect": {
242-
"fqbn": "arduino:mbed_nano:nanorp2040connect",
243-
"firmware": [],
244-
},
245-
"arduino:renesas_uno:unor4wifi": {
246-
"fqbn": "arduino:renesas_uno:unor4wifi",
247-
"firmware": [],
248-
# "uploader_plugin" and "additional_tools" need to be hard coded because
249-
# there is no way to retrieve them dinamically
250-
"uploader_plugin": "arduino:uno-r4-wifi-fwuploader@1.0.0",
251-
"additional_tools": ["arduino:espflash@2.0.0", "arduino:bossac@1.9.1-arduino5"],
252-
},
253-
}
254-
225+
def generate_boards_json(input_data, arduino_cli_path, new_boards):
255226
# List of old boards that need precompiled sketch data and uploader information obtained through platform.txt.
256227
old_boards = [
257228
"arduino:samd:mkr1000",
@@ -262,17 +233,49 @@ def generate_boards_json(input_data, arduino_cli_path):
262233
"arduino:mbed_nano:nanorp2040connect",
263234
]
264235

265-
# Gets the installed cores
266-
res = arduino_cli(cli_path=arduino_cli_path, args=["core", "list", "--format", "json"])
267-
installed_cores = {c["id"]: c for c in json.loads(res)}
268-
269-
# Verify all necessary cores are installed
270-
# TODO: Should we check that the latest version is installed too?
271-
for fqbn in old_boards:
272-
core_id = ":".join(fqbn.split(":")[:2])
273-
if core_id not in installed_cores:
274-
print(f"Board {fqbn} is not installed, install its core {core_id}")
275-
sys.exit(1)
236+
if not new_boards:
237+
boards = {
238+
"arduino:samd:mkr1000": {"fqbn": "arduino:samd:mkr1000", "firmware": []},
239+
"arduino:samd:mkrwifi1010": {
240+
"fqbn": "arduino:samd:mkrwifi1010",
241+
"firmware": [],
242+
},
243+
"arduino:samd:nano_33_iot": {
244+
"fqbn": "arduino:samd:nano_33_iot",
245+
"firmware": [],
246+
},
247+
"arduino:samd:mkrvidor4000": {
248+
"fqbn": "arduino:samd:mkrvidor4000",
249+
"firmware": [],
250+
},
251+
"arduino:megaavr:uno2018": {"fqbn": "arduino:megaavr:uno2018", "firmware": []},
252+
"arduino:mbed_nano:nanorp2040connect": {
253+
"fqbn": "arduino:mbed_nano:nanorp2040connect",
254+
"firmware": [],
255+
},
256+
}
257+
# Gets the installed cores
258+
res = arduino_cli(cli_path=arduino_cli_path, args=["core", "list", "--format", "json"])
259+
installed_cores = {c["id"]: c for c in json.loads(res)}
260+
261+
# Verify all necessary cores are installed
262+
# TODO: Should we check that the latest version is installed too?
263+
for fqbn in old_boards:
264+
core_id = ":".join(fqbn.split(":")[:2])
265+
if core_id not in installed_cores:
266+
print(f"Board {fqbn} is not installed, install its core {core_id}")
267+
sys.exit(1)
268+
else:
269+
boards = {
270+
"arduino:renesas_uno:unor4wifi": {
271+
"fqbn": "arduino:renesas_uno:unor4wifi",
272+
"firmware": [],
273+
# "uploader_plugin" and "additional_tools" need to be hard coded because
274+
# there is no way to retrieve them dinamically
275+
"uploader_plugin": "arduino:uno-r4-wifi-fwuploader@1.0.0",
276+
"additional_tools": ["arduino:espflash@2.0.0", "arduino:bossac@1.9.1-arduino5"],
277+
},
278+
}
276279

277280
for fqbn, data in input_data.items():
278281
simple_fqbn = fqbn.replace(":", ".")
@@ -316,18 +319,31 @@ def generate_boards_json(input_data, arduino_cli_path):
316319
help="Path to arduino-cli executable",
317320
required=True,
318321
)
322+
parser.add_argument(
323+
"--new",
324+
action=argparse.BooleanOptionalAction,
325+
default=True,
326+
help="Generate the index for old boards",
327+
)
319328
args = parser.parse_args(sys.argv[1:])
320329

330+
if args.new:
331+
input_file = "new_boards.json"
332+
output_file = "plugin_firmware_index.json"
333+
else:
334+
input_file = "boards.json"
335+
output_file = "module_firmware_index.json"
336+
321337
# raw_boards.json has been generated using --get_available_for FirmwareUploader (version 0.1.8) flag.
322338
# It has been edited a bit to better handle parsing.
323-
with open("boards.json", "r") as f:
339+
with open(input_file, "r") as f:
324340
boards = json.load(f)
325341

326-
boards_json = generate_boards_json(boards, args.arduino_cli)
342+
boards_json = generate_boards_json(boards, args.arduino_cli, args.new)
327343

328344
Path("boards").mkdir()
329345

330-
with open("boards/module_firmware_index.json", "w") as f:
346+
with open("boards/" + output_file, "w") as f:
331347
json.dump(boards_json, f, indent=2)
332348

333349
# board_index.json must be formatted like so:

generator/new_boards.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"arduino:renesas_uno:unor4wifi": {
3+
"moduleName": "ESP32-S3",
4+
"versions": ["0.1.0", "0.2.0"]
5+
}
6+
}

0 commit comments

Comments
 (0)