From 1895ef1c3e667910d3eb86053ddbd7c8dcdaad98 Mon Sep 17 00:00:00 2001 From: Mat931 <49403702+Mat931@users.noreply.github.com> Date: Sun, 3 May 2026 20:03:38 +0200 Subject: [PATCH] Restore 'Used size' of running app in dump_config --- esphome/components/esphome/ota/ota_esphome.cpp | 12 ++++++------ esphome/components/esphome/ota/ota_esphome.h | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/esphome/components/esphome/ota/ota_esphome.cpp b/esphome/components/esphome/ota/ota_esphome.cpp index 00089c000d..369f39e22b 100644 --- a/esphome/components/esphome/ota/ota_esphome.cpp +++ b/esphome/components/esphome/ota/ota_esphome.cpp @@ -87,6 +87,10 @@ void ESPHomeOTAComponent::setup() { // no wakes fire and loop() falls back to the self-disable safety net. esphome_fast_select_set_ota_listener_sock(esphome_lwip_get_sock(this->server_->get_fd())); #endif + +#ifdef USE_OTA_PARTITIONS + ota::get_running_app_position(this->running_app_offset_, this->running_app_size_); +#endif } void ESPHomeOTAComponent::dump_config() { @@ -101,16 +105,12 @@ void ESPHomeOTAComponent::dump_config() { } #endif #ifdef USE_OTA_PARTITIONS - // running_app_part can be nullptr if the partition cache was unloaded by a prior aborted - // partition-table OTA; surface zeros instead of dereferencing. - const esp_partition_t *running_app_part = esp_ota_get_running_partition(); ESP_LOGCONFIG(TAG, " Partition access allowed\n" " Running app:\n" " Partition address: 0x%X\n" - " Partition size: 0x%X bytes", - running_app_part != nullptr ? running_app_part->address : 0u, - running_app_part != nullptr ? running_app_part->size : 0u); + " Used size: %zu bytes (0x%X)", + this->running_app_offset_, this->running_app_size_, this->running_app_size_); #ifdef USE_ESP32 ESP_LOGCONFIG(TAG, " Partition table:"); diff --git a/esphome/components/esphome/ota/ota_esphome.h b/esphome/components/esphome/ota/ota_esphome.h index 5043bc33ef..0053ca6969 100644 --- a/esphome/components/esphome/ota/ota_esphome.h +++ b/esphome/components/esphome/ota/ota_esphome.h @@ -98,6 +98,10 @@ class ESPHomeOTAComponent final : public ota::OTAComponent { uint32_t client_connect_time_{0}; static constexpr size_t HANDSHAKE_BUF_SIZE = 5; +#ifdef USE_OTA_PARTITIONS + uint32_t running_app_offset_{0}; + size_t running_app_size_{0}; +#endif uint16_t port_; uint8_t handshake_buf_[HANDSHAKE_BUF_SIZE]; OTAState ota_state_{OTAState::IDLE};