Skip to content

Commit 71bc2c9

Browse files
committed
Fix ESP32 tools path with latest Arduino IDE
1 parent efa1f80 commit 71bc2c9

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

esp8266fs.js

+44-6
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,22 @@ function getEspPackagePath(arduinoUserPath, preferencesPath, target) {
532532
}
533533

534534
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+
}
536551

537552
if (!dirExists(esp32Path))
538553
throw `ESP32 has not been installed correctly - see https://github.com/espressif/arduino-esp32.`;
@@ -625,9 +640,10 @@ function getSpiffsOptions(packagesPath, target, arduinoJson, preferences) {
625640
//------------------------------------------------------------------------------
626641

627642
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"));
631647

632648
if (!dirExists(dir))
633649
throw `Can't find tools path.`;
@@ -706,7 +722,17 @@ function getMkSpiffs(target, espToolsPath) {
706722
}
707723

708724
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+
}
710736

711737
if (!fileExists(mkspiffs))
712738
throw `"Can't locate "${mkspiffs}"`;
@@ -876,7 +902,19 @@ function getEspTool(target, espToolsPath) {
876902
}
877903

878904
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+
}
880918

881919
if (!fileExists(esptoolPy))
882920
throw `"Can't locate "${esptoolPy}"`;

0 commit comments

Comments
 (0)