@@ -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:[email protected] " ,
251
- "additional_tools" : [
"arduino:[email protected] " ,
"arduino:[email protected] " ],
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
+ boards = {
237
+ "arduino:renesas_uno:unor4wifi" : {
238
+ "fqbn" : "arduino:renesas_uno:unor4wifi" ,
239
+ "firmware" : [],
240
+ # "uploader_plugin" and "additional_tools" need to be hard coded because
241
+ # there is no way to retrieve them dinamically
242
+ "uploader_plugin" :
"arduino:[email protected] " ,
243
+ "additional_tools" : [
"arduino:[email protected] " ,
"arduino:[email protected] " ],
244
+ },
245
+ }
246
+
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
+ }
268
+ # Gets the installed cores
269
+ res = arduino_cli (cli_path = arduino_cli_path , args = ["core" , "list" , "--format" , "json" ])
270
+ installed_cores = {c ["id" ]: c for c in json .loads (res )}
271
+
272
+ # Verify all necessary cores are installed
273
+ # TODO: Should we check that the latest version is installed too?
274
+ for fqbn in old_boards :
275
+ core_id = ":" .join (fqbn .split (":" )[:2 ])
276
+ if core_id not in installed_cores :
277
+ print (f"Board { fqbn } is not installed, install its core { core_id } " )
278
+ sys .exit (1 )
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