wdt

kamesh
Posts: 35
Joined: Sat Aug 06, 2016 5:14 am

wdt

Postby kamesh » Tue Dec 27, 2016 7:33 am

Hi,
How to disable wdt in esp32?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: wdt

Postby WiFive » Tue Dec 27, 2016 8:00 am


ESP_Sprite
Posts: 9020
Joined: Thu Nov 26, 2015 4:08 am

Re: wdt

Postby ESP_Sprite » Wed Dec 28, 2016 6:56 am

Also, which wdt? There are two; an interrupt wdt as well as a task wdt. You normally shouldn't have to disable them; if they trigger, in 98% of the time they do it because the design or implementation of your program is wrong. In that case, the wdt is only showing you that something is wrong; disabling it will fix the symptom but not the original issue.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: wdt

Postby kolban » Wed Dec 28, 2016 3:52 pm

Looking at the API docs, we see that the recommended solution is to call esp_task_wdt_feed() to feed the watch dog. I have also seen recipes such as vTaskDelay(1). Are there any pros or cons between these (assuming both work). Is RTOS "taskYIELD" an option as well (http://www.freertos.org/a00020.html#taskYIELD)?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: wdt

Postby WiFive » Wed Dec 28, 2016 4:26 pm

esp_task_wdt_feed() is required for a watched task to feed the watchdog
vTaskDelay will allow other watched tasks including the idle task to run and feed the watchdog
taskYIELD will only allow higher priority tasks to run and feed the watchdog

In general, don't hog the CPU(s)

ESP_Sprite
Posts: 9020
Joined: Thu Nov 26, 2015 4:08 am

Re: wdt

Postby ESP_Sprite » Thu Dec 29, 2016 3:40 pm

Expanded slightly: The task watchdog is capable of, as the name implies, watching tasks. Now, a task needs to elect itself to be watched, that is, it has to tell the task watchdog it will feed it every now and then and there's something weird going on if a task that promised that, doesn't feed the task watchdog. Normally (but this is configurable in menuconfig), the idle tasks will do this: every time they run, they will feed the watchdog. This is useful because if a task with a higher priority is spinning, the idle tasks can't feed the watchdog, and the watchdog will tell you something is wrong.

Now, if you have a thread you expect to do the same thing periodically and something is wrong if it doesn't, you can also elect to have the watchdog watch this thread. You do this by putting esp_task_wdt_feed() in the main loop of the task. The first time the task calls esp_task_wdt_feed(), the task watchdog will register the task as watched, and will expect it to call esp_task_wdt_feed() for the duration of the life of the task. So, calling esp_task_wdt_feed() in a thread randomly does *not* affect the idle threads watchdog timeout message, that will still happen if you starve the idle threads.

faydinp
Posts: 4
Joined: Tue Jun 13, 2017 1:15 pm

Re: wdt

Postby faydinp » Tue Jun 13, 2017 1:42 pm

Hi,

This topic is quite old, but I have the same idle task wdt feed issue.
I created a ble gatt service referring to gatts_demo in esp_idf, and I have a task which calculates some data using digital inputs and sensors. I initialized ble gatt in app_main, and then created a task for calculations as below:

Code: Select all

void app_main()
{
    /* Ble gatts initializations here...*/
    
	xTaskCreate(measurementTask, "measurementTask", 2048, NULL, 5, NULL);
	
	esp_ble_gatts_register_callback(gatts_event_handler);
    	esp_ble_gap_register_callback(gap_event_handler);
    	esp_ble_gatts_app_register(PROFILE_A_APP_ID);
	
    return;
}
Even if I call vTaskDelay in task loop, I get these prints: "Task watchdog got triggered. The following tasks did not feed the watchdog in time".

My questions:
- Does esp_ble_gatts_app_register() function create a thread? or is it a blocking function?
- What is the idle task here?
- How can I feed wdt? Where should I call esp_task_wdt_feed()?
- I tried taskYIELD instead of vTaskDelay in task while loop, result is same. Why?

I'm new to ESP32 and freeRTOS, so forgive me if my questions are silly.

Thanks,

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: wdt

Postby kolban » Tue Jun 13, 2017 4:16 pm

Does the diagnostic message written to serial output contain the identity of which task is being starved?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

faydinp
Posts: 4
Joined: Tue Jun 13, 2017 1:15 pm

Re: wdt

Postby faydinp » Wed Jun 14, 2017 2:16 pm

kolban wrote:Does the diagnostic message written to serial output contain the identity of which task is being starved?
here is the serial output I get:

Code: Select all

Task watchdog got triggered. The following tasks did not feed the watchdog in time:
 - IDLE (CPU 1)
Tasks currently running:
CPU 0: IDLE
CPU 1: speedCalInit
BTW, if I remove BLE init functions in app_main and just keep task create function, the warning disappears.

In addition, if I disable "Task watchdog watches CPU0 idle task" option by menuconfig, the warning disappears as it should be.

many thanks

ESP_Sprite
Posts: 9020
Joined: Thu Nov 26, 2015 4:08 am

Re: wdt

Postby ESP_Sprite » Wed Jun 14, 2017 7:55 pm

What do you do in speedCalInit? Do you happen to spin for multiple seconds without calling a FreeRTOS function which waits for something? If so, then that may be your problem.

Who is online

Users browsing this forum: cdollar, joglz8 and 189 guests