Skip to content

Commit 83a0e1a

Browse files
committed
Calculating the missing Offset (begining of partition) of partition.csv file lines.
Minor changes in make.win batch file
1 parent 0e20b77 commit 83a0e1a

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Arduino ESP32 filesystem uploader
22

33
- Arduino plugin which packs sketch data folder into SPIFFS, LittleFS or FatFS filesystem image,
4-
and uploads the image to ESP32 flash memory.
5-
- Added a choice to "Erase all flash"
6-
- You can have only one of three filesystems on same Arduino project.
4+
and uploads the image to ESP32 flash memory.
5+
- Added custom "partition.csv" file processing if it is located in the sketch folder.
6+
- Added esp32 / esp32s2 chip detection based on Arduino IDE selection.
7+
- Added a choice to "Erase all flash".
8+
- You can have only one of three filesystems on same Arduino project as data partition.
79

810
## Notes for SPIFFS
911

src/ESP32FS.java

+38-11
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,42 @@ private void createAndUpload(){
248248
try {
249249
BufferedReader partitionsReader = new BufferedReader(new FileReader(partitionsFile));
250250
String partitionsLine = "";
251+
long spiPrevEnd = 0;
252+
boolean isDataLine = false;
251253
while ((partitionsLine = partitionsReader.readLine()) != null) {
252-
if( ((typefs != "FatFS") && partitionsLine.contains("spiffs")) || ((typefs == "FatFS") && partitionsLine.contains("ffat"))){
253-
partitionsLine = partitionsLine.substring(partitionsLine.indexOf(",")+1);
254-
partitionsLine = partitionsLine.substring(partitionsLine.indexOf(",")+1);
255-
partitionsLine = partitionsLine.substring(partitionsLine.indexOf(",")+1);
256-
while(partitionsLine.startsWith(" ")) partitionsLine = partitionsLine.substring(1);
257-
String pStart = partitionsLine.substring(0, partitionsLine.indexOf(","));
258-
partitionsLine = partitionsLine.substring(partitionsLine.indexOf(",")+1);
259-
while(partitionsLine.startsWith(" ")) partitionsLine = partitionsLine.substring(1);
260-
String pSize = partitionsLine.substring(0, partitionsLine.indexOf(","));
261-
spiStart = parseInt(pStart) + spiOffset;
262-
spiSize = parseInt(pSize) - spiOffset;
254+
if (!partitionsLine.substring(0, 1).equals("#")) {
255+
if( ((typefs != "FatFS") && partitionsLine.contains("spiffs")) || ((typefs == "FatFS") && partitionsLine.contains("ffat"))){
256+
isDataLine = true;
257+
}
258+
partitionsLine = partitionsLine.substring(partitionsLine.indexOf(",")+1);
259+
partitionsLine = partitionsLine.substring(partitionsLine.indexOf(",")+1);
260+
partitionsLine = partitionsLine.substring(partitionsLine.indexOf(",")+1);
261+
while(partitionsLine.startsWith(" ")) partitionsLine = partitionsLine.substring(1);
262+
String pStart = partitionsLine.substring(0, partitionsLine.indexOf(","));
263+
partitionsLine = partitionsLine.substring(partitionsLine.indexOf(",")+1);
264+
while(partitionsLine.startsWith(" ")) partitionsLine = partitionsLine.substring(1);
265+
String pSize = partitionsLine.substring(0, partitionsLine.indexOf(","));
266+
267+
//System.out.println("From CSV, Partition Start: " + pStart + ", Size: " + pSize);
268+
269+
if (isDataLine) {
270+
if (pStart == null || pStart.trim().isEmpty()) {
271+
spiStart = spiPrevEnd + spiOffset;
272+
} else {
273+
spiStart = parseInt(pStart) + spiOffset;
274+
}
275+
spiSize = parseInt(pSize) - spiOffset;
276+
break;
277+
} else {
278+
if (pSize != null && !pSize.trim().isEmpty()) {
279+
if (pStart == null || pStart.trim().isEmpty()) {
280+
spiPrevEnd += parseInt(pSize);
281+
} else {
282+
spiPrevEnd = parseInt(pStart) + parseInt(pSize);
283+
}
284+
}
285+
spiSize = 0;
286+
}
263287
}
264288
}
265289
if(spiSize == 0){
@@ -272,6 +296,9 @@ private void createAndUpload(){
272296
return;
273297
}
274298

299+
System.out.println("Start: 0x" + String.format("%x", spiStart));
300+
System.out.println("Size : 0x" + String.format("%x", spiSize));
301+
275302
File tool = new File(platform.getFolder() + "/tools", mkspiffsCmd);
276303
if (!tool.exists() || !tool.isFile()) {
277304
tool = new File(platform.getFolder() + "/tools/mk" + typefs.toLowerCase(), mkspiffsCmd);

src/make_win.bat

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
del bin\*.*
1+
del bin\*.jar
2+
rd /S /Q bin\com
23
"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
34
cd bin
45
"C:\Program Files (x86)\Java\jdk1.8.0_152\bin\jar.exe" cvfM esp32fs.jar *

0 commit comments

Comments
 (0)