From a0398d120cf78dcf6d826844f81274cbdbfe78d1 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 8 Sep 2026 10:11:21 +0200 Subject: [PATCH] [ota] Let the RP2040 stage a gzip image and inflate it at reboot The Arduino Pico OTA stub already detects a gzip firmware.bin on LittleFS, reads the inflated length from the trailer and inflates it into the app region at reboot, so the RP2040 takes the ESP8266 path and no longer needs the on-the-fly decoder. --- esphome/components/esphome/ota/__init__.py | 7 ++++--- esphome/components/ota/ota_backend_arduino_rp2.h | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/esphome/components/esphome/ota/__init__.py b/esphome/components/esphome/ota/__init__.py index cbab552fc2..816cb7b6c8 100644 --- a/esphome/components/esphome/ota/__init__.py +++ b/esphome/components/esphome/ota/__init__.py @@ -308,9 +308,10 @@ async def to_code(config: ConfigType) -> None: if config.get(CONF_ALLOW_PARTITION_ACCESS): cg.add_define("USE_OTA_PARTITIONS") - # ESP8266 inflates gzip in its bootloader; every other platform inflates - # a deflate stream on the fly while it receives the image - if not CORE.is_esp8266: + # ESP8266 and RP2040 inflate a gzip image at reboot from their bootloader + # or OTA stub; every other platform inflates a deflate stream on the fly + # while it receives the image + if not (CORE.is_esp8266 or CORE.is_rp2): cg.add_define("USE_OTA_DEFLATE") # One key per device: an api encryption block supplies it (static or diff --git a/esphome/components/ota/ota_backend_arduino_rp2.h b/esphome/components/ota/ota_backend_arduino_rp2.h index f7c0037bd2..75f12f44b0 100644 --- a/esphome/components/ota/ota_backend_arduino_rp2.h +++ b/esphome/components/ota/ota_backend_arduino_rp2.h @@ -15,7 +15,9 @@ class ArduinoRP2OTABackend final { OTAResponseTypes write(uint8_t *data, size_t len); OTAResponseTypes end(); void abort(); - bool supports_compression() { return false; } + // A gzip image is staged on LittleFS as is; the core's OTA stub inflates it + // into the app region at reboot, the same way the ESP8266 bootloader does + bool supports_compression() { return true; } private: bool md5_set_{false};