Hi,
I’m using an ESP32 with EC200U to download and flash firmware via OTA, while also saving a copy to SD. The download sometimes loses data in the middle, causing OTA failures.
Current approach:
- 256-byte buffer with
EC200U.readBytes().
- Writing each chunk to OTA and SD immediately.
- 15s inactivity timeout.
Issue: Some bytes in the firmware are missing despite checking available() and waiting for “CONNECT”. Suspect buffer overflow or blocking read.
Question: What’s the best practice to reliably read large firmware files from EC200U without missing data?
I’d suggest trying a byte-by-byte read approach instead of using a 256-byte buffer. Sometimes, buffering can introduce subtle timing or overflow issues, especially when writing to both OTA and SD simultaneously. Reading one byte at a time might help ensure you don’t miss any data, even if it’s a bit slower.
Also, consider adding a small delay or yield between reads to give the module and your tasks some breathing room. Let me know if you want a code snippet for this approach.
Thank you for your rsponse
I have already tried that , but while downloading the file some portion of the data in between the file gets missing. That is if my total bytes size is 285413 , I am only able to get about 284931 bytes . While I tried to download the file into a SD card and then flash it from it, that worked.
If you want I can share the code that I have with me.
I didn’t tried it on ESP32. I’ve seen such problem with Linux.
The way you tried work fine for EC25 but failed for EC200U.
test.c (9.6 KB)
Here is an example code for Linux.