Skip to content

Commit 5fa54e6

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

File tree

3 files changed

+54
-35
lines changed

3 files changed

+54
-35
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: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -222,26 +222,18 @@ 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):
225+
def generate_boards_json(input_data, arduino_cli_path, new_boards):
226+
# List of old boards that need precompiled sketch data and uploader information obtained through platform.txt.
227+
old_boards = [
228+
"arduino:samd:mkr1000",
229+
"arduino:samd:mkrwifi1010",
230+
"arduino:samd:nano_33_iot",
231+
"arduino:samd:mkrvidor4000",
232+
"arduino:megaavr:uno2018",
233+
"arduino:mbed_nano:nanorp2040connect",
234+
]
235+
226236
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-
},
245237
"arduino:renesas_uno:unor4wifi": {
246238
"fqbn": "arduino:renesas_uno:unor4wifi",
247239
"firmware": [],
@@ -252,15 +244,27 @@ def generate_boards_json(input_data, arduino_cli_path):
252244
},
253245
}
254246

255-
# List of old boards that need precompiled sketch data and uploader information obtained through platform.txt.
256-
old_boards = [
257-
"arduino:samd:mkr1000",
258-
"arduino:samd:mkrwifi1010",
259-
"arduino:samd:nano_33_iot",
260-
"arduino:samd:mkrvidor4000",
261-
"arduino:megaavr:uno2018",
262-
"arduino:mbed_nano:nanorp2040connect",
263-
]
247+
if not new_boards:
248+
boards = {
249+
"arduino:samd:mkr1000": {"fqbn": "arduino:samd:mkr1000", "firmware": []},
250+
"arduino:samd:mkrwifi1010": {
251+
"fqbn": "arduino:samd:mkrwifi1010",
252+
"firmware": [],
253+
},
254+
"arduino:samd:nano_33_iot": {
255+
"fqbn": "arduino:samd:nano_33_iot",
256+
"firmware": [],
257+
},
258+
"arduino:samd:mkrvidor4000": {
259+
"fqbn": "arduino:samd:mkrvidor4000",
260+
"firmware": [],
261+
},
262+
"arduino:megaavr:uno2018": {"fqbn": "arduino:megaavr:uno2018", "firmware": []},
263+
"arduino:mbed_nano:nanorp2040connect": {
264+
"fqbn": "arduino:mbed_nano:nanorp2040connect",
265+
"firmware": [],
266+
},
267+
}
264268

265269
# Gets the installed cores
266270
res = arduino_cli(cli_path=arduino_cli_path, args=["core", "list", "--format", "json"])
@@ -316,18 +320,31 @@ def generate_boards_json(input_data, arduino_cli_path):
316320
help="Path to arduino-cli executable",
317321
required=True,
318322
)
323+
parser.add_argument(
324+
"--new",
325+
action=argparse.BooleanOptionalAction,
326+
default=True,
327+
help="Generate the index for old boards",
328+
)
319329
args = parser.parse_args(sys.argv[1:])
320330

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

326-
boards_json = generate_boards_json(boards, args.arduino_cli)
343+
boards_json = generate_boards_json(boards, args.arduino_cli, args.new)
327344

328345
Path("boards").mkdir()
329346

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

333350
# 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)