@@ -458,22 +458,17 @@ def find_board():
458
458
if args .board :
459
459
arg_board_pattern = re .compile (args .board , re .IGNORECASE )
460
460
461
- fqbn_list_tmp = []
462
461
try :
463
462
output = subprocess .check_output (
464
- [arduino_cli , "board" , "listall" , "--format" , "json" ],
463
+ [arduino_cli , "board" , "search" , arduino_platform , "--format" , "json" ],
465
464
stderr = subprocess .STDOUT ,
466
465
).decode ("utf-8" )
467
466
except subprocess .CalledProcessError as e :
468
467
print (f"'{ ' ' .join (e .cmd )} ' failed with code: { e .returncode } !" )
469
468
print (e .stdout .decode ("utf-8" ))
470
469
quit (e .returncode )
471
470
else :
472
- boards_list = json .loads (output )
473
- if boards_list is not None :
474
- for board in boards_list ["boards" ]:
475
- if arduino_platform in board ["fqbn" ]:
476
- fqbn_list_tmp .append (board ["fqbn" ])
471
+ fqbn_list_tmp = [board ["fqbn" ] for board in json .loads (output )]
477
472
if not len (fqbn_list_tmp ):
478
473
print (f"No boards found for { arduino_platform } " )
479
474
quit (1 )
@@ -490,6 +485,7 @@ def find_board():
490
485
stm32_url ,
491
486
"--format" ,
492
487
"json" ,
488
+ "-b" ,
493
489
fqbn ,
494
490
],
495
491
stderr = subprocess .STDOUT ,
@@ -500,22 +496,18 @@ def find_board():
500
496
quit (e .returncode )
501
497
else :
502
498
board_detail = json .loads (output )
503
- if board_detail is not None :
504
- if "config_options" not in board_detail :
505
- print ("No config_options found for " + fqbn )
506
- quit (1 )
507
- for option in board_detail ["config_options" ]:
508
- if option ["option" ] == "pnum" :
509
- for value in option ["values" ]:
510
- if args .board :
511
- if arg_board_pattern .search (value ["value" ]) is None :
512
- continue
513
- board_found [
514
- value ["value" ]
515
- ] = f"{ fqbn } :pnum={ value ['value' ]} "
516
- break
517
- else :
518
- print (f"No detail found for:'{ fqbn } '!" )
499
+ for val in next (
500
+ (
501
+ item
502
+ for item in board_detail .get ("config_options" , [])
503
+ if item ["option" ] == "pnum"
504
+ ),
505
+ {},
506
+ ).get ("values" , []):
507
+ if args .board :
508
+ if arg_board_pattern .search (val ["value" ]) is None :
509
+ continue
510
+ board_found [val ["value" ]] = f"{ fqbn } :pnum={ val ['value' ]} "
519
511
if board_found :
520
512
board_fqbn = collections .OrderedDict (sorted (board_found .items ()))
521
513
else :
0 commit comments