Skip to content

Commit 75c3d2d

Browse files
author
Leif
committed
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.
1 parent ef99cd7 commit 75c3d2d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

libraries/ArduinoOTA/src/ArduinoOTA.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ void ArduinoOTAClass::_runUpdate() {
315315
size_t r = client.read(buf, available);
316316
if(r != available){
317317
log_w("didn't read enough! %u != %u", r, available);
318+
if((int32_t) r<0){
319+
delay(50);
320+
continue; //let's not try to write 4 gigabytes when client.read returns -1
321+
}
318322
}
319323

320324
written = Update.write(buf, r);

0 commit comments

Comments
 (0)