Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
168d02b
Change tool from esptool to esptool_py
me-no-dev Jan 15, 2019
7a0de41
Added LittleFS choice
lorol Jun 19, 2020
6a327a5
Added message to show found espota, esptool, mklittlefs and mkspiffs …
lorol Jun 29, 2020
90a1724
Updated README
lorol Jul 9, 2020
07d7a82
Added FatFS
lorol Jul 14, 2020
f490215
Fix README.md
lorol Jul 14, 2020
2c71408
Added batch for Windows quick build
lorol Jul 14, 2020
d4c0f00
Release 2.0.1
lorol Jul 14, 2020
97143d0
Updated README.md
lorol Jul 15, 2020
b51ef07
Updated README.md and added a snapshot
lorol Jul 17, 2020
fee9640
Change first choice (default) of drop-down to LittleFS
lorol Jul 31, 2020
9efcdb7
Added a choice to "Erase All Flash" at the end of FS type selections
lorol Oct 9, 2020
aaa5335
add support to esp32s2
steph-prv Oct 23, 2020
eeb21f3
Merge branch 'master' into fix_merge
stephb1377 Oct 23, 2020
4651830
Merge branch 'zouffin-fix_merge'
lorol Nov 10, 2020
92b4956
Added messages to console about chip type
lorol Nov 10, 2020
0e20b77
Use partitions.csv from sketch folder
lorol Nov 20, 2020
83a0e1a
Calculating the missing Offset (begining of partition) of partition.c…
lorol Nov 21, 2020
cd75923
Parse partition csv file line' Offset(Start address) and Size values
lorol Nov 22, 2020
810d85c
Improvements and tests before release
lorol Nov 22, 2020
22efec6
Release 2.0.5 with comment how to build a jar that is in esp32fs_no_c…
lorol Nov 24, 2020
a41ef5c
jar files added to .gitignore
lorol Nov 24, 2020
e4c702f
More universal way to get chip model
lorol Dec 15, 2020
b97f756
Bugfixes
lorol Dec 22, 2020
8543000
Better make_win.bat
Dec 23, 2020
b2268aa
Update Readme
lorol Dec 23, 2020
e995308
Update ESP32FS.java
lorol Dec 23, 2020
310e9d0
Update make_win.bat
lorol Dec 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bugfixes
Changed sysExec() to be based on: https://www.infoworld.com/article/2071275/when-runtime-exec---won-t.html
The original way hangs on long uploading.
  • Loading branch information
lorol committed Dec 22, 2020
commit b97f756142dfb7a2a4d24aa19939bfd90bd280e7
98 changes: 59 additions & 39 deletions src/ESP32FS.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@

package com.esp32.mkspiffs;

import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;
import java.io.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import javax.swing.JOptionPane;
Expand All @@ -51,6 +47,32 @@

import cc.arduino.files.DeleteFilesOnShutdown;

/**
* Taken from https://www.infoworld.com/article/2071275/when-runtime-exec---won-t.html?page=3
*/
class StreamGobbler extends Thread {
InputStream is;
String type;

StreamGobbler(InputStream is, String type) {
this.is = is;
this.type = type;
}

public void run() {
try {
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null)
System.out.println(type + ">" + line);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}


/**
* Example Tools menu entry.
*/
Expand All @@ -71,31 +93,26 @@ public String getMenuTitle() {

private int listenOnProcess(String[] arguments){
try {
final Process p = ProcessUtils.exec(arguments);
Thread thread = new Thread() {
public void run() {
try {
InputStreamReader reader = new InputStreamReader(p.getInputStream());
int c;
while ((c = reader.read()) != -1)
System.out.print((char) c);
reader.close();

reader = new InputStreamReader(p.getErrorStream());
while ((c = reader.read()) != -1)
System.err.print((char) c);
reader.close();
} catch (Exception e){}
}
};
thread.start();
int res = p.waitFor();
thread.join();
return res;
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(arguments);
// any error message?
StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "E");

// any output?
StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "O");

// kick them off
errorGobbler.start();
outputGobbler.start();

// any error???
int exitVal = proc.waitFor();

return exitVal;
} catch (Exception e){
return -1;
}
}
}

private void sysExec(final String[] arguments){
Thread thread = new Thread() {
Expand Down Expand Up @@ -328,9 +345,12 @@ private void createAndUpload(){
isNetwork = true;
espota = new File(platform.getFolder()+"/tools", espotaCmd);
if(!espota.exists() || !espota.isFile()){
System.err.println();
editor.statusError(typefs + " Error: espota not found!");
return;
espota = new File(platform.getFolder()+"/tools", "espota.py"); //fall-back to .py
if(!espota.exists() || !espota.isFile()){
System.err.println();
editor.statusError(typefs + " Error: espota not found!");
return;
}
}
System.out.println("espota : "+espota.getAbsolutePath());
System.out.println();
Expand All @@ -354,11 +374,10 @@ private void createAndUpload(){
}
}
}
System.out.println("esptool : "+esptool.getAbsolutePath());
System.out.println();
}
System.out.println("esptool : "+esptool.getAbsolutePath());
System.out.println();



//load a list of all files
int fileCount = 0;
File dataFolder = new File(editor.getSketch().getFolder(), "data");
Expand Down Expand Up @@ -426,9 +445,10 @@ private void createAndUpload(){

if(isNetwork){
System.out.println("[" + typefs + "] IP : "+serialPort);
System.out.println();
System.out.println("Running: " + espota.getAbsolutePath() + " -i " + serialPort + " -p 3232 -s -f " + imagePath);
System.out.println();
if(espota.getAbsolutePath().endsWith(".py"))
sysExec(new String[]{pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-p", "3232", "-s", "-f", imagePath});
sysExec(new String[]{pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-p", "3232", "-s", "-f", imagePath}); // other flags , "-d", "-r", "-t", "50"
else
sysExec(new String[]{espota.getAbsolutePath(), "-i", serialPort, "-p", "3232", "-s", "-f", imagePath});
} else {
Expand Down Expand Up @@ -507,9 +527,9 @@ private void eraseFlash(){
}
}
}
System.out.println("esptool : "+esptool.getAbsolutePath());
System.out.println();
}
System.out.println("esptool : "+esptool.getAbsolutePath());
System.out.println();

Object[] options = { "Yes", "No" };
String title = "Erase All Flash";
Expand Down
Empty file removed src/bin/placeholder
Empty file.
4 changes: 2 additions & 2 deletions src/make_win.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
del bin\*.jar
rd /S /Q bin\com
"C:\Program Files (x86)\Java\jdk1.8.0_152\bin\javac.exe" -target 1.8 -cp ".;arduino-core.jar;commons-codec-1.7.jar;pde.jar" -d bin ESP32FS.java
javac.exe -target 1.8 -cp ".;arduino-core.jar;commons-codec-1.7.jar;pde.jar" -d bin ESP32FS.java
cd bin
"C:\Program Files (x86)\Java\jdk1.8.0_152\bin\jar.exe" cvfM esp32fs.jar *
jar.exe cvfM esp32fs.jar *
pause