if WiFi not connected, it crashes after a few loops
Posted: 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.
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.