From 6208e6ba1f2faf6ab66f97041fa98e23e96caa34 Mon Sep 17 00:00:00 2001 From: Rick Hewes Date: Wed, 8 Aug 2018 17:04:44 +0100 Subject: [PATCH 1/5] Update README Add comment for Linux based OSs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d20d3b..9486bd4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Tested with the following Arduino IDE versions: 1.6.5-r2, - Unpack the tool into tools directory (the path will look like `/Arduino/tools/ESP8266FS/tool/esp8266fs.jar)`. - Restart Arduino IDE. -On the OS X create the tools directory in ~/Documents/Arduino/ and unpack the files there +On OS X and Linux based OSs create the tools directory in ~/Documents/Arduino/ and unpack the files there ## Usage - Open a sketch (or create a new one and save it). From c2315454c5e581390b6ce088e518bd81d97b1640 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Fri, 22 Feb 2019 12:19:32 -0800 Subject: [PATCH 2/5] Add upload.py and internal python in tools When present, use a tools-installed python executable for any python calls. When tools/upload.py is present, use it in place of esptool-ck.exe. When neither of these are present, as in releases 2.5.0 and prior, use the prior behavior, unchanged. --- src/ESP8266FS.java | 69 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/src/ESP8266FS.java b/src/ESP8266FS.java index fd210f2..7a3811a 100644 --- a/src/ESP8266FS.java +++ b/src/ESP8266FS.java @@ -208,6 +208,12 @@ private void createAndUpload(){ File espota = new File(platform.getFolder()+"/tools"); File esptool = new File(platform.getFolder()+"/tools"); String serialPort = PreferencesData.get("serial.port"); + String pythonCmd; + if(PreferencesData.get("runtime.os").contentEquals("windows")) + pythonCmd = "python.exe"; + else + pythonCmd = "python"; + String uploadCmd = ""; //make sure the serial port or IP is defined if (serialPort == null || serialPort.isEmpty()) { @@ -216,6 +222,31 @@ private void createAndUpload(){ return; } + // Find upload.py, don't fail if not present for backwards compat + File uploadPyFile = new File(platform.getFolder()+"/tools", "upload.py"); + if (uploadPyFile.exists() && uploadPyFile.isFile()) { + uploadCmd = uploadPyFile.getAbsolutePath(); + } + // Find python.exe if present, don't fail if not found for backwards compat + String toolPyCmd = pythonCmd; + if ((toolPyCmd != null ) && !toolPyCmd.isEmpty()) { + File toolPyFile = new File(platform.getFolder()+"/tools", toolPyCmd); + if (toolPyFile.exists() && toolPyFile.isFile() && toolPyFile.canExecute()) { + pythonCmd = toolPyFile.getAbsolutePath(); + } else { + toolPyFile = new File(platform.getFolder()+"/tools/python", toolPyCmd); + if (toolPyFile.exists() && toolPyFile.isFile() && toolPyFile.canExecute()) { + pythonCmd = toolPyFile.getAbsolutePath(); + } else { + toolPyFile = new File(PreferencesData.get("runtime.tools.python.path"), toolPyCmd); + if (toolPyFile.exists() && toolPyFile.isFile() && toolPyFile.canExecute()) { + pythonCmd = toolPyFile.getAbsolutePath(); + } + } + } + } + // pythonCmd now points to either an installed exe with full path or just plain "python(.exe)" + //find espota if IP else find esptool if(serialPort.split("\\.").length == 4){ isNetwork = true; @@ -233,7 +264,7 @@ private void createAndUpload(){ esptool = new File(platform.getFolder()+"/tools/esptool", esptoolCmd); if(!esptool.exists()){ esptool = new File(PreferencesData.get("runtime.tools.esptool.path"), esptoolCmd); - if (!esptool.exists()) { + if (!esptool.exists() && uploadCmd.isEmpty()) { System.err.println(); editor.statusError("SPIFFS Error: esptool not found!"); return; @@ -278,10 +309,10 @@ private void createAndUpload(){ } editor.statusNotice("SPIFFS Creating Image..."); - System.out.println("[SPIFFS] data : "+dataPath); - System.out.println("[SPIFFS] size : "+((spiEnd - spiStart)/1024)); - System.out.println("[SPIFFS] page : "+spiPage); - System.out.println("[SPIFFS] block : "+spiBlock); + System.out.println("[SPIFFS] data : "+dataPath); + System.out.println("[SPIFFS] size : "+((spiEnd - spiStart)/1024)); + System.out.println("[SPIFFS] page : "+spiPage); + System.out.println("[SPIFFS] block : "+spiBlock); try { if(listenOnProcess(new String[]{toolPath, "-c", dataPath, "-p", spiPage+"", "-b", spiBlock+"", "-s", (spiEnd - spiStart)+"", imagePath}) != 0){ @@ -296,25 +327,27 @@ private void createAndUpload(){ } editor.statusNotice("SPIFFS Uploading Image..."); - System.out.println("[SPIFFS] upload : "+imagePath); + System.out.println("[SPIFFS] upload : "+imagePath); if(isNetwork){ - String pythonCmd; - if(PreferencesData.get("runtime.os").contentEquals("windows")) - pythonCmd = "python.exe"; - else - pythonCmd = "python"; - - System.out.println("[SPIFFS] IP : "+serialPort); + System.out.println("[SPIFFS] IP : "+serialPort); System.out.println(); sysExec(new String[]{pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-s", "-f", imagePath}); } else { - System.out.println("[SPIFFS] address: "+uploadAddress); - System.out.println("[SPIFFS] reset : "+resetMethod); - System.out.println("[SPIFFS] port : "+serialPort); - System.out.println("[SPIFFS] speed : "+uploadSpeed); + System.out.println("[SPIFFS] address : "+uploadAddress); + System.out.println("[SPIFFS] reset : "+resetMethod); + System.out.println("[SPIFFS] port : "+serialPort); + System.out.println("[SPIFFS] speed : "+uploadSpeed); + if (uploadCmd != null && !uploadCmd.isEmpty()) { + System.out.println("[SPIFFS] python : "+pythonCmd); + System.out.println("[SPIFFS] uploader : "+uploadCmd); + } System.out.println(); - sysExec(new String[]{esptool.getAbsolutePath(), "-cd", resetMethod, "-cb", uploadSpeed, "-cp", serialPort, "-ca", uploadAddress, "-cf", imagePath}); + if (uploadCmd != null && !uploadCmd.isEmpty()) { + sysExec(new String[]{pythonCmd, uploadCmd, "--chip", "esp8266", "--port", serialPort, "--baud", uploadSpeed, "write_flash", uploadAddress, imagePath, "--end"}); + } else { + sysExec(new String[]{esptool.getAbsolutePath(), "-cd", resetMethod, "-cb", uploadSpeed, "-cp", serialPort, "-ca", uploadAddress, "-cf", imagePath}); + } } } From 33969c9c0388ca31b2e49ec4b3fde71a5629e0b5 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sat, 23 Feb 2019 09:35:51 -0800 Subject: [PATCH 3/5] Use cleaner path finding code, misc. cleanup Instead of a bunch of nested if-elses, use a list of strings to try iterating over to fins python(.exe). Replace 1-line if-else with ternary operator --- src/ESP8266FS.java | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/ESP8266FS.java b/src/ESP8266FS.java index 7a3811a..95a51e7 100644 --- a/src/ESP8266FS.java +++ b/src/ESP8266FS.java @@ -208,11 +208,7 @@ private void createAndUpload(){ File espota = new File(platform.getFolder()+"/tools"); File esptool = new File(platform.getFolder()+"/tools"); String serialPort = PreferencesData.get("serial.port"); - String pythonCmd; - if(PreferencesData.get("runtime.os").contentEquals("windows")) - pythonCmd = "python.exe"; - else - pythonCmd = "python"; + String pythonCmd = PreferencesData.get("runtime.os").contentEquals("windows") ? "python.exe" : "python"; String uploadCmd = ""; //make sure the serial port or IP is defined @@ -228,21 +224,12 @@ private void createAndUpload(){ uploadCmd = uploadPyFile.getAbsolutePath(); } // Find python.exe if present, don't fail if not found for backwards compat - String toolPyCmd = pythonCmd; - if ((toolPyCmd != null ) && !toolPyCmd.isEmpty()) { - File toolPyFile = new File(platform.getFolder()+"/tools", toolPyCmd); + String[] paths = { platform.getFolder()+"/tools", platform.getFolder()+"/tools/python", PreferencesData.get("runtime.tools.python.path") }; + for (String s: paths) { + File toolPyFile = new File(s, pythonCmd); if (toolPyFile.exists() && toolPyFile.isFile() && toolPyFile.canExecute()) { pythonCmd = toolPyFile.getAbsolutePath(); - } else { - toolPyFile = new File(platform.getFolder()+"/tools/python", toolPyCmd); - if (toolPyFile.exists() && toolPyFile.isFile() && toolPyFile.canExecute()) { - pythonCmd = toolPyFile.getAbsolutePath(); - } else { - toolPyFile = new File(PreferencesData.get("runtime.tools.python.path"), toolPyCmd); - if (toolPyFile.exists() && toolPyFile.isFile() && toolPyFile.canExecute()) { - pythonCmd = toolPyFile.getAbsolutePath(); - } - } + break; } } // pythonCmd now points to either an installed exe with full path or just plain "python(.exe)" @@ -338,12 +325,12 @@ private void createAndUpload(){ System.out.println("[SPIFFS] reset : "+resetMethod); System.out.println("[SPIFFS] port : "+serialPort); System.out.println("[SPIFFS] speed : "+uploadSpeed); - if (uploadCmd != null && !uploadCmd.isEmpty()) { + if (!uploadCmd.isEmpty()) { System.out.println("[SPIFFS] python : "+pythonCmd); System.out.println("[SPIFFS] uploader : "+uploadCmd); } System.out.println(); - if (uploadCmd != null && !uploadCmd.isEmpty()) { + if (!uploadCmd.isEmpty()) { sysExec(new String[]{pythonCmd, uploadCmd, "--chip", "esp8266", "--port", serialPort, "--baud", uploadSpeed, "write_flash", uploadAddress, imagePath, "--end"}); } else { sysExec(new String[]{esptool.getAbsolutePath(), "-cd", resetMethod, "-cb", uploadSpeed, "-cp", serialPort, "-ca", uploadAddress, "-cf", imagePath}); From 64082855fe558d9a546b88ba0282e09775345584 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Mon, 18 Nov 2019 21:16:12 -0800 Subject: [PATCH 4/5] Fix uploader for python3 compat and core 2.6.x The core moved to python3 because python (2) is EOL on January 1, 2020. Move the search paths and platform variables to use python3 instead. Remove the no longer needed --end parameter to upload.py --- src/ESP8266FS.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ESP8266FS.java b/src/ESP8266FS.java index 95a51e7..81b55ef 100644 --- a/src/ESP8266FS.java +++ b/src/ESP8266FS.java @@ -208,7 +208,7 @@ private void createAndUpload(){ File espota = new File(platform.getFolder()+"/tools"); File esptool = new File(platform.getFolder()+"/tools"); String serialPort = PreferencesData.get("serial.port"); - String pythonCmd = PreferencesData.get("runtime.os").contentEquals("windows") ? "python.exe" : "python"; + String pythonCmd = PreferencesData.get("runtime.os").contentEquals("windows") ? "python3.exe" : "python3"; String uploadCmd = ""; //make sure the serial port or IP is defined @@ -224,7 +224,7 @@ private void createAndUpload(){ uploadCmd = uploadPyFile.getAbsolutePath(); } // Find python.exe if present, don't fail if not found for backwards compat - String[] paths = { platform.getFolder()+"/tools", platform.getFolder()+"/tools/python", PreferencesData.get("runtime.tools.python.path") }; + String[] paths = { platform.getFolder()+"/tools", platform.getFolder()+"/tools/python3", PreferencesData.get("runtime.tools.python3.path") }; for (String s: paths) { File toolPyFile = new File(s, pythonCmd); if (toolPyFile.exists() && toolPyFile.isFile() && toolPyFile.canExecute()) { @@ -232,7 +232,7 @@ private void createAndUpload(){ break; } } - // pythonCmd now points to either an installed exe with full path or just plain "python(.exe)" + // pythonCmd now points to either an installed exe with full path or just plain "python3(.exe)" //find espota if IP else find esptool if(serialPort.split("\\.").length == 4){ @@ -331,7 +331,7 @@ private void createAndUpload(){ } System.out.println(); if (!uploadCmd.isEmpty()) { - sysExec(new String[]{pythonCmd, uploadCmd, "--chip", "esp8266", "--port", serialPort, "--baud", uploadSpeed, "write_flash", uploadAddress, imagePath, "--end"}); + sysExec(new String[]{pythonCmd, uploadCmd, "--chip", "esp8266", "--port", serialPort, "--baud", uploadSpeed, "write_flash", uploadAddress, imagePath}); } else { sysExec(new String[]{esptool.getAbsolutePath(), "-cd", resetMethod, "-cb", uploadSpeed, "-cp", serialPort, "-ca", uploadAddress, "-cf", imagePath}); } From 56a6c515545ff5301be5e679d014ab7062600d81 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Mon, 25 Nov 2019 11:37:48 +0200 Subject: [PATCH 5/5] change target version --- make.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make.sh b/make.sh index 9a7702e..6d76779 100755 --- a/make.sh +++ b/make.sh @@ -19,7 +19,7 @@ echo "lib_path: $lib_path" set -e mkdir -p bin -javac -target 1.8 -cp "$pde_path:$core_path:$lib_path" \ +javac -target 11 -cp "$pde_path:$core_path:$lib_path" \ -d bin src/ESP8266FS.java pushd bin