This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Zephyr Task WDT doesn't cause a system reset, hangs system

Hello, 

I am trying to add a watchdog timer to my code which consists of THREE threads, so I referred to the task_wdt example in Zephyr/Samples/Subsys for SDK1.6.1. 

Based on the example, I initialize the WDT and add a sleep > watchdog time after a count of 50, but instead of calling a wdt callback or system reset, my code just gets stuck into an undefined state. 

My config and my code snippet is given below: 

CONFIG_WATCHDOG=y
CONFIG_WDT_LOG_LEVEL_DBG=y
CONFIG_WDT_DISABLE_AT_BOOT=y

CONFIG_TASK_WDT=y
CONFIG_TASK_WDT_MIN_TIMEOUT=50
CONFIG_TASK_WDT_CHANNELS=5

Code Snippet: 

**********************************************************************************************

int count = 0;
const struct device *hw_wdt_dev = DEVICE_DT_GET(WDT_NODE);

if (!device_is_ready(hw_wdt_dev)) {
printk("Hardware watchdog %s is not ready; ignoring it.\n",
hw_wdt_dev->name);
hw_wdt_dev = NULL;
}
task_wdt_init(hw_wdt_dev);

task_wdt_id = task_wdt_add(100U, task_wdt_callback,
(void *)k_current_get());

while (true) {
if (count == 50) {
printk("Control thread getting stuck...\n");
k_sleep(K_FOREVER);
}

task_wdt_feed(task_wdt_id);
k_sleep(K_MSEC(50));
count++;
}

*********************************************************************************

So here are my questions: 

1. Does the task watchdog work the same way as system watchdog in terms of system reset or does it only kill the thread and lets the system run. 

2. Is there a way to test this is debug mode? Like setting a breakpoint on main() and checking if it hits main() post watchdog firing? 

3. My requirement is that if any thread is stuck for longer than a usual time, I want the system to reboot and restart all threads, am I missing something in config/understanding?  

Related