espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.62k stars 7.28k forks source link

[WiFiGeneric.cpp:715] espWiFiStart(): esp_wifi_start 257 (IDFGH-8777) #10209

Closed kraa965 closed 1 year ago

kraa965 commented 1 year ago

when starting wi-fi in STA mode, it tries to connect, but freezes, tell me, what could be the problem?

Xiehanxin commented 1 year ago

hello, @kraa965, can you provide more details? like whic which chip, the IDF version and the error log

kraa965 commented 1 year ago

hello, @kraa965, can you provide more details? like whic which chip, the IDF version and the error log

Chip: esp32dev IDF: 4.4.2 Error: espWiFiStart(): esp_wifi_start 257

I uploaded the access point data to the wificonfig.json file, the data is read, but when they get into wifi.begin(witiconfig.ssid, wificonfig.password), the espWiFiStart() error appears: esp_wifi_start 257, and a hang occurs

Xiehanxin commented 1 year ago

I have checked the error code in ESP arduino and the 257, which is 0x101, means out of memory, you can checkout your remain memory when you start the wifi, and if you try the STA example, can you connect to the AP? image

kraa965 commented 1 year ago

I have checked the error code in ESP arduino and the 257, which is 0x101, means out of memory, you can checkout your remain memory when you start the wifi, and if you try the STA example, can you connect to the AP?

@Xiehanxin I'm running in sta mode, yesterday I found that it was a lack of memory, I tried to work with partitions, but it didn't work out, I need partitions for spiffs and the code itself, but I'm new to this, can you tell me how to correctly calculate the necessary partitions and how to fill them correctly? I use huge_app.csv, but it is not enough


I calculated the memory it turned out like this

Name, Type, SubType, Offset, Size, Flags

nvs, data, nvs, 0x9000, 0x7000, app0, app, ota_0, 0x10000, 0x200000, spiffs, data, spiffs, 0x210000,0x1F0000,

but now this error occurs, I used to fix it with TFT_eSPI v2.3.70, and now it has reappeared, I don't know how to fix it Do you have any suggestions?

Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump: PC : 0x401bad91 PS : 0x00060130 A0 : 0x801bc512 A1 : 0x3fff9ca0 A2 : 0x00000000 A3 : 0x3ffd26ec A4 : 0x3ffd4460 A5 : 0x00000000
A6 : 0x3ffd26d4 A7 : 0x00000000 A8 : 0x801bad89 A9 : 0x3fff9c30
A10 : 0x3ffbdee8 A11 : 0x3ffc0c34 A12 : 0x00000002 A13 : 0x3f43c7e3
A14 : 0x00000001 A15 : 0x00000000 SAR : 0x0000001c EXCCAUSE: 0x0000001c
EXCVADDR: 0x0000002c LBEG : 0x40090e39 LEND : 0x40090e5b LCOUNT : 0xffffffff

Backtrace:0x401bad8e:0x3fff9ca00x401bc50f:0x3fff9d00 0x401c050d:0x3fff9d30 0x401c152c:0x3fff9d50 0x401c0050:0x3fff9d80 0x4020a4f1:0x3fff9da0

0 0x401bad8e:0x3fff9ca0 in ieee80211_hostap_attach at ??:?

1 0x401bc50f:0x3fff9d00 in wifi_softap_start at ??:?

2 0x401c050d:0x3fff9d30 in _do_wifi_start at ??:?

3 0x401c152c:0x3fff9d50 in wifi_set_mode_process at ??:?

4 0x401c0050:0x3fff9d80 in ieee80211_ioctl_process at ??:?

5 0x4020a4f1:0x3fff9da0 in ppTask at ??:?

kraa965 commented 1 year ago

I was able to achieve a little success, now at least it does not crash when starting wifi, but I still get an error

