Browse Source

fix task wdt to handle PANIC situations and spiffs formatting

devsaurus 6 years ago
parent
commit
8d843e5beb
3 changed files with 19 additions and 1 deletions
  1. 15 0
      components/platform/flash_api.c
  2. 1 1
      components/platform/include/flash_api.h
  3. 3 0
      sdkconfig.defaults

+ 15 - 0
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);
+}

+ 1 - 1
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__

+ 3 - 0
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