Closed meta-space closed 11 months ago
I think I found the culprit.
I am using a custom espressif32-arduino build. It turns out that I had the option CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y in my sdkconfig. This will result in the watchdog being tripped when running Matter stuff. The default esp32-arduino sdkconfig doesn't enable this setting.
I feel a little uneasy disabling the watchdog on the CPU1 Idle task... For the moment I'm going to assume that it is fine, as it is not enabled in the esp32-arduino-framework.
On the other hand the Arduino startup shows that the loopTask first invokes setup() and then loop(). If loop() blocks for some reason I'd really like to know about it :) In the Light.ino it seems that the setup() function is blocking if the device hasn't been commissioned.
void loopTask(void *pvParameters)
{
setup();
for(;;) {
#if CONFIG_FREERTOS_UNICORE
yieldIfNecessary();
#endif
if(loopTaskWDTEnabled){
esp_task_wdt_reset();
}
loop();
if (serialEventRun) serialEventRun();
}
}
I also discovered interesting functions in esp32-hal-misc.c which enable and disable the watchdogs at runtime. Maybe that's a better solution
Hey! Thanks for sharing interesting info. In my private home project I also wanted more flexibility and created custom headers for handling watchdogs:
watchdogs.h
#pragma once
#include <esp_task_wdt.h>
class WatchdogsClass
{
public:
WatchdogsClass() {}
void setupWatchdog(uint32_t timeout) {
esp_task_wdt_init(timeout, true);
esp_task_wdt_add(NULL);
}
void restartWatchdog() {
esp_task_wdt_reset();
}
private:
};
extern WatchdogsClass Watchdogs;
watchdogs.cpp
#include "watchdogs.h"
WatchdogsClass Watchdogs;
Then you can use it inside your code
Watchdogs.setupWatchdog(30); // setup watchdogs for 30 seconds
Watchdogs.restartWatchdog(); // yield (restart watchdog counter)
I'm trying to get the library to run on my devices. But I get watchdog errors. For instance running the Light.ino on my M5Stack Core (ESP32) I get:
If I globally disable the watchdogs using
esp_task_wdt_init(-1, false)
the device keeps running and I'm able to commission the light successfully and control it. Of course I cannot do this in production. I'm using PlatformIO and believe that I have fulfilled all requirements mentioned in the readme.md