Updating OTA is amazing

I have had some luck getting it working.

It seems that after the very first upload of your code (like the BasicOTA example), you must cycle the physical RESET button or power it down for a moment. From then on I have had no problems uploading the code!

@Jamin that is a known bug with ESP’s.

You should reboot your ESP after every Serial flash. It is nothing to do with OTA and an OTA flash doesn’t have this bug.

Many people don’t know about the bug as they simply reboot their ESP if they have a problem but when you start doing OTA this is not possible. So the initial Serial flash of the sketch containing the OTA elements is the problem that stops the device rebooting during the OTA update.

Detailed discussion on Github here.

If you don’t want to read all the Github thread then Ivan’s (Mr ESP, @igrr) last post is all you need to know.

Are you following these steps?
- upload initial code into module over serial
- power off the module
- power it back on
- perform OTA

The failure to reset after a Serial flash can occur with any sketch at any time and AFAIK there is no known fix at this current time. You will see that the Github thread was started last November and the milestone for the fix just keeps moving on. This bug only affects the FIRST software reset after the serial flash, any subsequent software resets are fine.

1 Like

I have always just replied on the upload managing the reset… as I have never had a problem in the past.
Also I point out that all the time I have problems, I was not physically close to the hardware… it was already plugged in to the computer and I was remote desktoping in from work.
I would not have had these issues if I had been able to reset it.

Yes it is the ESP.restart() that has the bug but only on first restart after a serial, not OTA, flash.
Restart the ESP manually once you have flashed the initial code via Serial and your future OTA updates will be fine.

2 Likes

Awesome advice! Cheers!
I have linked to your post (43) in my first post so people will know to skip past all the issues I had to find an answer if they also have the issue… or just want to know.

I am currently going around and recoding all my ESP’s around the house so I never have to unplug them again! Game changer!

1 Like

The bug is generally only encountered when you are testing the system in house. In a real life situation once you have done the Serial flash you normally send or take the ESP to the remote location. Unless you are sending / taking the ESP to the remote location in a powered up state i.e. connected to batteries since the last Serial flash, the bug will not occur.

1 Like

Amazing :grin:, i have just tried it now and inserted it in line with my code and 100% working.
to clarify i use the below command in between my code ,for any modification thanks to informs me :slight_smile:

#include <WiFiUdp.h>
#include <ArduinoOTA.h>

void setup () {
 ArduinoOTA.setPassword((const char *)"123"); // for password prompt insert between " "
 ArduinoOTA.begin();
}

void loop () {
  ArduinoOTA.handle();
  }

just got this;

Ready IP address: 192.168.1.103

on first try, thanks all - now to add to my sketch!

hmmm, just got this:

Sketch uses 265,915 bytes (53%) of program storage space. Maximum is 499,696 bytes.
Global variables use 36,592 bytes (44%) of dynamic memory, leaving 45,328 bytes for local variables. Maximum is 81,920 bytes.
java.io.IOException: Cannot run program "python.exe": CreateProcess error=2, The system cannot find the file specified
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
	at processing.app.helpers.ProcessUtils.exec(ProcessUtils.java:26)
	at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:130)
	at cc.arduino.packages.uploaders.GenericNetworkUploader.uploadUsingPreferences(GenericNetworkUploader.java:97)
	at cc.arduino.UploaderUtils.upload(UploaderUtils.java:78)
	at processing.app.Sketch.upload(Sketch.java:1186)
	at processing.app.Sketch.exportApplet(Sketch.java:1160)
	at processing.app.Sketch.exportApplet(Sketch.java:1132)
	at processing.app.Editor$DefaultExportHandler.run(Editor.java:2409)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
	at java.lang.ProcessImpl.create(Native Method)
	at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
	at java.lang.ProcessImpl.start(ProcessImpl.java:137)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
	... 9 more

so i am over 50% - is this what this would be?

i will cut a bit out then try…

@Dave1829 do you installed Python 2.7 as mentioned in the illustration below ? and select the option “Add python.exe to Path”

yeah, i did - do i need to restart PC or anything?

Yes ,restart it you have nothing to lose :slight_smile:

1 Like

@Dave1829 which ESP are you using and what SPIFFS allocation have you done?

using 12F with NodeMCU firmware.

and no idea what SPIFFS even is, let alone how to allocate it! :eek:

but isn’t this a fundamental problem:

where do i put this:

ESP.getFreeSketchSpace();

to know my free space?

OK, restarted and tried again - so windows firewall was blocking it, now i allow Python I get:

Sketch uses 265,035 bytes (53%) of program storage space. Maximum is 499,696 bytes.
Global variables use 36,368 bytes (44%) of dynamic memory, leaving 45,552 bytes for local variables. Maximum is 81,920 bytes.

21:54:36 [ERROR]: No response from device

so is THIS the issue with program space?

@Dave1829 now your first problem solved :slight_smile:
for the Error : No response from device you must
1-Allocate the Flash size of your module to the right one
2-upload the Basic OTA sketch again with the right Flash size with Serial connection
3-embedded the OTA code it between your code and upload it using OTA…
(for my ESP12 it was 4M(1M SPIFFS) )

@Dave1829 the 12F is a 4M not 1M device.

Change the flash size to 4M from the 1M you have in your screenshot and pick either 1M or 3M SPIFFS.

When you compile you will see your program memory has doubled from 512kb to 1MB. OTA will then work.

thanks @JohnNassiem & @Costas

this is the first time i have ever had to deal with SPIFFS - thank you!!!

tried 4M(1M SPIFFS) but no response,

tried 4M(3M SPIFFS) but still no response from device.

i followed Johns 1-2-3 steps each time