Skip to content

Commit

Permalink
fix(littlefs): Converted core disableWDT functions to bool (#10896)
Browse files Browse the repository at this point in the history
* fix(littlefs): Converted core disableWDT functions to bool

* Missed the returns on core1

* ci(pre-commit): Apply automatic fixes

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
  • Loading branch information
lbernstone and pre-commit-ci-lite[bot] authored Jan 27, 2025
1 parent 15cbb1e commit 2fecc48
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 8 additions & 4 deletions cores/esp32/esp32-hal-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -171,11 +173,13 @@ 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");
return false;
}
return true;
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions cores/esp32/esp32-hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions libraries/LittleFS/src/LittleFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ 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;
Expand Down

0 comments on commit 2fecc48

Please sign in to comment.