From 997dedca73de5624e60b7261b771b6b1a65635bf Mon Sep 17 00:00:00 2001 From: Larry Bernstone Date: Thu, 23 Jan 2025 07:06:09 -1000 Subject: [PATCH 1/3] fix(littlefs): Converted core disableWDT functions to bool --- cores/esp32/esp32-hal-misc.c | 10 ++++++---- cores/esp32/esp32-hal.h | 4 ++-- libraries/LittleFS/src/LittleFS.cpp | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index 0bce548bdd2..286b0ea3453 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -156,11 +156,13 @@ void enableCore0WDT() { } } -void disableCore0WDT() { +bool disableCore0WDT() { TaskHandle_t idle_0 = xTaskGetIdleTaskHandleForCore(0); - if (idle_0 == NULL || esp_task_wdt_delete(idle_0) != ESP_OK) { + if (idle_0 == NULL || esp_task_wdt_status(idle_0) || esp_task_wdt_delete(idle_0) != ESP_OK) { log_e("Failed to remove Core 0 IDLE task from WDT"); + return false; } + return true; } #ifndef CONFIG_FREERTOS_UNICORE @@ -171,9 +173,9 @@ void enableCore1WDT() { } } -void disableCore1WDT() { +bool disableCore1WDT() { TaskHandle_t idle_1 = xTaskGetIdleTaskHandleForCore(1); - if (idle_1 == NULL || esp_task_wdt_delete(idle_1) != ESP_OK) { + if (idle_1 == NULL || esp_task_wdt_status(idle_1) || esp_task_wdt_delete(idle_1) != ESP_OK) { log_e("Failed to remove Core 1 IDLE task from WDT"); } } diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index d0bd4b8bc93..5ed99aeb205 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -121,11 +121,11 @@ void feedLoopWDT(); //enable/disable WDT for the IDLE task on Core 0 (SYSTEM) void enableCore0WDT(); -void disableCore0WDT(); +bool disableCore0WDT(); #ifndef CONFIG_FREERTOS_UNICORE //enable/disable WDT for the IDLE task on Core 1 (Arduino) void enableCore1WDT(); -void disableCore1WDT(); +bool disableCore1WDT(); #endif //if xCoreID < 0 or CPU is unicore, it will use xTaskCreate, else xTaskCreatePinnedToCore diff --git a/libraries/LittleFS/src/LittleFS.cpp b/libraries/LittleFS/src/LittleFS.cpp index e86caeb74cc..017780fb6f1 100644 --- a/libraries/LittleFS/src/LittleFS.cpp +++ b/libraries/LittleFS/src/LittleFS.cpp @@ -95,9 +95,9 @@ void LittleFSFS::end() { } bool LittleFSFS::format() { - disableCore0WDT(); + bool wdt_active = disableCore0WDT(); esp_err_t err = esp_littlefs_format(partitionLabel_); - enableCore0WDT(); + if (wdt_active) enableCore0WDT(); if (err) { log_e("Formatting LittleFS failed! Error: %d", err); return false; From 15ed5a3b52f4214d7bc275d8f72a98da8bb15ad3 Mon Sep 17 00:00:00 2001 From: Larry Bernstone Date: Thu, 23 Jan 2025 07:21:43 -1000 Subject: [PATCH 2/3] Missed the returns on core1 --- cores/esp32/esp32-hal-misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index 286b0ea3453..02871872f83 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -177,7 +177,9 @@ bool disableCore1WDT() { TaskHandle_t idle_1 = xTaskGetIdleTaskHandleForCore(1); if (idle_1 == NULL || esp_task_wdt_status(idle_1) || esp_task_wdt_delete(idle_1) != ESP_OK) { log_e("Failed to remove Core 1 IDLE task from WDT"); + return false; } + return true; } #endif From f406c0c8901d580d3d5491e9e107a00b483c9c3a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 09:15:54 +0000 Subject: [PATCH 3/3] ci(pre-commit): Apply automatic fixes --- libraries/LittleFS/src/LittleFS.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/LittleFS/src/LittleFS.cpp b/libraries/LittleFS/src/LittleFS.cpp index 017780fb6f1..761d1ba4c24 100644 --- a/libraries/LittleFS/src/LittleFS.cpp +++ b/libraries/LittleFS/src/LittleFS.cpp @@ -97,7 +97,9 @@ void LittleFSFS::end() { bool LittleFSFS::format() { bool wdt_active = disableCore0WDT(); esp_err_t err = esp_littlefs_format(partitionLabel_); - if (wdt_active) enableCore0WDT(); + if (wdt_active) { + enableCore0WDT(); + } if (err) { log_e("Formatting LittleFS failed! Error: %d", err); return false;