Skip to content

Commit 7a0de41

Browse files
committed
Added LittleFS choice
1 parent 168d02b commit 7a0de41

File tree

2 files changed

+62
-37
lines changed

2 files changed

+62
-37
lines changed

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
# Arduino ESP32 filesystem uploader
22

3-
Arduino plugin which packs sketch data folder into SPIFFS filesystem image,
3+
Arduino plugin which packs sketch data folder into SPIFFS or LittleFS filesystem image,
44
and uploads the image to ESP32 flash memory.
5+
</br> You can use either LITTLEFS or SPIFFS but not both simultaneously on given Arduino project.
56

67
## Installation
78

89
- Make sure you use one of the supported versions of Arduino IDE and have ESP32 core installed.
910
- Download the tool archive from [releases page](https://github.com/me-no-dev/arduino-esp32fs-plugin/releases/latest).
1011
- In your Arduino sketchbook directory, create tools directory if it doesn't exist yet.
1112
- Unpack the tool into tools directory (the path will look like ```<home_dir>/Arduino/tools/ESP32FS/tool/esp32fs.jar```).
13+
- If not already installed, for LITTLEFS you need an additional [mklittlefs tool](https://github.com/earlephilhower/mklittlefs) Download the [release](https://github.com/earlephilhower/mklittlefs/releases) and copy it to
14+
packages\esp32\tools\mkspiffs\<mklittlefs rev. x.x.x>\ or on checkout (dev) environment to: packages\esp32\hardware\esp32\<release>\tools\mklittlefs\
1215
- Restart Arduino IDE.
1316

17+
1418
On the OS X create the tools directory in ~/Documents/Arduino/ and unpack the files there
1519

1620
## Usage
@@ -20,8 +24,9 @@ On the OS X create the tools directory in ~/Documents/Arduino/ and unpack the fi
2024
- Create a directory named `data` and any files you want in the file system there.
2125
- Make sure you have selected a board, port, and closed Serial Monitor.
2226
- Select *Tools > ESP32 Sketch Data Upload* menu item. This should start uploading the files into ESP32 flash file system.
27+
- When prompted, select SPIFFS or LITTLEFS image you want to make from your data folder.
2328

24-
When done, IDE status bar will display SPIFFS Image Uploaded message. Might take a few minutes for large file system sizes.
29+
When done, IDE status bar will display SPIFFS or LITTLEFS Image Uploaded message. Might take a few minutes for large file system sizes.
2530

2631
## Credits and license
2732

src/ESP32FS.java

+55-35
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public void init(Editor editor) {
6565
public String getMenuTitle() {
6666
return "ESP32 Sketch Data Upload";
6767
}
68+
69+
private String typefs = "SPIFFS";
6870

6971
private int listenOnProcess(String[] arguments){
7072
try {
@@ -99,12 +101,12 @@ private void sysExec(final String[] arguments){
99101
public void run() {
100102
try {
101103
if(listenOnProcess(arguments) != 0){
102-
editor.statusError("SPIFFS Upload failed!");
104+
editor.statusError(typefs + " Upload failed!");
103105
} else {
104-
editor.statusNotice("SPIFFS Image Uploaded");
106+
editor.statusNotice(typefs + " Image Uploaded");
105107
}
106108
} catch (Exception e){
107-
editor.statusError("SPIFFS Upload failed!");
109+
editor.statusError(typefs + " Upload failed!");
108110
}
109111
}
110112
};
@@ -168,7 +170,7 @@ private void createAndUpload(){
168170

169171
if(!PreferencesData.get("target_platform").contentEquals("esp32")){
170172
System.err.println();
171-
editor.statusError("SPIFFS Not Supported on "+PreferencesData.get("target_platform"));
173+
editor.statusError(typefs + " Not Supported on "+PreferencesData.get("target_platform"));
172174
return;
173175
}
174176

@@ -189,9 +191,11 @@ private void createAndUpload(){
189191

190192
String mkspiffsCmd;
191193
if(PreferencesData.get("runtime.os").contentEquals("windows"))
192-
mkspiffsCmd = "mkspiffs.exe";
194+
if (typefs == "LITTLEFS") mkspiffsCmd = "mklittlefs.exe";
195+
else mkspiffsCmd = "mkspiffs.exe";
193196
else
194-
mkspiffsCmd = "mkspiffs";
197+
if (typefs == "LITTLEFS") mkspiffsCmd = "mklittlefs";
198+
else mkspiffsCmd = "mkspiffs";
195199

196200
String espotaCmd = "espota.py";
197201
if(PreferencesData.get("runtime.os").contentEquals("windows"))
@@ -222,7 +226,7 @@ private void createAndUpload(){
222226
File partitionsFile = new File(platform.getFolder() + "/tools/partitions", partitions + ".csv");
223227
if (!partitionsFile.exists() || !partitionsFile.isFile()) {
224228
System.err.println();
225-
editor.statusError("SPIFFS Error: partitions file " + partitions + ".csv not found!");
229+
editor.statusError(typefs + " Error: partitions file " + partitions + ".csv not found!");
226230
return;
227231
}
228232

@@ -245,7 +249,7 @@ private void createAndUpload(){
245249
}
246250
if(spiSize == 0){
247251
System.err.println();
248-
editor.statusError("SPIFFS Error: partition size could not be found!");
252+
editor.statusError(typefs + " Error: partition size could not be found!");
249253
return;
250254
}
251255
} catch(Exception e){
@@ -255,12 +259,12 @@ private void createAndUpload(){
255259

256260
File tool = new File(platform.getFolder() + "/tools", mkspiffsCmd);
257261
if (!tool.exists() || !tool.isFile()) {
258-
tool = new File(platform.getFolder() + "/tools/mkspiffs", mkspiffsCmd);
262+
tool = new File(platform.getFolder() + "/tools/mk" + typefs.toLowerCase(), mkspiffsCmd);
259263
if (!tool.exists()) {
260-
tool = new File(PreferencesData.get("runtime.tools.mkspiffs.path"), mkspiffsCmd);
264+
tool = new File(PreferencesData.get("runtime.tools.mk" + typefs.toLowerCase() + ".path"), mkspiffsCmd);
261265
if (!tool.exists()) {
262266
System.err.println();
263-
editor.statusError("SPIFFS Error: mkspiffs not found!");
267+
editor.statusError(typefs + " Error: mk" + typefs.toLowerCase() + "not found!");
264268
return;
265269
}
266270
}
@@ -269,7 +273,7 @@ private void createAndUpload(){
269273
//make sure the serial port or IP is defined
270274
if (serialPort == null || serialPort.isEmpty()) {
271275
System.err.println();
272-
editor.statusError("SPIFFS Error: serial port not defined!");
276+
editor.statusError(typefs + " Error: serial port not defined!");
273277
return;
274278
}
275279

@@ -279,7 +283,7 @@ private void createAndUpload(){
279283
espota = new File(platform.getFolder()+"/tools", espotaCmd);
280284
if(!espota.exists() || !espota.isFile()){
281285
System.err.println();
282-
editor.statusError("SPIFFS Error: espota not found!");
286+
editor.statusError(typefs + " Error: espota not found!");
283287
return;
284288
}
285289
} else {
@@ -291,7 +295,7 @@ private void createAndUpload(){
291295
esptool = new File(PreferencesData.get("runtime.tools.esptool_py.path"), esptoolCmd);
292296
if (!esptool.exists()) {
293297
System.err.println();
294-
editor.statusError("SPIFFS Error: esptool not found!");
298+
editor.statusError(typefs + " Error: esptool not found!");
295299
return;
296300
}
297301
}
@@ -316,43 +320,43 @@ private void createAndUpload(){
316320
String dataPath = dataFolder.getAbsolutePath();
317321
String toolPath = tool.getAbsolutePath();
318322
String sketchName = editor.getSketch().getName();
319-
String imagePath = getBuildFolderPath(editor.getSketch()) + "/" + sketchName + ".spiffs.bin";
323+
String imagePath = getBuildFolderPath(editor.getSketch()) + "/" + sketchName + "." + typefs.toLowerCase() + ".bin";
320324
String uploadSpeed = BaseNoGui.getBoardPreferences().get("upload.speed");
321325

322326
Object[] options = { "Yes", "No" };
323-
String title = "SPIFFS Create";
324-
String message = "No files have been found in your data folder!\nAre you sure you want to create an empty SPIFFS image?";
327+
String title = typefs + " Create";
328+
String message = "No files have been found in your data folder!\nAre you sure you want to create an empty " + typefs + " image?";
325329

326330
if(fileCount == 0 && JOptionPane.showOptionDialog(editor, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]) != JOptionPane.YES_OPTION){
327331
System.err.println();
328-
editor.statusError("SPIFFS Warning: mkspiffs canceled!");
332+
editor.statusError(typefs + " Warning: mkspiffs canceled!");
329333
return;
330334
}
331335

332-
editor.statusNotice("SPIFFS Creating Image...");
333-
System.out.println("[SPIFFS] data : "+dataPath);
334-
System.out.println("[SPIFFS] start : "+spiStart);
335-
System.out.println("[SPIFFS] size : "+(spiSize/1024));
336-
System.out.println("[SPIFFS] page : "+spiPage);
337-
System.out.println("[SPIFFS] block : "+spiBlock);
336+
editor.statusNotice(typefs + " Creating Image...");
337+
System.out.println("[" + typefs + "] data : "+dataPath);
338+
System.out.println("[" + typefs + "] start : "+spiStart);
339+
System.out.println("[" + typefs + "] size : "+(spiSize/1024));
340+
System.out.println("[" + typefs + "] page : "+spiPage);
341+
System.out.println("[" + typefs + "] block : "+spiBlock);
338342

339343
try {
340344
if(listenOnProcess(new String[]{toolPath, "-c", dataPath, "-p", spiPage+"", "-b", spiBlock+"", "-s", spiSize+"", imagePath}) != 0){
341345
System.err.println();
342-
editor.statusError("SPIFFS Create Failed!");
346+
editor.statusError(typefs + " Create Failed!");
343347
return;
344348
}
345349
} catch (Exception e){
346350
editor.statusError(e);
347-
editor.statusError("SPIFFS Create Failed!");
351+
editor.statusError(typefs + " Create Failed!");
348352
return;
349353
}
350354

351-
editor.statusNotice("SPIFFS Uploading Image...");
352-
System.out.println("[SPIFFS] upload : "+imagePath);
355+
editor.statusNotice(typefs + " Uploading Image...");
356+
System.out.println("[" + typefs + "] upload : "+imagePath);
353357

354358
if(isNetwork){
355-
System.out.println("[SPIFFS] IP : "+serialPort);
359+
System.out.println("[" + typefs + "] IP : "+serialPort);
356360
System.out.println();
357361
if(espota.getAbsolutePath().endsWith(".py"))
358362
sysExec(new String[]{pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-p", "3232", "-s", "-f", imagePath});
@@ -361,11 +365,11 @@ private void createAndUpload(){
361365
} else {
362366
String flashMode = BaseNoGui.getBoardPreferences().get("build.flash_mode");
363367
String flashFreq = BaseNoGui.getBoardPreferences().get("build.flash_freq");
364-
System.out.println("[SPIFFS] address: "+spiStart);
365-
System.out.println("[SPIFFS] port : "+serialPort);
366-
System.out.println("[SPIFFS] speed : "+uploadSpeed);
367-
System.out.println("[SPIFFS] mode : "+flashMode);
368-
System.out.println("[SPIFFS] freq : "+flashFreq);
368+
System.out.println("[" + typefs + "] address: "+spiStart);
369+
System.out.println("[" + typefs + "] port : "+serialPort);
370+
System.out.println("[" + typefs + "] speed : "+uploadSpeed);
371+
System.out.println("[" + typefs + "] mode : "+flashMode);
372+
System.out.println("[" + typefs + "] freq : "+flashFreq);
369373
System.out.println();
370374
if(esptool.getAbsolutePath().endsWith(".py"))
371375
sysExec(new String[]{pythonCmd, esptool.getAbsolutePath(), "--chip", "esp32", "--baud", uploadSpeed, "--port", serialPort, "--before", "default_reset", "--after", "hard_reset", "write_flash", "-z", "--flash_mode", flashMode, "--flash_freq", flashFreq, "--flash_size", "detect", ""+spiStart, imagePath});
@@ -375,6 +379,22 @@ private void createAndUpload(){
375379
}
376380

377381
public void run() {
378-
createAndUpload();
382+
String sketchName = editor.getSketch().getName();
383+
Object[] options = { "LITTLEFS", "SPIFFS", };
384+
int result = JOptionPane.showOptionDialog(editor,
385+
"What FS you want for " + sketchName +
386+
" data folder?",
387+
"Select",
388+
JOptionPane.YES_NO_OPTION,
389+
JOptionPane.QUESTION_MESSAGE,
390+
null,
391+
options,
392+
options[1]);
393+
if (result == JOptionPane.YES_OPTION) {
394+
typefs = "LITTLEFS";
395+
} else {
396+
typefs = "SPIFFS";
397+
}
398+
createAndUpload();
379399
}
380400
}

0 commit comments

Comments
 (0)