(solved) WDT triggered with addition of empty function

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

(solved) WDT triggered with addition of empty function

Postby mzimmers » Fri Oct 15, 2021 3:04 am

Hi all -

I've been fighting this problem for days, and am out of ideas.

I am porting an app that is currently running, when a certain code passage looks like this:

Code: Select all

#if 0 // mzimmers
    MCP7940_Init();
(I use the #if 0 to disable sections that I haven't finished yet.)

But if I enable this function, like this:

Code: Select all

    MCP7940_Init();
#if 0 // mzimmers
I trigger the WDT. This function is currently set to return immediately:

Code: Select all

void MCP7940_Init(void){
return;
    SI2C_Initialize();
    MCP7940_Enable24Hour(true);
    MCP7940_EnableBattery(true);
    MCP7940_StartClock();
}
So, for the life of me, I can't see how this is changing processing that could affect the WDT.

Can anyone think of what's going on here?

Thanks...

Oh, in case anyone is interested in the console output:

Code: Select all

E (6153) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (6153) task_wdt:  - IDLE (CPU 1)
E (6153) task_wdt: Tasks currently running:
E (6153) task_wdt: CPU 0: IDLE
E (6153) task_wdt: CPU 1: IDLE
E (6153) task_wdt: Print CPU 0 (current core) backtrace


Backtrace:0x400EA10F:0x3FFB0B800x40082B29:0x3FFB0BA0 0x4015237B:0x3FFBD040 0x400D397A:0x3FFBD060 0x4008A74D:0x3FFBD080 0x4008C38D:0x3FFBD0A0 
0x400ea10f: task_wdt_isr at /home/mzimmers/esp/esp-idf/components/esp_system/task_wdt.c:191 (discriminator 3)

0x40082b29: _xt_lowint1 at /home/mzimmers/esp/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1111

0x4015237b: cpu_ll_waiti at /home/mzimmers/esp/esp-idf/components/hal/esp32/include/hal/cpu_ll.h:183
 (inlined by) esp_pm_impl_waiti at /home/mzimmers/esp/esp-idf/components/esp_pm/pm_impl.c:838

0x400d397a: esp_vApplicationIdleHook at /home/mzimmers/esp/esp-idf/components/esp_system/freertos_hooks.c:63

0x4008a74d: prvIdleTask at /home/mzimmers/esp/esp-idf/components/freertos/tasks.c:3959 (discriminator 1)

0x4008c38d: vPortTaskWrapper at /home/mzimmers/esp/esp-idf/components/freertos/port/xtensa/port.c:159
Last edited by mzimmers on Tue Nov 02, 2021 6:20 pm, edited 1 time in total.

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

Re: WDT triggered with addition of empty function

Postby ESP_Sprite » Fri Oct 15, 2021 3:46 am

That is a very odd watchdog timeout message... it basically says that the idle process is not running because both CPUs are running the idle process. No idea why an empty function can do that, but my guess is that you have an error somewhere else (e.g. a spurious write that overwrites some FreeRTOS memory?) that results in 'undefined behaviour' which is dependent on variable and program code placement, and the empty function happens to tickle that problem in just the right way to lead what you're seeing here.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: WDT triggered with addition of empty function

Postby mzimmers » Fri Oct 15, 2021 3:49 am

Hi Sprite -

I'm not ruling out the error occurring somewhere else, but...it only manifests when I enable that function.

EDIT: I've done some more looking at this, and the problem doesn't occur if I disconnect all the peripherals (LEDs, buttons, etc.) How these connections could result in a WDT trigger doesn't make sense to me, though.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: WDT triggered with addition of empty function

Postby mzimmers » Tue Nov 02, 2021 6:20 pm

I think I discovered the problem, and the reason for the odd reporting of the WDT trigger. The trigger was indeed caused by a tight loop in my main task, but I'm guessing that because I hadn't registered the task with the WDT, the trigger wasn't being reported correctly.

To experiment, I called esp_task_wdt_add() for the main task, and the reporting "blamed" the main task, not Idle, for the trigger. I found the problem and fixed it, and removed the call to esp_task_wdt_add(). All seems well now.

Who is online

Users browsing this forum: No registered users and 257 guests