From e9b742434f48502bca4b54b12f2858ea1d170007 Mon Sep 17 00:00:00 2001 From: Luc <8822552+luc-github@users.noreply.github.com> Date: Thu, 24 Sep 2020 20:12:35 +0200 Subject: [PATCH] Fix loop of unique ota partition wrongly detected as second partition next update partition should give null if no next app partition, but actually it loop first partition, so compare both addresses to be sure there are 2 distinct partitions --- esp3d/src/include/version.h | 2 +- esp3d/src/modules/filesystem/esp_filesystem.cpp | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/esp3d/src/include/version.h b/esp3d/src/include/version.h index d16f088f..05760086 100644 --- a/esp3d/src/include/version.h +++ b/esp3d/src/include/version.h @@ -22,7 +22,7 @@ #define _VERSION_ESP3D_H //version and sources location -#define FW_VERSION "3.0.0.a57" +#define FW_VERSION "3.0.0.a58" #define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0" #endif //_VERSION_ESP3D_H diff --git a/esp3d/src/modules/filesystem/esp_filesystem.cpp b/esp3d/src/modules/filesystem/esp_filesystem.cpp index 04ece8d7..c65e92dc 100644 --- a/esp3d/src/modules/filesystem/esp_filesystem.cpp +++ b/esp3d/src/modules/filesystem/esp_filesystem.cpp @@ -65,13 +65,15 @@ size_t ESP_FileSystem::max_update_size() #endif //ARDUINO_ARCH_ESP8266 #if defined (ARDUINO_ARCH_ESP32) //Is OTA available ? - if (esp_ota_get_running_partition()) { - const esp_partition_t* partition = esp_ota_get_next_update_partition(NULL); + const esp_partition_t* mainpartition = esp_ota_get_running_partition(); + if (mainpartition) { + const esp_partition_t* partition = esp_ota_get_next_update_partition(mainpartition); if (partition) { - flashsize = partition->size; + const esp_partition_t* partition2 = esp_ota_get_next_update_partition(partition); + if (partition2 && (partition->address!=partition2->address)) { + flashsize = partition2->size; + } } - } else { - flashsize = 0; } #endif //ARDUINO_ARCH_ESP32 return flashsize;