@@ -248,18 +248,42 @@ private void createAndUpload(){
248
248
try {
249
249
BufferedReader partitionsReader = new BufferedReader (new FileReader (partitionsFile ));
250
250
String partitionsLine = "" ;
251
+ long spiPrevEnd = 0 ;
252
+ boolean isDataLine = false ;
251
253
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
+ }
263
287
}
264
288
}
265
289
if (spiSize == 0 ){
@@ -272,6 +296,9 @@ private void createAndUpload(){
272
296
return ;
273
297
}
274
298
299
+ System .out .println ("Start: 0x" + String .format ("%x" , spiStart ));
300
+ System .out .println ("Size : 0x" + String .format ("%x" , spiSize ));
301
+
275
302
File tool = new File (platform .getFolder () + "/tools" , mkspiffsCmd );
276
303
if (!tool .exists () || !tool .isFile ()) {
277
304
tool = new File (platform .getFolder () + "/tools/mk" + typefs .toLowerCase (), mkspiffsCmd );
0 commit comments