mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 15:27:33 +00:00
Gate RP2 gzip on the core version, log an inflate overrun, document the window aliasing
This commit is contained in:
@@ -824,8 +824,10 @@ ota::OTAResponseTypes ESPHomeOTAComponent::inflate_flush_(InflateSession &sessio
|
||||
const size_t pending = produced - session.flushed;
|
||||
if (pending == 0)
|
||||
return ota::OTA_RESPONSE_OK;
|
||||
if (pending > session.image_size - session.written)
|
||||
if (pending > session.image_size - session.written) {
|
||||
ESP_LOGW(TAG, "Inflate overrun");
|
||||
return ota::OTA_RESPONSE_ERROR_UNKNOWN;
|
||||
}
|
||||
ota::OTAResponseTypes result = this->write_flash_(session.window + session.flushed, pending);
|
||||
if (result != ota::OTA_RESPONSE_OK)
|
||||
return result;
|
||||
|
||||
@@ -56,7 +56,9 @@ struct OtaInflateState {
|
||||
|
||||
/* dict must cover the encoder's window (its largest back reference) */
|
||||
void ota_inflate_init(struct OtaInflateState *d, unsigned char *dict, unsigned int dict_len);
|
||||
/* Fills dest up to dest_limit (OK) or to the end of the stream (DONE) */
|
||||
/* Fills dest up to dest_limit (OK) or to the end of the stream (DONE). dest may
|
||||
alias dict only if dest_limit - dest == dict_len and dest is reset to dict
|
||||
exactly when a call returns OK, so the ring index and dest stay in lockstep */
|
||||
int ota_inflate(struct OtaInflateState *d);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/macros.h"
|
||||
|
||||
#include <RP2040Version.h>
|
||||
|
||||
namespace esphome::ota {
|
||||
|
||||
class ArduinoRP2OTABackend final {
|
||||
@@ -15,10 +17,12 @@ class ArduinoRP2OTABackend final {
|
||||
OTAResponseTypes write(uint8_t *data, size_t len);
|
||||
OTAResponseTypes end();
|
||||
void abort();
|
||||
// The core's OTA stub inflates a staged gzip image at reboot (arduino-pico
|
||||
// 2.4.0, RP2350 4.0.3; ESPHome pins 6.0.0). begin() only sees the gzip
|
||||
// size; the inflated size is known when the stub reads the trailer.
|
||||
static constexpr bool supports_compression() { return true; }
|
||||
// The core's OTA stub inflates a staged gzip image at reboot, on every chip
|
||||
// from 4.0.3 (ESPHome pins 6.0.0). begin() only sees the gzip size; the
|
||||
// inflated size is known when the stub reads the trailer.
|
||||
static constexpr bool supports_compression() {
|
||||
return VERSION_CODE(ARDUINO_PICO_MAJOR, ARDUINO_PICO_MINOR, ARDUINO_PICO_REVISION) >= VERSION_CODE(4, 0, 3);
|
||||
}
|
||||
|
||||
private:
|
||||
bool md5_set_{false};
|
||||
|
||||
Reference in New Issue
Block a user