Przeglądaj źródła

Subscribe the update task to the ESP-IDF task watchdog

Arduino.h's delay()/yield() and SPI.h's transfer() call
esphome::App.feed_wdt() to keep this task's long busy-waits and SPI
write bursts from starving another task's watchdog - but feed_wdt()
only resets the *calling* task's own subscription, and only the main
loop task was ever subscribed (by esphome's own setup). Every one of
those calls from update_task_ was silently failing
(esp_task_wdt_reset() logging "task not found" once per second, at
esphome's feed-rate-limit), and a crash inside the watchdog
subsystem's own idle-task hook followed a burst of that error on
hardware - so it's at best useless, plausibly worse.

Subscribe this task to the watchdog for real when it starts, so those
resets actually land.
ZiB 1 miesiąc temu
rodzic
commit
c54c448e6b
1 zmienionych plików z 12 dodań i 0 usunięć
  1. 12 0
      components/gxepd2/gxepd2_display.h

+ 12 - 0
components/gxepd2/gxepd2_display.h

@@ -2,6 +2,7 @@
 
 #include <atomic>
 
+#include <esp_task_wdt.h>
 #include <freertos/FreeRTOS.h>
 #include <freertos/semphr.h>
 #include <freertos/task.h>
@@ -215,6 +216,17 @@ class GxEPD2Display : public display::DisplayBuffer {
   // until update() wakes it, runs one full refresh, then goes back to
   // sleep. Never returns; this is the task's entire body for its lifetime.
   [[noreturn]] void update_task_loop_() {
+    // Arduino.h's delay()/yield() and SPI.h's transfer() call
+    // esphome::App.feed_wdt() to keep this task's own long busy-waits and
+    // SPI write bursts from starving another task's watchdog - but
+    // feed_wdt() only resets the *calling* task's own subscription, and
+    // this task was never subscribed (only the main loop task is, by
+    // esphome's own setup). Every one of those calls was silently failing
+    // (esp_task_wdt_reset() logging "task not found"), which is at best
+    // useless and, going by a crash inside the same watchdog subsystem's
+    // idle-task hook right after a burst of that error, plausibly worse
+    // than useless. Subscribe for real so those resets land.
+    esp_task_wdt_add(nullptr);
     while (true) {
       ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
       uint32_t start = millis();