esp_wifi_init failed by invalid magic number

AndiRo
Posts: 3
Joined: Mon Dec 12, 2022 2:45 pm

esp_wifi_init failed by invalid magic number

Postby AndiRo » Fri Dec 16, 2022 9:17 am

I am trying to initialize wifi in an function and call it in the main.c

I am using esp-idf v4.4.3 and esp-adf v2.4.1
I wont use the wifi for an audio stream its just for an webserver to change some settings

you can see the initialization code here
its the same like the wifi get started example

Code: Select all

    esp_err_t ret;
    
    ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
      ESP_ERROR_CHECK(nvs_flash_erase());
      ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);


    ESP_ERROR_CHECK(esp_netif_init());
    ESP_ERROR_CHECK(esp_event_loop_create_default());
    esp_netif_create_default_wifi_ap();


    const wifi_init_config_t cfg_123 = WIFI_INIT_CONFIG_DEFAULT();
    ESP_LOGI(LOGTAG, "debug: %d ", cfg_123.magic );
    ESP_ERROR_CHECK(esp_wifi_init(&cfg_123));


    ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
                                                        ESP_EVENT_ANY_ID,
                                                        &wifi_event_handler,
                                                        NULL,
                                                        NULL));
                                                        
    wifi_config_t wifi_config = {
        .ap = {
            .ssid = EXAMPLE_ESP_WIFI_SSID,
            .ssid_len = strlen(EXAMPLE_ESP_WIFI_SSID),
            .channel = EXAMPLE_ESP_WIFI_CHANNEL,
            .password = EXAMPLE_ESP_WIFI_PASS,
            .max_connection = EXAMPLE_MAX_STA_CONN,
            .authmode = WIFI_AUTH_WPA_WPA2_PSK
        },
    };
    if (strlen(EXAMPLE_ESP_WIFI_PASS) == 0) {
        wifi_config.ap.authmode = WIFI_AUTH_OPEN;
    }

    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
    ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config));
    ESP_ERROR_CHECK(esp_wifi_start());
if I place the initialization in my main everything works fine

But if I put it in an function and call it in my main esp_wifi_init aborts caused by invalid (magic number) argument

E (592) wifi:invalid magic number 3ffb, call WIFI_INIT_CONFIG_DEFAULT to init config
I (592) wifi_init: rx ba win: 6
I (602) wifi_init: tcpip mbox: 32
I (602) wifi_init: udp mbox: 6
I (602) wifi_init: tcp mbox: 6
I (612) wifi_init: tcp tx win: 5744
I (612) wifi_init: tcp rx win: 5744
I (622) wifi_init: tcp mss: 1440
I (622) wifi_init: WiFi IRAM OP enabled
I (622) wifi_init: WiFi RX IRAM OP enabled
ESP_ERROR_CHECK failed: esp_err_t 0x102 (ESP_ERR_INVALID_ARG) at 0x4008a258

a already tried to do
git submodule update --init --recursive

Thanks in advance for your help

Who is online

Users browsing this forum: No registered users and 433 guests