An ESP32 can lock up in two different ways, and the chip has a watchdog for each one. This reading review covers two ESP-IDF pages, the Watchdogs page and the ESP-IDF FreeRTOS page, and pulls out what each watchdog actually watches, how the two timeouts differ, and what the scheduler promises a task that never blocks.
1. Three watchdog timers, two of them about the CPU (ESP-IDF Watchdogs page)
The page names three timers. The Task Watchdog Timer (TWDT) detects tasks that run without yielding for too long. The RTC/LP Watchdog Timer tracks boot time from power-up until app_main, and can also run during panic handling and in the low-power domain. The Interrupt Watchdog Timer (IWDT) and the TWDT are both built on the MWDT_WDT hardware timer in Timer Group 0, and a timeout raises an interrupt.
The page describes the IWDT failure as a panic: the panic handler reports Interrupt wdt timeout on CPU0 or ...CPU1, and what happens next depends on CONFIG_ESP_SYSTEM_PANIC. If the panic handler cannot run at all, the IWDT has a second-stage timeout that hard-resets the chip.
Lesson: an ISR or critical section that overruns is an interrupt watchdog problem. Changing a task's priority does nothing for it.
2. The task watchdog watches the idle task by default (same page)
By default the TWDT subscribes the idle task of each CPU. That is how it spots a task that monopolizes the CPU: if nothing yields, the idle task never runs and never feeds the timer. The page lists the API as esp_task_wdt_init() to initialize and subscribe the idle tasks, esp_task_wdt_add() to subscribe another task, esp_task_wdt_reset() to feed it from inside that task, and esp_task_wdt_delete() / esp_task_wdt_deinit() to back out. For finer granularity it also offers "users": esp_task_wdt_add_user() returns a handle, esp_task_wdt_reset_user() feeds that handle, esp_task_wdt_delete_user() removes it.
Two details are easy to miss. The timeout comes from CONFIG_ESP_TASK_WDT_TIMEOUT_S and the page says it should be at least as long as any single task legitimately needs to monopolize the CPU; it can also be changed at runtime with esp_task_wdt_init(). And a large flash erase can run long enough to trip the watchdog, so the page suggests raising the timeout, or calling esp_task_wdt_init() again, before erasing.
The default reaction to a TWDT timeout is to print a warning and a backtrace and keep running. Turning it into a panic and reset is a separate option, CONFIG_ESP_TASK_WDT_PANIC.
Lesson: a watchdog that only prints is a logging feature. If the device has to recover with nobody watching, the panic option is the part that matters.
3. What the scheduler promises a task that never blocks (ESP-IDF FreeRTOS page)
The FreeRTOS page describes vanilla FreeRTOS as a fixed priority preemptive scheduler with time slicing: the scheduler switches between ready tasks of the same priority in round-robin order, driven by a tick interrupt. IDF FreeRTOS keeps the same features, with behavioral differences worth knowing on a dual-core part.
Preemption happens when a higher-priority task becomes ready, but the page says that when such a task could run on more than one core, the scheduler preempts only one, preferring the current core. Time slicing in IDF FreeRTOS is best effort rather than perfect round robin, because a task may not be allowed to run on a given core; the page's remedy is to pin all tasks of a priority to the same core. Each core also gets its own tick interrupt, same period, possibly out of phase.
Lesson: on the dual-core chips, a high-priority task that never blocks can starve the lower-priority ones, and the idle task that feeds the TWDT is the lowest of them.
4. The two messages point to different fixes (Watchdogs page, troubleshooting)
The page gives the exact strings to look for. Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0) with a backtrace means interrupts were blocked longer than the IWDT allows, and the fix is shorter ISRs or critical sections, or a longer IWDT timeout. Task watchdog got triggered. The following tasks/users did not reset the watchdog in time: IDLE0 (CPU 0) means a task did not yield, and the page points at the user-level subscription API to find which task and which code path is taking the time.
One more note from the same page: OpenOCD disables both watchdog timers at every breakpoint and does not re-enable them on resume, so no watchdog warnings or panics appear while debugging over JTAG.
Lesson: the same reset can come from two very different bugs. Read the message before changing a timeout.
Checklist from the sources
- Decide what a timeout should do: warn, panic, or reset (
CONFIG_ESP_TASK_WDT_PANIC). - Set the TWDT timeout from the longest legitimate CPU monopoly, not from the shortest task period.
- Subscribe long-running tasks with
esp_task_wdt_add()and feed them deliberately; useesp_task_wdt_add_user()to isolate one code path. - Raise the timeout before erasing large flash areas.
- Keep blocking and yielding calls out of critical sections, as the FreeRTOS page states.
- Treat the interrupt watchdog message and the task watchdog message as two diagnoses, not one.
This is a documentation review, not a measurement report. It makes no claim about any specific board or firmware.
Top comments (0)