Page 1 of 2

wdt

Posted: Tue Dec 27, 2016 7:33 am
by kamesh
Hi,
How to disable wdt in esp32?

Re: wdt

Posted: Tue Dec 27, 2016 8:00 am
by WiFive

Re: wdt

Posted: Wed Dec 28, 2016 6:56 am
by ESP_Sprite
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.

Re: wdt

Posted: Wed Dec 28, 2016 3:52 pm
by kolban
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)?

Re: wdt

Posted: Wed Dec 28, 2016 4:26 pm
by WiFive
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)

Re: wdt

Posted: Thu Dec 29, 2016 3:40 pm
by ESP_Sprite
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.

Re: wdt

Posted: Tue Jun 13, 2017 1:42 pm
by faydinp
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,

Re: wdt

Posted: Tue Jun 13, 2017 4:16 pm
by kolban
Does the diagnostic message written to serial output contain the identity of which task is being starved?

Re: wdt

Posted: Wed Jun 14, 2017 2:16 pm
by faydinp
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

Re: wdt

Posted: Wed Jun 14, 2017 7:55 pm
by ESP_Sprite
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.