if WiFi not connected, it crashes after a few loops

zhenghaku
Posts: 8
Joined: Thu Jul 16, 2020 11:00 am

if WiFi not connected, it crashes after a few loops

Postby zhenghaku » Tue Mar 22, 2022 1:06 pm

I got an application that calls WiFi.begin(ssid, password); and tries to connect to an known AP. Then, no matter if the WiFi is connected or not, another work thread is started. This thread has nothing to do with WiFi.

The work thread will just loop 4-7 time before the ESP32 crashes.

I use xTaskCreate to create the work thread (extremely simple with 1s delay), and checked the work thread is running on core 0. I have read some say that the wifi runs on core 0, so if you have some work, don't put it on core 0. So I use xTaskCreatePinnedToCore to pin the work thread on core 1. But nothing changed. I have played with the stack size, It made no difference.

BUT, when the WiFi did connect to the AP, it does not crash, when the AP is not there it crashes. When everything runs ok , I turned of the AP, it crashes.

The work thread does not use anything even remotely related to network. When I commented out of a line the access a buffer (small) allocated by me in the work thread, it does not crash.

Very very weird behavior. Please help. :D

zhenghaku
Posts: 8
Joined: Thu Jul 16, 2020 11:00 am

Re: if WiFi not connected, it crashes after a few loops

Postby zhenghaku » Wed Mar 23, 2022 4:17 am

I also ruled out the power issue, by powering the board with a smartphone charger.
I even changed a board, it still crashed.

The stack trace decoder gives:

Code: Select all

Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x4009006e  PS      : 0x00060433  A0      : 0x8008f208  A1      : 0x3ffb3850
A2      : 0x3ffafe6c  A3      : 0x3ffb9064  A4      : 0x00060423  A5      : 0x000000fe
A6      : 0x00000001  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x3ffafe74
A10     : 0x00000001  A11     : 0x00000005  A12     : 0x3ffb99f8  A13     : 0x00000000
A14     : 0x00000000  A15     : 0x00000000  SAR     : 0x00000010  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x40089768  LEND    : 0x4008977e  LCOUNT  : 0xffffffff

ELF file SHA256: 0000000000000000

Backtrace: 0x4009006b:0x3ffb3850 0x4008f205:0x3ffb3870 0x4008d37c:0x3ffb3890 0x400e7df1:0x3ffb38d0 0x40123e92:0x3ffb38f0 0x401191ad:0x3ffb3910 0x4014cac3:0x3ffb3930 0x40198de7:0x3ffb3960 0x4019897f:0x3ffb3990 0x40198a51:0x3ffb39d0 0x4008d575:0x3ffb39f0
  #0  0x4009006b:0x3ffb3850 in vListInsert at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/list.c:188
  #1  0x4008f205:0x3ffb3870 in vTaskPlaceOnEventList at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:2901 (discriminator 2)
  #2  0x4008d37c:0x3ffb3890 in xQueueGenericReceive at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:1596
  #3  0x400e7df1:0x3ffb38d0 in semphr_take_wrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/esp_adapter.c:267
  #4  0x40123e92:0x3ffb38f0 in ieee80211_ioctl at ??:?
  #5  0x401191ad:0x3ffb3910 in esp_wifi_internal_reg_rxcb at ??:?
  #6  0x4014cac3:0x3ffb3930 in handle_sta_disconnected at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/tcpip_adapter/event_handlers.c:197
  #7  0x40198de7:0x3ffb3960 in handler_execute at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_event/esp_event.c:145
  #8  0x4019897f:0x3ffb3990 in esp_event_loop_run at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_event/esp_event.c:553 (discriminator 3)
  #9  0x40198a51:0x3ffb39d0 in esp_event_loop_run_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_event/esp_event.c:115
  #10 0x4008d575:0x3ffb39f0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:143

Who is online

Users browsing this forum: No registered users and 82 guests