Unverified Commit 77b64506 authored by Leif's avatar Leif Committed by GitHub

ArduinoOTA upload intermittent failure fixed (#4657)

* OTA upload often fails when client.read() return -1 and we subsequently try to write 4 gigabytes to flash. Fixed by signed comparison and retry.

* Delay of 1ms already solves the issue

* Update libraries/ArduinoOTA/src/ArduinoOTA.cpp
Co-authored-by: default avatarJan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>

---------
Co-authored-by: default avatarLeif <git@leif.lc>
Co-authored-by: default avatarLucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com>
Co-authored-by: default avatarJan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
parent f764af0d
......@@ -315,6 +315,10 @@ void ArduinoOTAClass::_runUpdate() {
size_t r = client.read(buf, available);
if(r != available){
log_w("didn't read enough! %u != %u", r, available);
if((int32_t) r<0) {
delay(1);
continue; //let's not try to write 4 gigabytes when client.read returns -1
}
}
written = Update.write(buf, r);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment