ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x400d8148

madhusudan_jadhav
Posts: 28
Joined: Fri Mar 10, 2023 9:05 am

ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x400d8148

Postby madhusudan_jadhav » Tue May 09, 2023 3:50 am

Hello there,
in my example i am doing wifi scan. after i get the result. i want to start wifi enterprise or bluetooth but during deinit the above error is coming.Codebox=text file=Untitled.txt]void task(void *pvParameter) {
while(1){
vTaskDelay(4000/portTICK_PERIOD_MS);
ESP_ERROR_CHECK(esp_wifi_disconnect() );
vTaskDelay(1000/portTICK_PERIOD_MS);
ESP_LOGI(TAG, "wifi_init_sta stop sta");
ESP_ERROR_CHECK(esp_wifi_stop() );
vTaskDelay(1000/portTICK_PERIOD_MS);
ESP_LOGI(TAG, "wifi_init_sta deinit sta");
ESP_ERROR_CHECK(esp_wifi_deinit() );
vTaskDelay(1000/portTICK_PERIOD_MS);
if(k==0){
app();k=1;}
ble_init();
}
vTaskDelay(pdMS_TO_TICKS(1000));
}[/Codebox]

Code: Untitled.txt Select all

static void wifi_scan(void)
{
int j =0;
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
esp_netif_t *sta_netif = esp_netif_create_default_wifi_sta();
assert(sta_netif);

wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));

uint16_t number = DEFAULT_SCAN_LIST_SIZE;
wifi_ap_record_t ap_info[DEFAULT_SCAN_LIST_SIZE];
uint16_t ap_count = 0;
memset(ap_info, 0, sizeof(ap_info));

ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_start());
esp_wifi_scan_start(NULL, true);
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&number, ap_info));
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count));
ESP_LOGI(TAG, "Total APs scanned = %u", ap_count);
j=0;
for (int i = 0; (i < DEFAULT_SCAN_LIST_SIZE) && (i < ap_count); i++) {
send_dat[0]='S';

send_data1[j]='^';
j++;
ESP_LOGI(TAG, "SSID \t\t%s", ap_info[i].ssid);
for (int k=0;k<33;k++){
send_data1[j] =ap_info[i].ssid[k];
printf("%c",send_data1[k]);
j++;
}
ESP_LOGI(TAG, "RSSI \t\t%d", ap_info[i].rssi);

print_auth_mode(ap_info[i].authmode);
if (ap_info[i].authmode != WIFI_AUTH_WEP) {
print_cipher_type(ap_info[i].pairwise_cipher, ap_info[i].group_cipher);
}
ESP_LOGI(TAG, "Channel \t\t%d\n", ap_info[i].primary);
}

}

MicroController
Posts: 2672
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x400d8148

Postby MicroController » Tue May 09, 2023 8:35 am

Code: Select all

while(1) {
...
ESP_ERROR_CHECK(esp_wifi_deinit() );
...
}
You're disconnecting/de-init'ing inside a loop. WiFi is already de-init'ed after the first iteration and can't be de-init'ed again in the next iteration.

madhusudan_jadhav
Posts: 28
Joined: Fri Mar 10, 2023 9:05 am

Re: ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x400d8148

Postby madhusudan_jadhav » Tue May 09, 2023 10:01 am

Ok changed the code.now the code is

Code: Untitled.txt Select all

int
app_main(void)
{
char *a="";
/* Initialize NVS — it is used to store PHY calibration data */
esp_err_t ret = nvs_flash_init();
printf("one");
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();
printf("no free pages in nvs");
}
for(int i=0;i<sizeof(wifi_con.ssid);i++){
a+=wifi_con.ssid[i];
}

ESP_ERROR_CHECK(ret);
app_wifi();
char * p=strstr(send_data1,a);
if (p) {
vTaskDelay(4000/portTICK_PERIOD_MS);
printf("wifi cred found");
//esp_wifi_scan_stop();
esp_wifi_stop();
esp_wifi_deinit();
app();
}
else{
vTaskDelay(4000/portTICK_PERIOD_MS);
printf("wifi cred not found");
//xTaskCreate(&task1, "task1", 10000, NULL, 2, NULL);
//esp_wifi_scan_stop();
// esp_wifi_stop();
// esp_wifi_deinit();
ble_init();

}
return 0;
}
but now

Code: Untitled.txt Select all

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6944
load:0x40078000,len:15500
load:0x40080400,len:3844
0x40080400: _init at ??:?

