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: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>

---------

Co-authored-by: Leif <git@leif.lc>
Co-authored-by: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com>
Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
This commit is contained in:
Leif 2024-01-31 17:54:34 +07:00 committed by GitHub
parent f764af0d1c
commit 77b64506a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);