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