From 5f234639147628961fe5fa41852072e2cad17c7d Mon Sep 17 00:00:00 2001 From: Jonny Date: Thu, 7 Aug 2025 09:11:46 +0100 Subject: [PATCH 1/2] Readd watchdog (re)initialization, disable idle watchdogs --- Software/Software.ino | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Software/Software.ino b/Software/Software.ino index f912b181..d12e4e69 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -120,12 +120,23 @@ void setup() { check_reset_reason(); // Initialize Task Watchdog for subscribed tasks - esp_task_wdt_config_t wdt_config = { - .timeout_ms = INTERVAL_5_S, // If task hangs for longer than this, reboot - .idle_core_mask = - (uint32_t)(1 << esp32hal->CORE_FUNCTION_CORE()) | (uint32_t)(1 << esp32hal->WIFICORE()), // Watch both cores - .trigger_panic = true // Enable panic reset on timeout - }; + esp_task_wdt_config_t wdt_config = {// 5s should be enough for the connectivity tasks (which are all contending + // for the same core) to yield to each other and reset their watchdogs. + .timeout_ms = INTERVAL_5_S, + // We don't benefit from idle task watchdogs, our critical loops have their + // own. The idle watchdogs can cause nuisance reboots under heavy load. + .idle_core_mask = 0, + // Panic (and reboot) on timeout + .trigger_panic = true}; +#ifdef CONFIG_ESP_TASK_WDT + // ESP-IDF will have already initialized it, so reconfigure. + // Arduino and PlatformIO have different watchdog defaults, so we reconfigure + // for consistency. + esp_task_wdt_reconfigure(&wdt_config); +#else + // Otherwise initialize it for the first time. + esp_task_wdt_init(&wdt_config); +#endif // Start tasks From de770144a2f81f1d7bb23770ed22e99267756d55 Mon Sep 17 00:00:00 2001 From: Jonny Date: Thu, 7 Aug 2025 09:12:14 +0100 Subject: [PATCH 2/2] Make AsyncTCP yield each loop, to let other same-prio tasks get a turn --- Software/src/lib/mathieucarbou-AsyncTCPSock/src/AsyncTCP.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Software/src/lib/mathieucarbou-AsyncTCPSock/src/AsyncTCP.cpp b/Software/src/lib/mathieucarbou-AsyncTCPSock/src/AsyncTCP.cpp index e13fa764..e00c6e5f 100644 --- a/Software/src/lib/mathieucarbou-AsyncTCPSock/src/AsyncTCP.cpp +++ b/Software/src/lib/mathieucarbou-AsyncTCPSock/src/AsyncTCP.cpp @@ -228,6 +228,11 @@ void _asynctcpsock_task(void *) sockList.clear(); xSemaphoreGiveRecursive(_asyncsock_mutex); + + // Battery-Emulator modification: Yield so that other same-priority + // tasks on the same core get a turn, otherwise heavy HTTP traffic will + // exclude them. + taskYIELD(); } vTaskDelete(NULL);