Add WDT API for Core 0 and disable it while SPIFFS is formatting

This commit is contained in:
me-no-dev 2018-12-28 21:14:46 +02:00
parent f49c854ff3
commit 28ea39cf05
3 changed files with 29 additions and 5 deletions

View File

@ -70,7 +70,21 @@ void disableLoopWDT(){
}
#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(){
TaskHandle_t idle_1 = xTaskGetIdleTaskHandleForCPU(1);
if(idle_1 == NULL || esp_task_wdt_add(idle_1) != ESP_OK){

View File

@ -78,8 +78,11 @@ void enableLoopWDT();
void disableLoopWDT();
#endif
#ifndef CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1
//enable/disable WDT for the IDLE task on Core 1
//enable/disable WDT for the IDLE task on Core 0 (SYSTEM)
void enableCore0WDT();
void disableCore0WDT();
#ifndef CONFIG_FREERTOS_UNICORE
//enable/disable WDT for the IDLE task on Core 1 (Arduino)
void enableCore1WDT();
void disableCore1WDT();
#endif

View File

@ -39,11 +39,16 @@ bool SPIFFSFS::begin(bool formatOnFail, const char * basePath, uint8_t maxOpenFi
.base_path = basePath,
.partition_label = NULL,
.max_files = maxOpenFiles,
.format_if_mount_failed = formatOnFail
.format_if_mount_failed = false
};
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);
return false;
}
@ -65,7 +70,9 @@ void SPIFFSFS::end()
bool SPIFFSFS::format()
{
disableCore0WDT();
esp_err_t err = esp_spiffs_format(NULL);
enableCore0WDT();
if(err){
log_e("Formatting SPIFFS failed! Error: %d", err);
return false;