(long intro for newcomers: at the end)
The ‘System’ module is documented here, as you probably already know.
Your understanding seems correct to me, however, the IDF docs state:
If a task does not reset within the TWDT timeout period, a warning will be printed with information about which tasks failed to reset the TWDT in time and which tasks are currently running
The implementation for the ESP32 is here and as we can see, it calls the IDF functions, though I fail to see how and where it calls the referred esp_task_wdt_init() function.
There is this log entry:
[Jun 24 11:57:13.967] mgos_sys_config.c:374 WDT: 30 seconds
which suggests mOS is using the WDT for its own purposes.
Unfortunately I don’t have further time to play along with this now; I wrote a small piece and confirmed what you are experiencing, perhaps @nliviu can shine some light here.
In the meantime, perhaps you’d like to play with the IDF functions and comment. Regards.
#include "mgos.h"
enum mgos_app_init_result mgos_app_init(void) {
mgos_wdt_set_timeout(2);
mgos_wdt_enable();
// mgos_wdt_feed();
return MGOS_APP_INIT_SUCCESS;
}
… and now the intro:
Generically speaking, if you run on bare metal of course you “kick the dog” as often as needed (unless it is a windowed watchdog, in which case you kick it within some interval). If you have an OS, which is the case here, usually the OS handles the hardware watchdog and provides an API for you. Your app initializes a “virtual watchdog” and complies with the API to signal the OS it is alive (and kicking). In the case of the ESP32, the IDF provides its own interface here.
In mOS, there is an extra layer providing a common interface for the various supported microcontrollers.
Some implementations actually require a first kick for the WDT to be active, so simply setting it up and letting it expire won’t work, you need to first kick it and then stop doing it (the developers here seem to care about animals and they ‘feed’ the dog instead of ‘kicking’ it (him/her), but you get the picture). It doesn’t seem to be the case here.