@@ -479,21 +479,30 @@ def main():
479
479
# Inject boards.local.txt if requested
480
480
if COPY_BOARDS_LOCAL_TXT and boards_local_txt :
481
481
try :
482
+ local_app_data_dir = os .environ .get ('HOME' , '' )
483
+ data_dir = None
484
+ if os .path .exists (os .path .join (local_app_data_dir , 'Arduino' )):
485
+ data_dir = os .path .join (local_app_data_dir , 'Arduino' )
486
+ elif os .path .exists (os .path .join (local_app_data_dir , '.arduino15' )):
487
+ data_dir = os .path .join (local_app_data_dir , '.arduino15' )
488
+ elif os .path .exists (os .path .join (local_app_data_dir , '.arduino' )):
489
+ data_dir = os .path .join (local_app_data_dir , '.arduino' )
490
+
482
491
# Get arduino-cli data directory
483
492
import json
484
- config_output = subprocess .check_output (["arduino-cli" , "config" , "dump" , "--format" , "json" ]).decode ()
493
+ if data_dir :
494
+ config_output = subprocess .check_output (["arduino-cli" , "config" , "dump" , "--format" , "json" , "--config-dir" , data_dir ]).decode ()
495
+ else :
496
+ config_output = subprocess .check_output (["arduino-cli" , "config" , "dump" , "--format" , "json" ]).decode ()
485
497
config = json .loads (config_output )
486
498
ColorPrint .print_info (f"Using arduino-cli config: { config_output .strip ()} " )
487
499
488
500
# Extract data directory, with fallback to default
489
- data_dir = config .get ("directories" , {}).get ("data" , "" )
501
+ data_dir = config .get ("directories" , {}).get ("data" , data_dir )
490
502
if not data_dir :
491
- ColorPrint .print_warn ("No data directory found in arduino-cli config, using fallback locations." )
492
- # Fallback to common default locations
493
- if os .name == 'nt' : # Windows
494
- data_dir = os .path .join (os .environ .get ('LOCALAPPDATA' , '' ), 'Arduino15' )
495
- else : # Linux/macOS
496
- data_dir = os .path .join (os .environ .get ('HOME' , '' ), '.arduino15' )
503
+ ColorPrint .print_warn ("No valid data directory found, cannot copy boards.local.txt" )
504
+ continue
505
+
497
506
ColorPrint .print_info (f"Using data directory: { data_dir } " )
498
507
499
508
# Parse platform vendor and architecture from core_fqbn (e.g., "adafruit:samd")
@@ -507,8 +516,10 @@ def main():
507
516
508
517
ColorPrint .print_info (f"Using vendor: { vendor } , architecture: { architecture } " )
509
518
510
- # Construct base platform path
511
- platform_base = os .path .join (data_dir , "packages" , vendor , "hardware" , architecture )
519
+ # Construct base platform path, fall back to architecture if vendor rebadged BSP.
520
+ platform_base = os .path .join (data_dir , "packages" , vendor , "hardware" , architecture ) if \
521
+ os .path .exists (os .path .join (data_dir , "packages" , vendor , "hardware" , architecture )) else \
522
+ os .path .join (data_dir , "packages" , architecture , "hardware" , architecture )
512
523
513
524
# Find the latest version directory
514
525
if os .path .exists (platform_base ):
0 commit comments