Task watchdog callback - Printk, Logging and saving to the internal flash not working

Greetings,

I have recently incorporated the Task Watchdog library in our custom application for our custom board based on nRF52840 MCU with success and everything works as expected.

The only issue I have not been able to solve is getting the information on which thread was responsible for a watchdog timeout.

Inside the task watchdog callback I tried printing the information of the log using printk, the logging system (LOG_WRN/INF/DBG) & saving the information in the internal flash so that I can at least retrieve it and print it using the logger after the reset on initialization.

Below a have attached the callback used for all the task watchdog channels.

void task_wdt_callback(int channel_id, void *user_data)
{
	// LOG_INF("Task watchdog channel %d callback, thread: %s",
	// 	channel_id, k_thread_name_get((k_tid_t)user_data));
	printk("Task watchdog channel %d callback, thread: %s\n",
		channel_id, k_thread_name_get((k_tid_t)user_data));

  // ch_id = channel_id;
  // LOG_INF("ch_id: %d", ch_id);

  wdt_state_t state = { .wdt_reboot = true, 
                        .channel_id = channel_id, 
                        .user_data = user_data };
  fs_store_wdt_info( state );

	/*
	 * If the issue could be resolved, call task_wdt_feed(channel_id) here
	 * to continue operation.
	 *
	 * Otherwise we can perform some cleanup and reset the device.
	 */

	printk("Resetting device...\n");
	// LOG_INF("Resetting device...");
  //k_msleep(2000);
	sys_reboot(SYS_REBOOT_COLD);
}
 

Whatever I put inside this callback seems like it is never executed, not even storing the values with the LittleFS system using fs_store_wdt_info (which is already implemented and tested and works great as in many other modules of our custom application, when I retrieve the values from flash on initialization I get irrelevant invalid values).

What could be the problem here?

I have confirmed using the debugger that the callback function is indeed called when simulating a hang in a thread (by inserting an infinite loop in the thread) but seems like the code inside the callback is not running at all.

I look forward to hearing from you with any feedback on what could be causing this.

Thank you!

Best regards,

Stavros

Parents
  • I'm getting the exact same issue, task_wdt_callback is not called.

    Did you managed to solve it?

  • For me it worked correctly, when the correct config options were enabled, even the logging (for the logging enable Imediate logging if the messages don't show up) if I removed any other operation apart from the device reset.

    As mentioned in the verified answer, which was also backed up by the Zephyr Community (Discord)

    I have a feeling that a watchdog is something that should not occur, and if it occurs it is a kind of point of no return, where you can't really allow anything to run (since you don't know what actually caused the watchdog to start with). So I have a feeling this is a conscientious decision and implementation that the only thing allowed is really execute a reset.

    which I have confirmed. The watchdog callback should only reset the device (apart from the logging).

Reply
  • For me it worked correctly, when the correct config options were enabled, even the logging (for the logging enable Imediate logging if the messages don't show up) if I removed any other operation apart from the device reset.

    As mentioned in the verified answer, which was also backed up by the Zephyr Community (Discord)

    I have a feeling that a watchdog is something that should not occur, and if it occurs it is a kind of point of no return, where you can't really allow anything to run (since you don't know what actually caused the watchdog to start with). So I have a feeling this is a conscientious decision and implementation that the only thing allowed is really execute a reset.

    which I have confirmed. The watchdog callback should only reset the device (apart from the logging).

Children
No Data
Related