From 07f1c5f3028a5a54316435e7c56780b6735de459 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 7 May 2022 11:05:10 +0200 Subject: [PATCH] Fix single partition free space --- tasmota/support_esp.ino | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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);