entry 0x4008064c
I (27) boot: ESP-IDF v5.0.1-dirty 2nd stage bootloader
I (27) boot: compile time 06:14:10
I (27) boot: chip revision: v3.0
I (31) boot.esp32: SPI Speed : 40MHz
I (35) boot.esp32: SPI Mode : DIO
I (40) boot.esp32: SPI Flash Size : 8MB
I (45) boot: Enabling RNG early entropy source...
I (50) boot: Partition Table:
I (53) boot: ## Label Usage Type ST Offset Length
I (61) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (68) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (76) boot: 2 factory factory app 00 00 00010000 00177000
I (83) boot: End of partition table
I (87) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=24540h (148800) map
I (150) esp_image: segment 1: paddr=00034568 vaddr=3ffbdb60 size=051bch ( 20924) load
I (158) esp_image: segment 2: paddr=0003972c vaddr=40080000 size=068ech ( 26860) load
I (169) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=b1f88h (728968) map
I (433) esp_image: segment 4: paddr=000f1fb0 vaddr=400868ec size=179b4h ( 96692) load
I (488) boot: Loaded app from partition at offset 0x10000
I (488) boot: Disabling RNG early entropy source...
I (500) cpu_start: Pro cpu up.
I (500) cpu_start: Starting app cpu, entry point is 0x40081414
0x40081414: call_start_cpu1 at C:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/port/cpu_start.c:142

I (487) cpu_start: App cpu up.
I (516) cpu_start: Pro cpu start user code
I (516) cpu_start: cpu freq: 160000000 Hz
I (516) cpu_start: Application information:
I (521) cpu_start: Project name: bleprph
I (526) cpu_start: App version: 1
I (531) cpu_start: Compile time: May 9 2023 06:13:44
I (537) cpu_start: ELF file SHA256: 0ef03b4e9d963ee2...
I (543) cpu_start: ESP-IDF: v5.0.1-dirty
I (548) cpu_start: Min chip rev: v0.0
I (553) cpu_start: Max chip rev: v3.99
I (558) cpu_start: Chip rev: v3.0
I (562) heap_init: Initializing. RAM available for dynamic allocation:
I (570) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (576) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (582) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (588) heap_init: At 3FFC90F8 len 00016F08 (91 KiB): DRAM
I (594) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (600) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (607) heap_init: At 4009E2A0 len 00001D60 (7 KiB): IRAM
I (614) spi_flash: detected chip: generic
I (618) spi_flash: flash io: dio
W (621) spi_flash: Detected size(16384k) larger than the size in the binary image header(8192k). Using the size in the binary image header.
I (636) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
oneI (693) wifi:wifi driver task: 3ffcce70, prio:23, stack:6656, core=0
I (694) system_api: Base MAC address is not set
I (694) system_api: read default base MAC address from EFUSE
I (703) wifi:wifi firmware version: 17afb16
I (704) wifi:wifi certification version: v7.0
I (708) wifi:config NVS flash: enabled
I (711) wifi:config nano formating: disabled
I (716) wifi:Init data frame dynamic rx buffer num: 32
I (720) wifi:Init management frame dynamic rx buffer num: 32
I (726) wifi:Init management short buffer num: 32
I (730) wifi:Init dynamic tx buffer num: 32
I (734) wifi:Init static rx buffer size: 1600
I (738) wifi:Init static rx buffer num: 10
I (742) wifi:Init dynamic rx buffer num: 32
I (747) wifi_init: rx ba win: 6
I (750) wifi_init: tcpip mbox: 32
I (754) wifi_init: udp mbox: 6
I (757) wifi_init: tcp mbox: 6
I (761) wifi_init: tcp tx win: 5744
I (765) wifi_init: tcp rx win: 5744
I (769) wifi_init: tcp mss: 1440
I (773) wifi_init: WiFi IRAM OP enabled
I (778) wifi_init: WiFi RX IRAM OP enabled
I (784) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (893) wifi:mode : sta (c0:49:ef:08:84:e0)
I (894) wifi:enable tsf
I (3399) scan: Total APs scanned = 9
I (3400) scan: SSID JADHAV
^JADHAVI (3400) scan: RSSI -53
I (3402) scan: Authmode WIFI_AUTH_WPA_WPA2_PSK
I (3408) scan: Pairwise Cipher WIFI_CIPHER_TYPE_CCMP
I (3413) scan: Group Cipher WIFI_CIPHER_TYPE_CCMP
I (3419) scan: Channel 6

I (3422) scan: SSID Mukund
^JADHAVI (3426) scan: RSSI -60
I (3432) scan: Authmode WIFI_AUTH_WPA2_PSK
I (3437) scan: Pairwise Cipher WIFI_CIPHER_TYPE_CCMP
I (3443) scan: Group Cipher WIFI_CIPHER_TYPE_CCMP
I (3448) scan: Channel 4

I (3452) scan: SSID Ocean_2.4g
^JADHAVI (3456) scan: RSSI -71
I (3462) scan: Authmode WIFI_AUTH_WPA_WPA2_PSK
I (3467) scan: Pairwise Cipher WIFI_CIPHER_TYPE_TKIP_CCMP
I (3473) scan: Group Cipher WIFI_CIPHER_TYPE_TKIP
I (3479) scan: Channel 6

