Skip to content

ESP32 OTA Compressed Firmware Fails

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about ESP32 OTA Compressed Firmware Fails. We cover key concepts, practical examples, and best practices.

The Problem

ESP32 OTA update with compressed firmware (.bin.gz) fails to decompress.

Quick Fix

Wrong

http.getStream() // Sending raw gzip without decompression
Corrupted firmware written to partition. Boot fails.
WiFiClient* stream = http.getStreamPtr();
size_t totalSize = http.getSize();
Update.begin(totalSize);
uint8_t buf[512];
while (http.connected() && stream->available()) {
  int len = stream->readBytes(buf, 512);
  Update.write(buf, len);
  Serial.printf("Progress: %d%%\n", Update.progress() * 100 / totalSize);
}
if (Update.end()) {
  Serial.println("Decompressed OTA complete");
}
Progress: 25%
Progress: 50%
Progress: 75%
Progress: 100%
Decompressed OTA complete

Prevention

OTA does NOT automatically decompress gzip. Send raw .bin files over OTA. Use gzip for HTTP transfer but decompress before Update.write(). Verify uncompressed size matches partition. Compress at server, decompress at ESP32.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### Does ESP32 support compressed OTA?

ESP-IDF supports compressed OTA with CONFIG_OTA_COMPRESSION. Arduino core does not. Use uncompressed .bin files for Arduino OTA.

How do I compress OTA images?

At server side, serve the .bin file as-is with Content-Type: application/octet-stream. Do not gzip at HTTP level.

What is the advantage of compressed OTA?

Smaller download size (30-50% reduction) means faster updates and less bandwidth. ESP32 decompresses on the fly during write.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro