diff --git a/tasmota/support_esp.ino b/tasmota/support_esp.ino index dca558cb6..57ad66046 100644 --- a/tasmota/support_esp.ino +++ b/tasmota/support_esp.ino @@ -461,11 +461,6 @@ uint32_t ESP_getChipId(void) { return id; } -uint32_t ESP_getFreeSketchSpace(void) { - uint32_t size = EspRunningFactoryPartition(); - return (size) ? size : ESP.getFreeSketchSpace(); -} - uint32_t ESP_getSketchSize(void) { static uint32_t sketchsize = 0; @@ -475,6 +470,17 @@ uint32_t ESP_getSketchSize(void) { return sketchsize; } +uint32_t ESP_getFreeSketchSpace(void) { + if (EspSingleOtaPartition()) { + uint32_t size = EspRunningFactoryPartition(); + if (!size) { + size = ESP.getFreeSketchSpace(); + } + return size - ESP_getSketchSize(); + } + return ESP.getFreeSketchSpace(); +} + uint32_t ESP_getFreeHeap(void) { // ESP_getFreeHeap() returns also IRAM which we don't use return heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);