I (3482) scan: SSID Archana Pardeshi
^JADHAVI (3487) scan: RSSI -87
I (3493) scan: Authmode WIFI_AUTH_WPA_WPA2_PSK
I (3498) scan: Pairwise Cipher WIFI_CIPHER_TYPE_CCMP
I (3504) scan: Group Cipher WIFI_CIPHER_TYPE_CCMP
I (3509) scan: Channel 10

I (3513) scan: SSID techofy_g
^JADHAVI (3517) scan: RSSI -90
I (3523) scan: Authmode WIFI_AUTH_WPA_WPA2_PSK
I (3528) scan: Pairwise Cipher WIFI_CIPHER_TYPE_CCMP
I (3534) scan: Group Cipher WIFI_CIPHER_TYPE_CCMP
I (3539) scan: Channel 3

I (3543) scan: SSID
^JADHAVI (3546) scan: RSSI -76
I (3552) scan: Authmode WIFI_AUTH_UNKNOWN
I (3557) scan: Pairwise Cipher WIFI_CIPHER_TYPE_UNKNOWN
I (3563) scan: Group Cipher WIFI_CIPHER_TYPE_UNKNOWN
I (3568) scan: Channel 64

I (3572) scan: SSID @�@@�@@(B@��@��@��@

^JADHAVI (3578) scan: RSSI 0
I (3583) scan: Authmode WIFI_AUTH_UNKNOWN
I (3588) scan: Pairwise Cipher WIFI_CIPHER_TYPE_NONE
I (3594) scan: Group Cipher WIFI_CIPHER_TYPE_NONE
I (3599) scan: Channel 0

I (3603) scan: SSID
^JADHAVI (3606) scan: RSSI 0
I (3612) scan: Authmode WIFI_AUTH_WPA2_WPA3_PSK
I (3617) scan: Pairwise Cipher WIFI_CIPHER_TYPE_UNKNOWN
I (3623) scan: Group Cipher WIFI_CIPHER_TYPE_CCMP
I (3629) scan: Channel 63

I (3632) scan: SSID �?x�A?
^JADHAVI (3636) scan: RSSI 68
I (3642) scan: Authmode WIFI_AUTH_OPEN
I (3647) scan: Pairwise Cipher WIFI_CIPHER_TYPE_UNKNOWN
I (3653) scan: Group Cipher WIFI_CIPHER_TYPE_UNKNOWN
I (3658) scan: Channel 63

wifi cred foundI (7665) wifi:flush txq
I (7665) wifi:stop sw txq
I (7666) wifi:lmac stop hw txq
I (7667) wifi:Deinit lldesc rx mblock:10
ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x400d7fd0
0x400d7fd0: initialise_wifi at C:/Espressif/tools/espressif-ide/2.9.0/workspace/bleprph/main/wifi_enterprise_main.c:114 (discriminator 1)

file: "./main/wifi_enterprise_main.c" line 114
func: initialise_wifi
expression: esp_event_loop_create_default()

abort() was called at PC 0x40091f53 on core 0
0x40091f53: _esp_error_check_failed at C:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/esp_err.c:47



Backtrace: 0x40081ffe:0x3ffbb9b0 0x40091f5d:0x3ffbb9d0 0x40098486:0x3ffbb9f0 0x40091f53:0x3ffbba60 0x400d7fd0:0x3ffbba90 0x400d81ef:0x3ffbbc10 0x400d74e5:0x3ffbbc40 0x401803d3:0x3ffbbc60
0x40081ffe: panic_abort at C:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/panic.c:423

0x40091f5d: esp_system_abort at C:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/esp_system.c:153

0x40098486: abort at C:/Espressif/frameworks/esp-idf-v5.0.1/components/newlib/abort.c:38

0x40091f53: _esp_error_check_failed at C:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/esp_err.c:47

0x400d7fd0: initialise_wifi at C:/Espressif/tools/espressif-ide/2.9.0/workspace/bleprph/main/wifi_enterprise_main.c:114 (discriminator 1)

0x400d81ef: app at C:/Espressif/tools/espressif-ide/2.9.0/workspace/bleprph/main/wifi_enterprise_main.c:185

0x400d74e5: app_main at C:/Espressif/tools/espressif-ide/2.9.0/workspace/bleprph/main/main.c:238

0x401803d3: main_task at C:/Espressif/frameworks/esp-idf-v5.0.1/components/freertos/FreeRTOS-Kernel/portable/port_common.c:131 (discriminator 2)
this one coming.

Who is online

Users browsing this forum: Bing [Bot], PetalBot and 6 guests