From ab735832941fd6bd2909b1995e268e2f9f6504f3 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 20 Jul 2021 15:05:00 +0200 Subject: [PATCH 1/3] Fix ESP32-Solo WDT on HTTP OTA update --- libraries/HTTPUpdate/src/HTTPUpdate.cpp | 3 +++ libraries/Update/src/Updater.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/HTTPUpdate/src/HTTPUpdate.cpp b/libraries/HTTPUpdate/src/HTTPUpdate.cpp index 9d1c782225f..e39d81500a8 100644 --- a/libraries/HTTPUpdate/src/HTTPUpdate.cpp +++ b/libraries/HTTPUpdate/src/HTTPUpdate.cpp @@ -199,6 +199,9 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren if(sketchMD5.length() != 0) { http.addHeader("x-ESP32-sketch-md5", sketchMD5); } + + delay(1); // Fix solo WDT + // Add also a SHA256 String sketchSHA256 = getSketchSHA256(); if(sketchSHA256.length() != 0) { diff --git a/libraries/Update/src/Updater.cpp b/libraries/Update/src/Updater.cpp index f9ecbfb057f..2b40185e7ae 100644 --- a/libraries/Update/src/Updater.cpp +++ b/libraries/Update/src/Updater.cpp @@ -352,7 +352,7 @@ size_t UpdateClass::writeStream(Stream &data) { bytesToRead = remaining(); } - /* + /* Init read&timeout counters and try to read, if read failed, increase counter, wait 100ms and try to read again. If counter > 300 (30 sec), give up/abort */ @@ -377,6 +377,8 @@ size_t UpdateClass::writeStream(Stream &data) { if((_bufferLen == remaining() || _bufferLen == SPI_FLASH_SEC_SIZE) && !_writeBuffer()) return written; written += toRead; + + delay(1); // Fix solo WDT } return written; } From 72e30b832a4ec72eb79265aa568baa7e3b5a2289 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 20 Jul 2021 16:43:46 +0200 Subject: [PATCH 2/3] Fix ESP32-Solo WDT on HTTP OTA update --- cores/esp32/Esp.cpp | 12 +++++++----- libraries/HTTPUpdate/src/HTTPUpdate.cpp | 3 --- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cores/esp32/Esp.cpp b/cores/esp32/Esp.cpp index 5e28bf83867..30414469b51 100644 --- a/cores/esp32/Esp.cpp +++ b/cores/esp32/Esp.cpp @@ -42,7 +42,7 @@ extern "C" { #elif CONFIG_IDF_TARGET_ESP32C3 #include "esp32c3/rom/spi_flash.h" #define ESP_FLASH_IMAGE_BASE 0x0000 // Esp32c3 is located at 0x0000 -#else +#else #error Target CONFIG_IDF_TARGET is not supported #endif #else // ESP32 Before IDF 4.0 @@ -187,7 +187,7 @@ static uint32_t sketchSize(sketchSize_t response) { return data.image_len; } } - + uint32_t EspClass::getSketchSize () { return sketchSize(SKETCH_SIZE_TOTAL); } @@ -226,6 +226,8 @@ String EspClass::getSketchMD5() md5.add(buf.get(), readBytes); lengthLeft -= readBytes; offset += readBytes; + + delay(1); // Fix solo WDT } md5.calculate(); result = md5.toString(); @@ -376,17 +378,17 @@ bool EspClass::flashRead(uint32_t offset, uint32_t *data, size_t size) return spi_flash_read(offset, (uint32_t*) data, size) == ESP_OK; } -bool EspClass::partitionEraseRange(const esp_partition_t *partition, uint32_t offset, size_t size) +bool EspClass::partitionEraseRange(const esp_partition_t *partition, uint32_t offset, size_t size) { return esp_partition_erase_range(partition, offset, size) == ESP_OK; } -bool EspClass::partitionWrite(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size) +bool EspClass::partitionWrite(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size) { return esp_partition_write(partition, offset, data, size) == ESP_OK; } -bool EspClass::partitionRead(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size) +bool EspClass::partitionRead(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size) { return esp_partition_read(partition, offset, data, size) == ESP_OK; } diff --git a/libraries/HTTPUpdate/src/HTTPUpdate.cpp b/libraries/HTTPUpdate/src/HTTPUpdate.cpp index e39d81500a8..9d1c782225f 100644 --- a/libraries/HTTPUpdate/src/HTTPUpdate.cpp +++ b/libraries/HTTPUpdate/src/HTTPUpdate.cpp @@ -199,9 +199,6 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren if(sketchMD5.length() != 0) { http.addHeader("x-ESP32-sketch-md5", sketchMD5); } - - delay(1); // Fix solo WDT - // Add also a SHA256 String sketchSHA256 = getSketchSHA256(); if(sketchSHA256.length() != 0) { From 44a15afcf833761c5dcd38b4b3cdf4bf8a27d8e0 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:15:07 -0300 Subject: [PATCH 3/3] Fix commits --- cores/esp32/Esp.cpp | 10 ++++++---- libraries/Update/src/Updater.cpp | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cores/esp32/Esp.cpp b/cores/esp32/Esp.cpp index 4b7919e4dde..925a67dfbad 100644 --- a/cores/esp32/Esp.cpp +++ b/cores/esp32/Esp.cpp @@ -60,7 +60,7 @@ extern "C" { #elif CONFIG_IDF_TARGET_ESP32H2 #include "esp32h2/rom/spi_flash.h" #define ESP_FLASH_IMAGE_BASE 0x0000 // Esp32h2 is located at 0x0000 -#else +#else #error Target CONFIG_IDF_TARGET is not supported #endif #else // ESP32 Before IDF 4.0 @@ -249,7 +249,9 @@ String EspClass::getSketchMD5() lengthLeft -= readBytes; offset += readBytes; + #if CONFIG_FREERTOS_UNICORE delay(1); // Fix solo WDT + #endif } free(pb); md5.calculate(); @@ -525,17 +527,17 @@ bool EspClass::flashRead(uint32_t offset, uint32_t *data, size_t size) return esp_flash_read(esp_flash_default_chip, (void*) data, offset, size) == ESP_OK; } -bool EspClass::partitionEraseRange(const esp_partition_t *partition, uint32_t offset, size_t size) +bool EspClass::partitionEraseRange(const esp_partition_t *partition, uint32_t offset, size_t size) { return esp_partition_erase_range(partition, offset, size) == ESP_OK; } -bool EspClass::partitionWrite(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size) +bool EspClass::partitionWrite(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size) { return esp_partition_write(partition, offset, data, size) == ESP_OK; } -bool EspClass::partitionRead(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size) +bool EspClass::partitionRead(const esp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size) { return esp_partition_read(partition, offset, data, size) == ESP_OK; } diff --git a/libraries/Update/src/Updater.cpp b/libraries/Update/src/Updater.cpp index 61a89c59120..9980558dbba 100644 --- a/libraries/Update/src/Updater.cpp +++ b/libraries/Update/src/Updater.cpp @@ -368,7 +368,7 @@ size_t UpdateClass::writeStream(Stream &data) { bytesToRead = remaining(); } - /* + /* Init read&timeout counters and try to read, if read failed, increase counter, wait 100ms and try to read again. If counter > 300 (30 sec), give up/abort */ @@ -394,7 +394,9 @@ size_t UpdateClass::writeStream(Stream &data) { return written; written += toRead; + #if CONFIG_FREERTOS_UNICORE delay(1); // Fix solo WDT + #endif } return written; }