gpearcey / NMEA_CAN_ctrl

MIT License
0 stars 0 forks source link

Task Watchdog triggered when sending a lot of fast packet messages in a row #14

Open gpearcey opened 1 year ago

gpearcey commented 1 year ago

Was triggered multiple times for 100 messages of length 134.

gpearcey commented 1 year ago

Also got triggered when I tried the NMEA2000 Switch bank example every few seconds

`E (10331) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time: E (10331) task_wdt: - IDLE (CPU 1) E (10331) task_wdt: Tasks currently running: E (10331) task_wdt: CPU 0: IDLE E (10331) task_wdt: CPU 1: N2K_task E (10331) task_wdt: Print CPU 1 backtrace

Backtrace: 0x4008449E:0x3FFB1320 0x40082875:0x3FFB1340 0x400D92C9:0x3FFB63E0 0x400DAB46:0x3FFB6510 0x400D60F1:0x3FFB6540 0x40088425:0x3FFB6570 0x4008449e: esp_crosscore_isr at /home/gracepearcey/repos/esp_5-0-2/esp-idf/components/esp_system/crosscore_int.c:96

0x40082875: _xt_lowint1 at /home/gracepearcey/repos/esp_5-0-2/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_vectors.S:1118

0x400d92c9: tNMEA2000::SendHeartbeat(bool) at /home/gracepearcey/repos/esp_5-0-2/NMEA2000_switchbank_example_esp-idf/components/NMEA2000/src/NMEA2000.cpp:1347

0x400dab46: tNMEA2000::ParseMessages() at /home/gracepearcey/repos/esp_5-0-2/NMEA2000_switchbank_example_esp-idf/components/NMEA2000/src/NMEA2000.cpp:2565 (discriminator 4)

0x400d60f1: N2K_task(void*) at /home/gracepearcey/repos/esp_5-0-2/NMEA2000_switchbank_example_esp-idf/components/my_N2K_lib/my_N2K_lib.cpp:215 (discriminator 1)

0x40088425: vPortTaskWrapper at /home/gracepearcey/repos/esp_5-0-2/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:154 `

gpearcey commented 1 year ago

Watch dog is triggerred anytime there are tight loops that "starve" the idle tasks that feed the watch dog. Setting task priority to the idle task priority stops the watch dog from being triggered. I don't know if this is a good solution. Another option is to disable watchdog.

gpearcey commented 1 year ago

Alternate Solution

gpearcey commented 1 year ago

Looks helpful: https://barrgroup.com/embedded-systems/how-to/advanced-watchdog-timer-tips

gpearcey commented 1 year ago

Free RTOS tasks were starving watchdog, adding a delay did not do anything. I combined reads and writes because NMEA2000 lib is set up for that. It goes in a send and listen mode. To fix the issue I put the task priority to the same priority as the idle task (keeps watchdog from triggering) and it was okay. Don't know if this is the best solution but can do more reading. If I have 3 tasks (one for each controller) and they are a higher priority than the idle tasks, and they are always ready, a yield, or a delay will call the other task. I don't think I can explicitly yield to idle task.