@@ -209,6 +209,8 @@ private void createAndUpload(){
209
209
File espota = new File (platform .getFolder ()+"/tools" );
210
210
File esptool = new File (platform .getFolder ()+"/tools" );
211
211
String serialPort = PreferencesData .get ("serial.port" );
212
+ String pythonCmd = PreferencesData .get ("runtime.os" ).contentEquals ("windows" ) ? "python.exe" : "python" ;
213
+ String uploadCmd = "" ;
212
214
213
215
//make sure the serial port or IP is defined
214
216
if (serialPort == null || serialPort .isEmpty ()) {
@@ -217,6 +219,22 @@ private void createAndUpload(){
217
219
return ;
218
220
}
219
221
222
+ // Find upload.py, don't fail if not present for backwards compat
223
+ File uploadPyFile = new File (platform .getFolder ()+"/tools" , "upload.py" );
224
+ if (uploadPyFile .exists () && uploadPyFile .isFile ()) {
225
+ uploadCmd = uploadPyFile .getAbsolutePath ();
226
+ }
227
+ // Find python.exe if present, don't fail if not found for backwards compat
228
+ String [] paths = { platform .getFolder ()+"/tools" , platform .getFolder ()+"/tools/python" , PreferencesData .get ("runtime.tools.python.path" ) };
229
+ for (String s : paths ) {
230
+ File toolPyFile = new File (s , pythonCmd );
231
+ if (toolPyFile .exists () && toolPyFile .isFile () && toolPyFile .canExecute ()) {
232
+ pythonCmd = toolPyFile .getAbsolutePath ();
233
+ break ;
234
+ }
235
+ }
236
+ // pythonCmd now points to either an installed exe with full path or just plain "python(.exe)"
237
+
220
238
//find espota if IP else find esptool
221
239
if (serialPort .split ("\\ ." ).length == 4 ){
222
240
isNetwork = true ;
@@ -234,7 +252,7 @@ private void createAndUpload(){
234
252
esptool = new File (platform .getFolder ()+"/tools/esptool" , esptoolCmd );
235
253
if (!esptool .exists ()){
236
254
esptool = new File (PreferencesData .get ("runtime.tools.esptool.path" ), esptoolCmd );
237
- if (!esptool .exists ()) {
255
+ if (!esptool .exists () && uploadCmd . isEmpty () ) {
238
256
System .err .println ();
239
257
editor .statusError ("LittleFS Error: esptool not found!" );
240
258
return ;
@@ -279,10 +297,10 @@ private void createAndUpload(){
279
297
}
280
298
281
299
editor .statusNotice ("LittleFS Creating Image..." );
282
- System .out .println ("[LittleFS] data : " +dataPath );
283
- System .out .println ("[LittleFS] size : " +((spiEnd - spiStart )/1024 ));
284
- System .out .println ("[LittleFS] page : " +spiPage );
285
- System .out .println ("[LittleFS] block : " +spiBlock );
300
+ System .out .println ("[LittleFS] data : " +dataPath );
301
+ System .out .println ("[LittleFS] size : " +((spiEnd - spiStart )/1024 ));
302
+ System .out .println ("[LittleFS] page : " +spiPage );
303
+ System .out .println ("[LittleFS] block : " +spiBlock );
286
304
287
305
try {
288
306
if (listenOnProcess (new String []{toolPath , "-c" , dataPath , "-p" , spiPage +"" , "-b" , spiBlock +"" , "-s" , (spiEnd - spiStart )+"" , imagePath }) != 0 ) {
@@ -297,25 +315,28 @@ private void createAndUpload(){
297
315
}
298
316
299
317
editor .statusNotice ("LittleFS Uploading Image..." );
300
- System .out .println ("[LittleFS] upload : " +imagePath );
318
+ System .out .println ("[LittleFS] upload : " +imagePath );
301
319
302
320
if (isNetwork ){
303
- String pythonCmd ;
304
- if (PreferencesData .get ("runtime.os" ).contentEquals ("windows" ))
305
- pythonCmd = "python.exe" ;
306
- else
307
- pythonCmd = "python" ;
308
-
309
- System .out .println ("[LittleFS] IP : " +serialPort );
321
+ System .out .println ("[LittleFS] IP : " +serialPort );
310
322
System .out .println ();
311
323
sysExec (new String []{pythonCmd , espota .getAbsolutePath (), "-i" , serialPort , "-s" , "-f" , imagePath });
312
324
} else {
313
- System .out .println ("[LittleFS] address: " +uploadAddress );
314
- System .out .println ("[LittleFS] reset : " +resetMethod );
315
- System .out .println ("[LittleFS] port : " +serialPort );
316
- System .out .println ("[LittleFS] speed : " +uploadSpeed );
325
+ System .out .println ("[LittleFS] address : " +uploadAddress );
326
+ System .out .println ("[LittleFS] reset : " +resetMethod );
327
+ System .out .println ("[LittleFS] port : " +serialPort );
328
+ System .out .println ("[LittleFS] speed : " +uploadSpeed );
329
+ if (!uploadCmd .isEmpty ()) {
330
+ System .out .println ("[SPIFFS] python : " +pythonCmd );
331
+ System .out .println ("[SPIFFS] uploader : " +uploadCmd );
332
+ }
333
+
317
334
System .out .println ();
318
- sysExec (new String []{esptool .getAbsolutePath (), "-cd" , resetMethod , "-cb" , uploadSpeed , "-cp" , serialPort , "-ca" , uploadAddress , "-cf" , imagePath });
335
+ if (!uploadCmd .isEmpty ()) {
336
+ sysExec (new String []{pythonCmd , uploadCmd , "--chip" , "esp8266" , "--port" , serialPort , "--baud" , uploadSpeed , "write_flash" , uploadAddress , imagePath , "--end" });
337
+ } else {
338
+ sysExec (new String []{esptool .getAbsolutePath (), "-cd" , resetMethod , "-cb" , uploadSpeed , "-cp" , serialPort , "-ca" , uploadAddress , "-cf" , imagePath });
339
+ }
319
340
}
320
341
}
321
342
0 commit comments