@@ -222,36 +222,7 @@ def create_upload_data(fqbn, installed_cores): # noqa: C901
222
222
return upload_data
223
223
224
224
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 ):
255
226
# List of old boards that need precompiled sketch data and uploader information obtained through platform.txt.
256
227
old_boards = [
257
228
"arduino:samd:mkr1000" ,
@@ -262,17 +233,49 @@ def generate_boards_json(input_data, arduino_cli_path):
262
233
"arduino:mbed_nano:nanorp2040connect" ,
263
234
]
264
235
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
+ }
276
279
277
280
for fqbn , data in input_data .items ():
278
281
simple_fqbn = fqbn .replace (":" , "." )
@@ -316,18 +319,31 @@ def generate_boards_json(input_data, arduino_cli_path):
316
319
help = "Path to arduino-cli executable" ,
317
320
required = True ,
318
321
)
322
+ parser .add_argument (
323
+ "--new" ,
324
+ action = argparse .BooleanOptionalAction ,
325
+ default = True ,
326
+ help = "Generate the index for old boards" ,
327
+ )
319
328
args = parser .parse_args (sys .argv [1 :])
320
329
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
+
321
337
# raw_boards.json has been generated using --get_available_for FirmwareUploader (version 0.1.8) flag.
322
338
# 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 :
324
340
boards = json .load (f )
325
341
326
- boards_json = generate_boards_json (boards , args .arduino_cli )
342
+ boards_json = generate_boards_json (boards , args .arduino_cli , args . new )
327
343
328
344
Path ("boards" ).mkdir ()
329
345
330
- with open ("boards/module_firmware_index.json" , "w" ) as f :
346
+ with open ("boards/" + output_file , "w" ) as f :
331
347
json .dump (boards_json , f , indent = 2 )
332
348
333
349
# board_index.json must be formatted like so:
0 commit comments