SW_RESET... Reason I am not able to figure out Please help

paras99
Posts: 11
Joined: Tue Nov 17, 2020 11:46 am

SW_RESET... Reason I am not able to figure out Please help

Postby paras99 » Thu Mar 25, 2021 2:37 pm

This is my backtrace decoded ... What is happening and How to analyze if something like this happens in future

Code: Select all

Decoding stack results
0x4008c434: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 155
0x4008c665: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 170
0x40088869: xQueueGenericReceive at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c line 1442
0x400d2aab: ledcWrite at C:\Users\paras\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\cores\esp32\esp32-hal-ledc.c line 193
0x400d11f2: Task1code(void*) at C:\Users\paras\Documents\Arduino\mtask/mtask.ino line 186
0x40088b7d: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

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

Re: SW_RESET... Reason I am not able to figure out Please help

Postby ESP_Sprite » Fri Mar 26, 2021 2:24 am

You read these things from the bottom up. Seems you started a task (as the stack trace starts with vPortTaskWrapper) called Task1code. This task then called into ledcWrite(), which internally called xQueueGenericReceive(). The xQueueGenericReceive() did not like the parameters it was passed or something so it called abort(), leading to the panic.

Functions like xQueueGenericReceive mostly panic if the queue they're given is corrupted or not initialized. Possibly ledcWrite was invoked before the ledc was initialized? (For instance, do you initialize it in your main task *after* starting Task1code?)

paras99
Posts: 11
Joined: Tue Nov 17, 2020 11:46 am

Re: SW_RESET... Reason I am not able to figure out Please help

Postby paras99 » Sat Mar 27, 2021 9:59 am

You were 100% correct i moved the ledcSetup block inside the task and it solved the issue ,

but I had declared ledcSetup in setup() [PS. I am writing code in Arduino IDE] how this didn't execute then , is the priority of setup() low ?

How did you analyze the error ? Is there any kind of resources or material that I should I refer before moving on to FreeRTOS ?

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

Re: SW_RESET... Reason I am not able to figure out Please help

Postby ESP_Sprite » Mon Mar 29, 2021 3:04 am

how this didn't execute then , is the priority of setup() low ?
Arduino is supposed to run setup() before running loop(), that's about all I know. The thing is, however, that as soon as you start a task, it's not guaranteed when it will actually run. The entire task may already have executed thousands of line of code before the routine that started it up exited, or the OS may decide that running that task is so unimportant that it won't get around to it until some thousands of lines of code in your setup() routine have run. Not sure if that was the cause of your issue, but keep that in mind when using tasks.

Who is online

Users browsing this forum: No registered users and 73 guests