WiFi stops working after RESET

Eric_AMIG
Posts: 1
Joined: Mon May 31, 2021 7:31 pm

WiFi stops working after RESET

Postby Eric_AMIG » Wed Jun 02, 2021 10:58 pm

Hi!

TL:DR; My ESP32 fails to connect to any WiFi AP after reset (the same profiles would work before that reset). It remains not connecting on further resets or flashing the program again, and is only fixed after an 'idf.py erase_flash' command.

I have an application where the ESP32 connects to a hard-coded profile upon first boot, then downloads configuration data, including new SSID and password. After that, it connects with these settings and realizes other tasks. On the first boot, it works correctly but after the first reset (whatever the cause), it wont connect to the AP at all. This will continue even if I flash the firmware again. Only erasing the flash and loading the program again will work. If there are no resets, the application will work correctly as long as I've observed.

So far I've determined that the saved credentials are not corrupted. No error messages displayed. There is though one main difference between the behaviour on the first boot and the further ones: the ESP32 verbose mode indicates the following:

- First boot (correct behaviour):
Between the 'esp_wifi_connect()' and the checkConnection() calls (that monitors the WIFI_CONNECTED_BIT and WIFI_FAIL_BIT from the events handler), I see two wifi stop events and a wifi start event. In that order.

- Subsequent boots:
In the same section, I see a start event and two stop events.

The code is the same. I've tried enabling and disabling NVS WiFi config save in the menuconfig tool, I see no effect.

Thanks in advance!

PS: Let me know if you need any type of info. This is a project with several hundreds lines of code, but I attach the two calls in between the strange behaviour happens:

Code: Select all

    // Se conecta a la red WIFI
    int wifiErrormsg = esp_wifi_connect();
    printf("Codigo de error de ESP WiFi: %d\n",wifiErrormsg);
    if( wifiErrormsg  != ESP_OK ) {
        printf("[SYSTEM][ERROR]: Ocurrio un error en el driver al conectarse a la red WIFI, reiniciando...\n");
        fflush(stdout);
        esp_restart();
    }

    printf("A punto de comprobar la conexion WiFi\n");
    // Comprueba la conexion
    if( !checkConnection(true) ) {
        return false;
    }
And this is the serial print, mixing our own debug info with the ESP verbose:
V (15967) esp_netif_objects: esp_netif_next_unsafe 0x0
I (15967) wifi:V (15977) esp_netif_objects: esp_netif_next_unsafe 0x3ffcb8f0
flush txq
I (15987) wifi:stop sw txq
V (15987) esp_netif_lwip: esp_netif_is_netif_up esp_netif:0x3ffcb8f0
I (15987) wifi:D (15987) esp_netif_lwip: call api in lwip: ret=0x0, give sem
lmac stop hw txq
D (15997) ADC: Wi-Fi returns adc2 lock.
[DEBUG][WIFI]: Setting profile 3
[DEBUG][PRIVATE]: ---> With SSID: *******
[DEBUG][PRIVATE]: ---> With KEY: *******
[DEBUG][PRIVATE]: ---> With BSSID: NULL
D (16007) event: running post WIFI_EVENT:2 with handler 0x40083010 and context 0x3ffcbc4c on loop 0x3ffc80d4
0x40083010: wifiEventHandler at c:\********\build/../components/controllers/wifi_controller/wifi_controller.cpp:30

V (16017) esp_adapter: thread sem get: sem=0x3ffd1c24
WiFi Debug: It is WiFi Event, with ID 2
V (16037) esp_adapter: thread sem get: sem=0x3ffd1c24
D (16037) event: running post WIFI_EVENT:3 with handler 0x400f41f4 and context 0x3ffcbb44 on loop 0x3ffc80d4
0x400f41f4: wifi_start at C:/*******/esp-idf/components/esp_wifi/src/wifi_default.c:52 (discriminator 9)

D (16047) ADC: Wi-Fi takes adc2 lock.
D (16057) esp_netif_handlers: esp_netif action stopped with netif0x3ffcb8f0 from event_id=3
D (16067) phy_init: loading PHY init data from application binary
D (16077) esp_netif_lwip: check: remote, if=0x3ffcb8f0 fn=0x400ed838
0x400ed838: esp_netif_up_api at C:/*********/esp-idf/components/esp_netif/lwip/esp_netif_lwip.c:1134


D (16077) esp_netif_lwip: call api in lwip: ret=0x5002, give sem
I (16077) wifi:mode : sta (**:**:**:**:**)
V (16087) esp_adapter: thread sem get: sem=0x3ffd1c24
D (16087) event: running post WIFI_EVENT:3 with handler 0x40083010 and context 0x3ffcbc4c on loop 0x3ffc80d4
0x40083010: wifiEventHandler at c:\*******\build/../components/controllers/wifi_controller/wifi_controller.cpp:30

WiFi Debug: It is WiFi Event, with ID 3
Error code from ESP WiFi: 0
D (16107) event: running post WIFI_EVENT:2 with handler 0x400f4328 and context 0x3ffcbb1c on loop 0x3ffc80d4
0x400f4328: create_and_attach at C:/*******/esp-idf/components/esp_wifi/src/wifi_default.c:270

About to verify WiFi connection
D (16117) wifi_init_default: wifi_start esp-netif:0x3ffcb8f0 event-id2
Error bit
D (16127) wifi_init_default: WIFI mac address: ** ** ** ** **
[DEBUG][NOTICE]: Not connected
[DEBUG][PRIVATE]: Could not connect to SSID: *****
V (16147) esp_adapter: thread sem get: sem=0x3ffd68ac

kylevest
Posts: 1
Joined: Thu Jan 12, 2023 8:27 pm

Re: WiFi stops working after RESET

Postby kylevest » Thu Jan 12, 2023 8:29 pm

I am having same issue. Did you ever figure this out?

Alberk
Posts: 50
Joined: Sat Jun 19, 2021 1:49 am

Re: WiFi stops working after RESET

Postby Alberk » Fri Jan 13, 2023 10:02 am

Have you tried to reboot the AP/Router?

Who is online

Users browsing this forum: TobiasUhmann and 138 guests