Skip to content

Commit a70cc5d

Browse files
authored
Merge branch 'master' into readme-update
2 parents 6208e6b + 25890cc commit a70cc5d

File tree

2 files changed

+40
-20
lines changed

2 files changed

+40
-20
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Tested with the following Arduino IDE versions: 1.6.5-r2,
1111
## Installation
1212
- Make sure you use one of the supported versions of Arduino IDE and have ESP8266 core installed.
1313
- Download the tool archive from [releases page](https://github.com/esp8266/arduino-esp8266fs-plugin/releases/latest).
14-
- In your Arduino sketchbook directory, create tools directory if it doesn't exist yet.
15-
- Unpack the tool into tools directory (the path will look like `<home_dir>/Arduino/tools/ESP8266FS/tool/esp8266fs.jar)`.
14+
- In your Arduino sketchbook directory, create `tools` directory if it doesn't exist yet. You can find the location of your sketchbook directory in the Arduino IDE at **File > Preferences > Sketchbook location**.
15+
- Unpack the tool into `tools` directory (the path will look like `<sketchbook directory>/tools/ESP8266FS/tool/esp8266fs.jar)`.
1616
- Restart Arduino IDE.
1717

1818
On OS X and Linux based OSs create the tools directory in ~/Documents/Arduino/ and unpack the files there

Diff for: src/ESP8266FS.java

+38-18
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ private void createAndUpload(){
208208
File espota = new File(platform.getFolder()+"/tools");
209209
File esptool = new File(platform.getFolder()+"/tools");
210210
String serialPort = PreferencesData.get("serial.port");
211+
String pythonCmd = PreferencesData.get("runtime.os").contentEquals("windows") ? "python3.exe" : "python3";
212+
String uploadCmd = "";
211213

212214
//make sure the serial port or IP is defined
213215
if (serialPort == null || serialPort.isEmpty()) {
@@ -216,6 +218,22 @@ private void createAndUpload(){
216218
return;
217219
}
218220

221+
// Find upload.py, don't fail if not present for backwards compat
222+
File uploadPyFile = new File(platform.getFolder()+"/tools", "upload.py");
223+
if (uploadPyFile.exists() && uploadPyFile.isFile()) {
224+
uploadCmd = uploadPyFile.getAbsolutePath();
225+
}
226+
// Find python.exe if present, don't fail if not found for backwards compat
227+
String[] paths = { platform.getFolder()+"/tools", platform.getFolder()+"/tools/python3", PreferencesData.get("runtime.tools.python3.path") };
228+
for (String s: paths) {
229+
File toolPyFile = new File(s, pythonCmd);
230+
if (toolPyFile.exists() && toolPyFile.isFile() && toolPyFile.canExecute()) {
231+
pythonCmd = toolPyFile.getAbsolutePath();
232+
break;
233+
}
234+
}
235+
// pythonCmd now points to either an installed exe with full path or just plain "python3(.exe)"
236+
219237
//find espota if IP else find esptool
220238
if(serialPort.split("\\.").length == 4){
221239
isNetwork = true;
@@ -233,7 +251,7 @@ private void createAndUpload(){
233251
esptool = new File(platform.getFolder()+"/tools/esptool", esptoolCmd);
234252
if(!esptool.exists()){
235253
esptool = new File(PreferencesData.get("runtime.tools.esptool.path"), esptoolCmd);
236-
if (!esptool.exists()) {
254+
if (!esptool.exists() && uploadCmd.isEmpty()) {
237255
System.err.println();
238256
editor.statusError("SPIFFS Error: esptool not found!");
239257
return;
@@ -278,10 +296,10 @@ private void createAndUpload(){
278296
}
279297

280298
editor.statusNotice("SPIFFS Creating Image...");
281-
System.out.println("[SPIFFS] data : "+dataPath);
282-
System.out.println("[SPIFFS] size : "+((spiEnd - spiStart)/1024));
283-
System.out.println("[SPIFFS] page : "+spiPage);
284-
System.out.println("[SPIFFS] block : "+spiBlock);
299+
System.out.println("[SPIFFS] data : "+dataPath);
300+
System.out.println("[SPIFFS] size : "+((spiEnd - spiStart)/1024));
301+
System.out.println("[SPIFFS] page : "+spiPage);
302+
System.out.println("[SPIFFS] block : "+spiBlock);
285303

286304
try {
287305
if(listenOnProcess(new String[]{toolPath, "-c", dataPath, "-p", spiPage+"", "-b", spiBlock+"", "-s", (spiEnd - spiStart)+"", imagePath}) != 0){
@@ -296,25 +314,27 @@ private void createAndUpload(){
296314
}
297315

298316
editor.statusNotice("SPIFFS Uploading Image...");
299-
System.out.println("[SPIFFS] upload : "+imagePath);
317+
System.out.println("[SPIFFS] upload : "+imagePath);
300318

301319
if(isNetwork){
302-
String pythonCmd;
303-
if(PreferencesData.get("runtime.os").contentEquals("windows"))
304-
pythonCmd = "python.exe";
305-
else
306-
pythonCmd = "python";
307-
308-
System.out.println("[SPIFFS] IP : "+serialPort);
320+
System.out.println("[SPIFFS] IP : "+serialPort);
309321
System.out.println();
310322
sysExec(new String[]{pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-s", "-f", imagePath});
311323
} else {
312-
System.out.println("[SPIFFS] address: "+uploadAddress);
313-
System.out.println("[SPIFFS] reset : "+resetMethod);
314-
System.out.println("[SPIFFS] port : "+serialPort);
315-
System.out.println("[SPIFFS] speed : "+uploadSpeed);
324+
System.out.println("[SPIFFS] address : "+uploadAddress);
325+
System.out.println("[SPIFFS] reset : "+resetMethod);
326+
System.out.println("[SPIFFS] port : "+serialPort);
327+
System.out.println("[SPIFFS] speed : "+uploadSpeed);
328+
if (!uploadCmd.isEmpty()) {
329+
System.out.println("[SPIFFS] python : "+pythonCmd);
330+
System.out.println("[SPIFFS] uploader : "+uploadCmd);
331+
}
316332
System.out.println();
317-
sysExec(new String[]{esptool.getAbsolutePath(), "-cd", resetMethod, "-cb", uploadSpeed, "-cp", serialPort, "-ca", uploadAddress, "-cf", imagePath});
333+
if (!uploadCmd.isEmpty()) {
334+
sysExec(new String[]{pythonCmd, uploadCmd, "--chip", "esp8266", "--port", serialPort, "--baud", uploadSpeed, "write_flash", uploadAddress, imagePath});
335+
} else {
336+
sysExec(new String[]{esptool.getAbsolutePath(), "-cd", resetMethod, "-cb", uploadSpeed, "-cp", serialPort, "-ca", uploadAddress, "-cf", imagePath});
337+
}
318338
}
319339
}
320340

0 commit comments

Comments
 (0)