Description:
I am encountering an issue while testing the watchdog functionality. When I intentionally hang the system for longer than the configured watchdog timeout period, the system restarts. However, the reset cause is reported as RESET_PIN
rather than RESET_WATCHDOG
as expected.
Watchdog Initialization Code:
int hal_watchdog_init(void) { bool found = false; if (watchdog_device != NULL) { LOG_INF("watchdog HAL already initialized"); return 0; } LOG_INF("initialize watchdog HAL"); watchdog_device = DEVICE_DT_GET(WATCHDOG0_NODE); if (watchdog_device) { if (device_is_ready(watchdog_device)) { LOG_INF("found watchdog device \"%s\"", watchdog_device->name); found = true; struct wdt_timeout_cfg wdt_config = { /* reset SoC when watchdog timer expires. */ .flags = WDT_FLAG_RESET_SOC, /* expire watchdog after max window */ .window.min = WDT_MIN_WINDOW, .window.max = WDT_MAX_WINDOW, }; wdt_channel_id = wdt_install_timeout(watchdog_device, &wdt_config); if (wdt_channel_id < 0) { LOG_ERR("failed to install watchdog"); return -1; } } else { LOG_ERR("watchdog device \"%s\" is not ready", watchdog_device->name); } } if (found == false) { LOG_ERR("no watchdog device found"); } return (found ? 0 : (-1)); }
Reset Cause Checking Code:
/* dump reset cause */ hwinfo_get_reset_cause(&reset_cause); if (reset_cause == RESET_LOW_POWER_WAKE) { LOG_INF("reset cause: wakeup"); } else if (reset_cause == RESET_POR) { LOG_INF("reset cause: power"); } else if (reset_cause == RESET_WATCHDOG) { LOG_INF("reset cause: watchdog"); #ifdef WATCHDOG_TEST isWatchdogTestRun = false; // Disable the Watchdog Test after detecting a Watchdog-induced reset #endif } else if (reset_cause == RESET_PIN) { LOG_INF("reset cause: reset pin"); } else if (reset_cause == RESET_SOFTWARE) { LOG_INF("reset cause: software"); } else if (reset_cause == RESET_WATCHDOG) { LOG_INF("reset cause: software reset"); } else { LOG_INF("reset cause 0x%x", reset_cause); }
Expected Behavior:
When the watchdog timeout is exceeded, the system should restart with the reset cause RESET_WATCHDOG
.
Observed Behavior:
Instead, the system restart is being reported as due to RESET_PIN
.
Best regards,
Ben Ron Udi