Configuring WDT causes reboot during FOTA

Hello,

I am writing an application based in nrf1.9.1 in a nrf9160 based board.

AWS FOTA is working fine.

I recently added a watchdog for the application, following this steps:

- Initialize the watchdog

- Configure a channel with a generous timeout (for testing purposes 100s)

- I feed the watchdog in a loop that is running in the main thread every 100ms

The application works fine but as soon as I try a FOTA update the application reboots after a few seconds, not completing the FOTA download. If I comment out the code that configures the watchdog channel (leving the the watchdog init intact) the FOTA works correctly.

Initi of the watchdog is done like this:

int watchdog_init() {
	int ret;
	const struct device *hw_wdt_dev = DEVICE_DT_GET(WDT_NODE);

	LOG_DBG("Task watchdog init.\n");

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

	ret = task_wdt_init(hw_wdt_dev);
	if (ret != 0) {
		LOG_ERR("task wdt init failure: %d\n", ret);
		return ret;
	}
    return 0;
}

Configuration of the channel:

    char *wdt_msg="motion";
    uint32_t wdt_timeout = MOTION_THRESH_DETECT_DELAY_MS*1000U;
    LOG_DBG("Configuring watchdog %s with timeout %dms",wdt_msg,wdt_timeout);
    motion_thresh_detect_wdt_id = task_wdt_add(wdt_timeout, &reboot_callback_wdt, (void *)wdt_msg);

Feeding of the watchdog:

task_wdt_feed(motion_thresh_detect_wdt_id);

Callback function when the watchdog is triggered:

void reboot_callback_wdt(int channel_id, void *user_data)
{
	//Needs to be a quick operation (32k ticks?)
	printk("------>WATCHDOG REBOOT: Task watchdog channel %d callback, thread: %s\n",
		channel_id, (char *)user_data);
}

Parents Reply
  • XavierN said:
    When you say "toggle a gpio in the watchdog feed function" you mean to modify the "task_wdt_feed" function in task_wdt.c?

    or pull high a gpio before and low after your application calls task_wdt_feed. Just want to know the timings of this being called before the reset happens.

    XavierN said:
    I also observed that the watchdog callback function (which right now it's just a printk) is not bing called while if i just configure the timeout in the wdt short enough for it to trigger it does get called.

    Dealing with printks on a serial output might be a tricky thing when you are dealing with logs before system would reset. I recommend you to use RTT logging just for testing.

Children
  • I am using the latest SDK2.2.0 now and still experiencing this same issue where if i use the Hardware WDT and try and perform a FOTA

    if i initialize the wdt with no hardware backup 

     task_wdt_init(NULL);
    it works fine but if i add the hardware wdt then as soon as i perform FOTA it crashes as XavierN says.. this quite a big issue, as i have noticed there are certain scenarios where the device can lockup and the task WDTs do not help.. so kind of need to use the hardware WDT and i also need the ability to perform FOTA.. is this in the timeline to get fixed anytime soon? 
Related