From 046dc7edb9469d5ae907652f2db1294f44c547b1 Mon Sep 17 00:00:00 2001
From: Hristo Kapanakov
Date: Sun, 9 Aug 2020 20:42:27 +0300
Subject: [PATCH] Fix ESP32 tools path with latest Arduino IDE
---
esp8266fs.js | 50 ++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 44 insertions(+), 6 deletions(-)
diff --git a/esp8266fs.js b/esp8266fs.js
index 62943ab..bd3f180 100644
--- a/esp8266fs.js
+++ b/esp8266fs.js
@@ -532,7 +532,22 @@ function getEspPackagePath(arduinoUserPath, preferencesPath, target) {
}
case "esp32": {
- const esp32Path = path.join(arduinoUserPath, "hardware", target.package, target.architecture);
+ var esp32Path = path.join(arduinoUserPath, "hardware", target.package, target.architecture);
+
+ // try same as esp8266
+ if (!dirExists(esp32Path)) {
+ const dir = path.join(preferencesPath, "packages", target.package, "hardware", target.architecture);
+
+ if (!dirExists(dir))
+ throw `ESP32 has not been installed correctly - see https://github.com/espressif/arduino-esp32.`;
+
+ const folders = getFolders(dir);
+
+ if (folders.length != 1)
+ throw `There should only be one ESP32 Package installed with the Arduino Board Manager.`;
+
+ esp32Path = path.join(dir, folders[0]);
+ }
if (!dirExists(esp32Path))
throw `ESP32 has not been installed correctly - see https://github.com/espressif/arduino-esp32.`;
@@ -625,9 +640,10 @@ function getSpiffsOptions(packagesPath, target, arduinoJson, preferences) {
//------------------------------------------------------------------------------
function getEspToolsPath(arduinoUserPath, preferencesPath, target) {
- const dir = target.architecture == "esp8266"
- ? path.resolve(path.join(preferencesPath, "packages", target.architecture, "tools"))
- : path.resolve(path.join(arduinoUserPath, "hardware", target.package, target.architecture, "tools"));
+ var dir = path.resolve(path.join(preferencesPath, "packages", target.architecture, "tools"));
+
+ if (target.architecture == "esp32" && !dirExists(dir))
+ dir = path.resolve(path.join(arduinoUserPath, "hardware", target.package, target.architecture, "tools"));
if (!dirExists(dir))
throw `Can't find tools path.`;
@@ -706,7 +722,17 @@ function getMkSpiffs(target, espToolsPath) {
}
case "esp32": {
- const mkspiffs = path.join(espToolsPath, "mkspiffs", program("mkspiffs"));
+ var mkspiffs = path.join(espToolsPath, "mkspiffs", program("mkspiffs"));
+
+ // try same as esp8266
+ if (!fileExists(mkspiffs)) {
+ const folders = getFolders(path.join(espToolsPath, "mkspiffs"));
+
+ if (folders.length != 1)
+ throw `"${target.architecture}" not installed correctly through Arduino Board Manager`;
+
+ mkspiffs = path.join(espToolsPath, "mkspiffs", folders[0], program("mkspiffs"));
+ }
if (!fileExists(mkspiffs))
throw `"Can't locate "${mkspiffs}"`;
@@ -876,7 +902,19 @@ function getEspTool(target, espToolsPath) {
}
case "esp32": {
- const esptoolPy = path.join(espToolsPath, program("esptool.py"));
+ var esptoolPy = path.join(espToolsPath, program("esptool.py"));
+
+ // try same as esp8266
+ if (!fileExists(esptoolPy)) {
+ const folders = getFolders(path.join(espToolsPath, "esptool"));
+
+ if (folders.length != 1)
+ throw `"${target.architecture}" not installed correctly through Arduino Board Manager`;
+
+ const version = folders[0];
+
+ esptoolPy = path.join(espToolsPath, "esptool", version, program("esptool"));
+ }
if (!fileExists(esptoolPy))
throw `"Can't locate "${esptoolPy}"`;