Add WDT API for Core 0 and disable it while SPIFFS is formatting
This commit is contained in:
parent
f49c854ff3
commit
28ea39cf05
@ -70,7 +70,21 @@ void disableLoopWDT(){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1
|
void enableCore0WDT(){
|
||||||
|
TaskHandle_t idle_0 = xTaskGetIdleTaskHandleForCPU(0);
|
||||||
|
if(idle_0 == NULL || esp_task_wdt_add(idle_0) != ESP_OK){
|
||||||
|
log_e("Failed to add Core 0 IDLE task to WDT");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void disableCore0WDT(){
|
||||||
|
TaskHandle_t idle_0 = xTaskGetIdleTaskHandleForCPU(0);
|
||||||
|
if(idle_0 == NULL || esp_task_wdt_delete(idle_0) != ESP_OK){
|
||||||
|
log_e("Failed to remove Core 0 IDLE task from WDT");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef CONFIG_FREERTOS_UNICORE
|
||||||
void enableCore1WDT(){
|
void enableCore1WDT(){
|
||||||
TaskHandle_t idle_1 = xTaskGetIdleTaskHandleForCPU(1);
|
TaskHandle_t idle_1 = xTaskGetIdleTaskHandleForCPU(1);
|
||||||
if(idle_1 == NULL || esp_task_wdt_add(idle_1) != ESP_OK){
|
if(idle_1 == NULL || esp_task_wdt_add(idle_1) != ESP_OK){
|
||||||
|
@ -78,8 +78,11 @@ void enableLoopWDT();
|
|||||||
void disableLoopWDT();
|
void disableLoopWDT();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1
|
//enable/disable WDT for the IDLE task on Core 0 (SYSTEM)
|
||||||
//enable/disable WDT for the IDLE task on Core 1
|
void enableCore0WDT();
|
||||||
|
void disableCore0WDT();
|
||||||
|
#ifndef CONFIG_FREERTOS_UNICORE
|
||||||
|
//enable/disable WDT for the IDLE task on Core 1 (Arduino)
|
||||||
void enableCore1WDT();
|
void enableCore1WDT();
|
||||||
void disableCore1WDT();
|
void disableCore1WDT();
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,11 +39,16 @@ bool SPIFFSFS::begin(bool formatOnFail, const char * basePath, uint8_t maxOpenFi
|
|||||||
.base_path = basePath,
|
.base_path = basePath,
|
||||||
.partition_label = NULL,
|
.partition_label = NULL,
|
||||||
.max_files = maxOpenFiles,
|
.max_files = maxOpenFiles,
|
||||||
.format_if_mount_failed = formatOnFail
|
.format_if_mount_failed = false
|
||||||
};
|
};
|
||||||
|
|
||||||
esp_err_t err = esp_vfs_spiffs_register(&conf);
|
esp_err_t err = esp_vfs_spiffs_register(&conf);
|
||||||
if(err){
|
if(err == ESP_FAIL && formatOnFail){
|
||||||
|
if(format()){
|
||||||
|
err = esp_vfs_spiffs_register(&conf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(err != ESP_OK){
|
||||||
log_e("Mounting SPIFFS failed! Error: %d", err);
|
log_e("Mounting SPIFFS failed! Error: %d", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -65,7 +70,9 @@ void SPIFFSFS::end()
|
|||||||
|
|
||||||
bool SPIFFSFS::format()
|
bool SPIFFSFS::format()
|
||||||
{
|
{
|
||||||
|
disableCore0WDT();
|
||||||
esp_err_t err = esp_spiffs_format(NULL);
|
esp_err_t err = esp_spiffs_format(NULL);
|
||||||
|
enableCore0WDT();
|
||||||
if(err){
|
if(err){
|
||||||
log_e("Formatting SPIFFS failed! Error: %d", err);
|
log_e("Formatting SPIFFS failed! Error: %d", err);
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user