Skip to content

Commit

Permalink
ESP32: Fix watchdog timeout handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tve authored and mkellner committed Nov 30, 2023
1 parent 332340e commit 134bd45
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE="8MB"

# CONFIG_ESP_DEBUG_STUBS_ENABLE=n
CONFIG_ESP_TASK_WDT_PANIC=y
CONFIG_ESP_TASK_WDT=y
CONFIG_ESP_TASK_WDT_EN=y
CONFIG_ESP_TASK_WDT_INIT=y
CONFIG_ESP_TASK_WDT_TIMEOUT_S=10

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

# CONFIG_ESP_DEBUG_STUBS_ENABLE=n
CONFIG_ESP_TASK_WDT_PANIC=y
CONFIG_ESP_TASK_WDT=y
CONFIG_ESP_TASK_WDT_EN=y
CONFIG_ESP_TASK_WDT_INIT=y
CONFIG_ESP_TASK_WDT_TIMEOUT_S=10

# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT=y
Expand Down
2 changes: 1 addition & 1 deletion build/devices/esp32/xsProj-esp32/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static void debug_task(void *pvParameter)

void loop_task(void *pvParameter)
{
#if CONFIG_ESP_TASK_WDT
#if CONFIG_ESP_TASK_WDT_EN
esp_task_wdt_add(NULL);
#endif

Expand Down
2 changes: 1 addition & 1 deletion build/devices/esp32/xsProj-esp32c3/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static void debug_task(void *pvParameter)

void loop_task(void *pvParameter)
{
#if CONFIG_ESP_TASK_WDT
#if CONFIG_ESP_TASK_WDT_EN
esp_task_wdt_add(NULL);
#endif

Expand Down
2 changes: 1 addition & 1 deletion build/devices/esp32/xsProj-esp32c6/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void debug_task(void *pvParameter)

void loop_task(void *pvParameter)
{
#if CONFIG_ESP_TASK_WDT
#if CONFIG_ESP_TASK_WDT_EN
esp_task_wdt_add(NULL);
#endif

Expand Down
2 changes: 1 addition & 1 deletion build/devices/esp32/xsProj-esp32h2/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void debug_task(void *pvParameter)

void loop_task(void *pvParameter)
{
#if CONFIG_ESP_TASK_WDT
#if CONFIG_ESP_TASK_WDT_EN
esp_task_wdt_add(NULL);
#endif

Expand Down
2 changes: 1 addition & 1 deletion build/devices/esp32/xsProj-esp32s2/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void setup(void)

void loop_task(void *pvParameter)
{
#if CONFIG_ESP_TASK_WDT
#if CONFIG_ESP_TASK_WDT_EN
esp_task_wdt_add(NULL);
#endif

Expand Down
2 changes: 1 addition & 1 deletion build/devices/esp32/xsProj-esp32s3/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ static void debug_task(void *pvParameter)

void loop_task(void *pvParameter)
{
#if CONFIG_ESP_TASK_WDT
#if CONFIG_ESP_TASK_WDT_EN
esp_task_wdt_add(NULL);
#endif

Expand Down
9 changes: 8 additions & 1 deletion xs/platforms/esp/xsHost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,15 @@ void modMessageService(xsMachine *the, int maxDelayMS)
{
modMessageRecord msg;

#if CONFIG_ESP_TASK_WDT
#if CONFIG_ESP_TASK_WDT_EN
modWatchDogReset();
#ifndef CONFIG_ESP_TASK_WDT_TIMEOUT_S
// The default timeout is 5s, but it can be changed using this CONFIG decl as well as
// dynamically via esp_task_wdt_reconfigure, we assume "worst case" 1s here if it's not
// defined (could actually be set lower dynamically). There is no way to extract the
// current timeout value from esp-idf.
#define CONFIG_ESP_TASK_WDT_TIMEOUT_S (1)
#endif
if (maxDelayMS >= (CONFIG_ESP_TASK_WDT_TIMEOUT_S * 1000)) {
#if CONFIG_ESP_TASK_WDT_TIMEOUT_S <= 1
maxDelayMS = 500;
Expand Down
2 changes: 1 addition & 1 deletion xs/platforms/esp/xsHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ double __ieee754_fmod_patch(double x, double y);
#if !ESP32
#define modWatchDogReset() system_soft_wdt_feed()
#else
#if CONFIG_ESP_TASK_WDT
#if CONFIG_ESP_TASK_WDT_EN
#define modWatchDogReset() esp_task_wdt_reset()
#else
#define modWatchDogReset()
Expand Down

0 comments on commit 134bd45

Please sign in to comment.