E (24441) wifi:Expected to init 4 rx buffer, actual is 3 [ 23763][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 E (24449) wifi:Expected to init 4 rx buffer, actual is 0 [ 23771][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 [ 23772][E][WiFiSTA.cpp:227] begin(): STA enable failed! E (29464) wifi:Expected to init 4 rx buffer, actual is 0 [ 28786][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 E (29471) wifi:Expected to init 4 rx buffer, actual is 0 [ 28793][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 [ 28796][E][WiFiAP.cpp:141] softAP(): enable AP first!

updated the sections, now it looks like this

Name, Type, SubType, Offset, Size, Flags

app0, app, ota_0, 0x10000, 2M,
nvs, data, nvs, , 400K,
spiffs, data, spiffs, , 1500K,

can you tell me what else I need to fix so that wi-fi starts running?

Xiehanxin commented 1 year ago

hi @kraa965 , I'm not sure what exact memory you need, but it seems you even don't have the enough memory for RX buffer, you can print the remain memory when you start the wifi? you can use ESP.getMinFreeHeap or esp_get_minimum_free_heap_size() at when you start wifi to get it. and what's more, your log show the enable AP first, dou you use the AP function at the same time?

kraa965 commented 1 year ago

hi @Xiehanxin the ESP.getMinFreeHeap function shows

[INFO] BLE Keyboard action received: 11 1 Free Heap before wifi launch: 71620 E (43743) wifi:Expected to init 4 rx buffer, actual is 3 [ 43067][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 E (43752) wifi:Expected to init 4 rx buffer, actual is 0 [ 43075][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 10 8 6 4 2 E (46277) wifi:Expected to init 4 rx buffer, actual is 0 [ 45600][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 E (46284) wifi:Expected to init 4 rx buffer, actual is 0 [ 45607][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 [ 45609][E][WiFiAP.cpp:141] softAP(): enable AP first! [WARNING]: Could not connect to AP, so started as AP.

the esp_get_minimum_free_heap_size() function shows

[INFO] BLE Keyboard action received: 11 1 Free Heap before wifi launch: 53528 E (19188) wifi:Expected to init 4 rx buffer, actual is 3 [ 18512][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 E (19197) wifi:Expected to init 4 rx buffer, actual is 0 [ 18520][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 [ 18521][E][WiFiSTA.cpp:227] begin(): STA enable failed! Free Heap after starting wifi: 53528 startWifiStation(): attempts = 10 startWifiStation(): attempt delay = 500 10 8 6 4 2 E (21722) wifi:Expected to init 4 rx buffer, actual is 0 [ 21045][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 E (21729) wifi:Expected to init 4 rx buffer, actual is 0 [ 21052][E][WiFiGeneric.cpp:678] wifiLowLevelInit(): esp_wifi_init 257 [ 21054][E][WiFiAP.cpp:141] softAP(): enable AP first! [WARNING]: Could not connect to AP, so started as AP.

and what's more, your log show the enable AP first, dou you use the AP function at the same time?

I have BLE running all the time, when I click on the screen, BLE stops and the access point with the web server starts

CODE:

bool startWifiStation()
{
    MSG_INFO1("startWifiStation(): Connecting to", wificonfig.ssid);
    if (String(WiFi.SSID()) != String(wificonfig.ssid)) {
        MSG_DEBUG1("Free Heap before wifi launch:", freeheap);
        WiFi.mode(WIFI_STA);
        MSG_INFO2("startWifiStation(): ssid, pwd=", wificonfig.ssid, wificonfig.password);
        WiFi.begin(wificonfig.ssid, wificonfig.password);
        MSG_DEBUG1("Free Heap after starting wifi:", freeheap);
        uint8_t attempts = wificonfig.attempts;
        MSG_DEBUG1("startWifiStation(): attempts =", attempts);
        MSG_DEBUG1("startWifiStation(): attempt delay =", wificonfig.attemptdelay);
        while (WiFi.status() != WL_CONNECTED) {
            if (attempts == 0) {
                WiFi.disconnect();
                MSG_INFOLN("");
                return false;
            }
            delay(wificonfig.attemptdelay);
            MSG_INFO(".");
            MSG_DEBUG1("", attempts--);
            attempts--;
        }
    }

    // Delete the task bleKeyboard had create to free memory and to not interfere with AsyncWebServer
    bleKeyboard.end();

    // Stop BLE from interfering with our WIFI signal
    btStop();
    esp_bt_controller_disable();
    esp_bt_controller_deinit();
    esp_bt_controller_mem_release(ESP_BT_MODE_BTDM);

    MSG_INFOLN("");
    MSG_INFOLN("[INFO] BLE Stopped");
    MSG_INFO("[INFO] Connected! IP address: ");
    MSG_INFOLN(WiFi.localIP());

    MDNS.begin(wificonfig.hostname);
    MDNS.addService("http", "tcp", 80);

    // Set pageNum to 7 so no buttons are displayed and touches are ignored
    pageNum = WEB_REQUEST_PAGE;

    // Start the webserver
    webserver.begin();
    MSG_INFOLN("[INFO] Webserver started");
    return true;
}
Xiehanxin commented 1 year ago

hi @kraa965 sorry for late reply, I think it is caused that your BLE running all the time which take too much memory. can you provide your sdkconfig? maybe you divide much resource to the wifi, what's more, you can use esp_get_free_internal_heap_size to get internal free heap which is allocated for wifi

kraa965 commented 1 year ago

@Xiehanxin thanks for the solution with ble