@@ -532,7 +532,22 @@ function getEspPackagePath(arduinoUserPath, preferencesPath, target) {
532
532
}
533
533
534
534
case "esp32" : {
535
- const esp32Path = path . join ( arduinoUserPath , "hardware" , target . package , target . architecture ) ;
535
+ var esp32Path = path . join ( arduinoUserPath , "hardware" , target . package , target . architecture ) ;
536
+
537
+ // try same as esp8266
538
+ if ( ! dirExists ( esp32Path ) ) {
539
+ const dir = path . join ( preferencesPath , "packages" , target . package , "hardware" , target . architecture ) ;
540
+
541
+ if ( ! dirExists ( dir ) )
542
+ throw `ESP32 has not been installed correctly - see https://github.com/espressif/arduino-esp32.` ;
543
+
544
+ const folders = getFolders ( dir ) ;
545
+
546
+ if ( folders . length != 1 )
547
+ throw `There should only be one ESP32 Package installed with the Arduino Board Manager.` ;
548
+
549
+ esp32Path = path . join ( dir , folders [ 0 ] ) ;
550
+ }
536
551
537
552
if ( ! dirExists ( esp32Path ) )
538
553
throw `ESP32 has not been installed correctly - see https://github.com/espressif/arduino-esp32.` ;
@@ -625,9 +640,10 @@ function getSpiffsOptions(packagesPath, target, arduinoJson, preferences) {
625
640
//------------------------------------------------------------------------------
626
641
627
642
function getEspToolsPath ( arduinoUserPath , preferencesPath , target ) {
628
- const dir = target . architecture == "esp8266"
629
- ? path . resolve ( path . join ( preferencesPath , "packages" , target . architecture , "tools" ) )
630
- : path . resolve ( path . join ( arduinoUserPath , "hardware" , target . package , target . architecture , "tools" ) ) ;
643
+ var dir = path . resolve ( path . join ( preferencesPath , "packages" , target . architecture , "tools" ) ) ;
644
+
645
+ if ( target . architecture == "esp32" && ! dirExists ( dir ) )
646
+ dir = path . resolve ( path . join ( arduinoUserPath , "hardware" , target . package , target . architecture , "tools" ) ) ;
631
647
632
648
if ( ! dirExists ( dir ) )
633
649
throw `Can't find tools path.` ;
@@ -706,7 +722,17 @@ function getMkSpiffs(target, espToolsPath) {
706
722
}
707
723
708
724
case "esp32" : {
709
- const mkspiffs = path . join ( espToolsPath , "mkspiffs" , program ( "mkspiffs" ) ) ;
725
+ var mkspiffs = path . join ( espToolsPath , "mkspiffs" , program ( "mkspiffs" ) ) ;
726
+
727
+ // try same as esp8266
728
+ if ( ! fileExists ( mkspiffs ) ) {
729
+ const folders = getFolders ( path . join ( espToolsPath , "mkspiffs" ) ) ;
730
+
731
+ if ( folders . length != 1 )
732
+ throw `"${ target . architecture } " not installed correctly through Arduino Board Manager` ;
733
+
734
+ mkspiffs = path . join ( espToolsPath , "mkspiffs" , folders [ 0 ] , program ( "mkspiffs" ) ) ;
735
+ }
710
736
711
737
if ( ! fileExists ( mkspiffs ) )
712
738
throw `"Can't locate "${ mkspiffs } "` ;
@@ -876,7 +902,19 @@ function getEspTool(target, espToolsPath) {
876
902
}
877
903
878
904
case "esp32" : {
879
- const esptoolPy = path . join ( espToolsPath , program ( "esptool.py" ) ) ;
905
+ var esptoolPy = path . join ( espToolsPath , program ( "esptool.py" ) ) ;
906
+
907
+ // try same as esp8266
908
+ if ( ! fileExists ( esptoolPy ) ) {
909
+ const folders = getFolders ( path . join ( espToolsPath , "esptool" ) ) ;
910
+
911
+ if ( folders . length != 1 )
912
+ throw `"${ target . architecture } " not installed correctly through Arduino Board Manager` ;
913
+
914
+ const version = folders [ 0 ] ;
915
+
916
+ esptoolPy = path . join ( espToolsPath , "esptool" , version , program ( "esptool" ) ) ;
917
+ }
880
918
881
919
if ( ! fileExists ( esptoolPy ) )
882
920
throw `"Can't locate "${ esptoolPy } "` ;
0 commit comments