From 8d843e5bebfb19230c1d53fb25ea87bc97384027 Mon Sep 17 00:00:00 2001 From: devsaurus Date: Mon, 2 Apr 2018 21:17:18 +0200 Subject: [PATCH] fix task wdt to handle PANIC situations and spiffs formatting --- components/platform/flash_api.c | 15 +++++++++++++++ components/platform/include/flash_api.h | 2 +- sdkconfig.defaults | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/components/platform/flash_api.c b/components/platform/flash_api.c index ff002270..bbd828ee 100644 --- a/components/platform/flash_api.c +++ b/components/platform/flash_api.c @@ -11,6 +11,7 @@ #include "esp_image_format.h" #include "esp_flash_data_types.h" +#include "esp_task_wdt.h" #define FLASH_HDR_ADDR 0x1000 @@ -171,3 +172,17 @@ uint32_t flash_rom_get_speed(void) } return 0; } + +esp_err_t flash_erase(size_t sector) +{ +#ifdef CONFIG_TASK_WDT + // re-init the task WDT, simulates feeding for the IDLE task +# ifdef CONFIG_TASK_WDT_PANIC + esp_task_wdt_init(CONFIG_TASK_WDT_TIMEOUT_S, true); +# else + esp_task_wdt_init(CONFIG_TASK_WDT_TIMEOUT_S, false); +# endif +#endif + + return spi_flash_erase_sector(sector); +} diff --git a/components/platform/include/flash_api.h b/components/platform/include/flash_api.h index 7966b8bf..fb703d44 100644 --- a/components/platform/include/flash_api.h +++ b/components/platform/include/flash_api.h @@ -19,7 +19,7 @@ uint32_t flash_rom_get_speed(void); #define FLASH_SIZE_16MBYTE (16 * 1024 * 1024) #define flash_write spi_flash_write -#define flash_erase spi_flash_erase_sector +esp_err_t flash_erase(size_t sector); #define flash_read spi_flash_read #endif // __FLASH_API_H__ diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 3aa32603..8878e7f9 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -18,3 +18,6 @@ CONFIG_TCP_MSL=5000 # No filesystem partition found, attempting to create it... # abort() was called at PC 0x400ecddd on core 0 CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED=y + +# Enable panic handler for task wdt to reset the firmware upon wdt timeout +CONFIG_TASK_WDT_PANIC=y