Task WD seems useless

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Task WD seems useless

Postby fly135 » Mon Sep 17, 2018 8:33 pm

I want to put a task WD in my project that as a last ditch effort will reboot the device if the supervising task is hung. But the Task WD API doesn't seem to support any functionality by the application other than a print out which is nice for newbie level debug, but not very useful. There is one short reference to a handler, but the API doesn't support installing a handler. Yes, I can look through the source, but I'm curious why the task WD seems like a half implemented feature.

John A

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Task WD seems useless

Postby fly135 » Mon Sep 17, 2018 9:04 pm

I looked through the source and it appears that the "esp_task_wdt_isr_user_handler" feature is not supported at all. It appears that there is little more that can be done except disabling the idle task WD, setting the panic flag, and just enabling the WD for the task in question.

John A

tommeyers
Posts: 184
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

Re: Task WD seems useless

Postby tommeyers » Mon Sep 17, 2018 9:58 pm

https://github.com/espressif/arduino-es ... gTimer.ino

can you do that?

Depending upon the requirements a more or less hw/sw independent timer is needed; how independent do you need? hw:555? timer in c; processor #2 or #3? all 3 are easy.

Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Task WD seems useless

Postby fly135 » Mon Sep 17, 2018 10:11 pm

tommeyers wrote:can you do that?
I'm not using Arduino, but I could use the IDF timer routines to accomplish the same thing. Thanks for the suggestion.

John A

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Task WD seems useless

Postby fly135 » Mon Sep 17, 2018 10:54 pm

tommeyers wrote:can you do that?
Just to let you know I used the timer technique. That allowed me to implement a long period WD and I can still keep the idle task WD just to detect any weirdness that might pop up. Erasing memory for an OTA triggers the idle WD.

John A

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Task WD seems useless

Postby ESP_Angus » Tue Sep 18, 2018 12:24 am

fly135 wrote:I want to put a task WD in my project that as a last ditch effort will reboot the device if the supervising task is hung.
If you call esp_task_wdt_init() with the panic argument set to true, the task WDT will trip the IDF "panic handler" if it is triggered.

The default configuration for the panic handler is to dump a backtrace and then reset the system.

Does that achieve your goal?
fly135 wrote:I looked through the source and it appears that the "esp_task_wdt_isr_user_handler" feature is not supported at all.
This feature was added recently, so if you're reading the "latest" documentation then it may refer to things which aren't in older ESP-IDF versions.

The "weak linked" implementation is here:
https://github.com/espressif/esp-idf/bl ... wdt.c#L121

If you implement a function with this name (without the "__attribute__((weak))") in a source file of your project, it will become the handler. The only requirement is that this source file must get linked into the project - this means that the function has to be in a source file which also has some other thing (function, variable) which is used by the project (ie the app_main() routine, or a function which is called from somewhere, etc). Otherwise the linker may never look in the object file at all, and doesn't see the replacement handler to link it.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: Task WD seems useless

Postby loboris » Tue Sep 18, 2018 6:19 am

ESP_Angus wrote:
fly135 wrote:If you implement a function with this name (without the "__attribute__((weak))") in a source file of your project, it will become the handler. The only requirement is that this source file must get linked into the project - this means that the function has to be in a source file which also has some other thing (function, variable) which is used by the project (ie the app_main() routine, or a function which is called from somewhere, etc). Otherwise the linker may never look in the object file at all, and doesn't see the replacement handler to link it.
It could be useful to move if the whole logging part part ("Task watchdog got triggered. ...") in the task_wdt_isr to the default esp_task_wdt_isr_user_handler.
That way the user could chose not to print the log messages, but only to take some other acction.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Task WD seems useless

Postby fly135 » Tue Sep 18, 2018 2:13 pm

ESP_Angus wrote:Does that achieve your goal?
I had my mind wrapped around using the callback, so saying the WD seems useless was a bit knee jerk. The panic option does achieve the goal.
ESP_Angus wrote:This feature was added recently, so if you're reading the "latest" documentation then it may refer to things which aren't in older ESP-IDF versions.
OK, that explains it. I'm working with v3.1 release.

John A

Who is online

Users browsing this forum: No registered users and 108 guests