Hey.
I have a problem where the task watchdog times out immediately.
I have taken the samples/basic/task_wdt sample and modified it a bit to simulate what I have in my own code:
int main(void) { int ret; const struct device *const hw_wdt_dev = DEVICE_DT_GET_OR_NULL(WDT_NODE); printk("Task watchdog sample application.\n"); if (!device_is_ready(hw_wdt_dev)) { printk("Hardware watchdog not ready; ignoring it.\n"); } ret = task_wdt_init(NULL); if (ret != 0) { printk("task wdt init failure: %d\n", ret); return 0; } /* passing NULL instead of callback to trigger system reset */ int task_wdt_id = task_wdt_add(1100U, NULL, NULL); while (true) { printk("Main thread still alive...\n"); task_wdt_feed(task_wdt_id); k_sleep(K_MSEC(1000)); } return 0; }
CONFIG_LOG=y CONFIG_LOG_MODE_IMMEDIATE=y CONFIG_WATCHDOG=y CONFIG_TASK_WDT=y CONFIG_THREAD_NAME=y CONFIG_TASK_WDT_HW_FALLBACK=n
In main i have made the change that im not parsing the hw_wdt_dev to task_wdt_init as the hw watchdog is setup later im my code.
And in the config i have disabled CONFIG_TASK_WDT_HW_FALLBACK.
I can see that the callback is called immediately. But if i change next_timeout = INT64_MAX to next_timeout = INT64_MAX - 0x0f in task_wdt.c then all of a sudden stuff starts to work.
static void schedule_next_timeout(int64_t current_ticks)
{
uintptr_t next_channel_id; /* channel which will time out next */
int64_t next_timeout; /* timeout in absolute ticks of this channel */
#ifdef CONFIG_TASK_WDT_HW_FALLBACK
next_channel_id = TASK_WDT_BACKGROUND_CHANNEL;
next_timeout = current_ticks +
k_ms_to_ticks_ceil64(CONFIG_TASK_WDT_MIN_TIMEOUT);
#else
next_channel_id = 0;
next_timeout = INT64_MAX - 0x0f;
#endif
What can be the problem?