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]
  1. static void wifi_scan(void)
  2. {
  3.     int j =0;
  4.     ESP_ERROR_CHECK(esp_netif_init());
  5.     ESP_ERROR_CHECK(esp_event_loop_create_default());
  6.     esp_netif_t *sta_netif = esp_netif_create_default_wifi_sta();
  7.     assert(sta_netif);
  8.  
  9.     wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  10.     ESP_ERROR_CHECK(esp_wifi_init(&cfg));
  11.  
  12.     uint16_t number = DEFAULT_SCAN_LIST_SIZE;
  13.     wifi_ap_record_t ap_info[DEFAULT_SCAN_LIST_SIZE];
  14.     uint16_t ap_count = 0;
  15.     memset(ap_info, 0, sizeof(ap_info));
  16.  
  17.     ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
  18.     ESP_ERROR_CHECK(esp_wifi_start());
  19.     esp_wifi_scan_start(NULL, true);
  20.     ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&number, ap_info));
  21.     ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count));
  22.     ESP_LOGI(TAG, "Total APs scanned = %u", ap_count);
  23.     j=0;
  24.     for (int i = 0; (i < DEFAULT_SCAN_LIST_SIZE) && (i < ap_count); i++) {
  25.         send_dat[0]='S';
  26.  
  27.         send_data1[j]='^';
  28.         j++;
  29.         ESP_LOGI(TAG, "SSID \t\t%s", ap_info[i].ssid);
  30.         for (int k=0;k<33;k++){
  31.             send_data1[j] =ap_info[i].ssid[k];
  32.                 printf("%c",send_data1[k]);
  33.                 j++;
  34.             }
  35.         ESP_LOGI(TAG, "RSSI \t\t%d", ap_info[i].rssi);
  36.  
  37.         print_auth_mode(ap_info[i].authmode);
  38.         if (ap_info[i].authmode != WIFI_AUTH_WEP) {
  39.             print_cipher_type(ap_info[i].pairwise_cipher, ap_info[i].group_cipher);
  40.         }
  41.         ESP_LOGI(TAG, "Channel \t\t%d\n", ap_info[i].primary);
  42.     }
  43.  
  44. }

MicroController
Posts: 1705
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
  1. int
  2. app_main(void)
  3. {
  4. char *a="";
  5. /* Initialize NVS — it is used to store PHY calibration data */
  6. esp_err_t ret = nvs_flash_init();
  7. printf("one");
  8. if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
  9.     ESP_ERROR_CHECK(nvs_flash_erase());
  10.     ret = nvs_flash_init();
  11.     printf("no free pages in nvs");
  12. }
  13. for(int i=0;i<sizeof(wifi_con.ssid);i++){
  14.     a+=wifi_con.ssid[i];
  15. }
  16.  
  17. ESP_ERROR_CHECK(ret);
  18. app_wifi();
  19. char * p=strstr(send_data1,a);
  20. if (p) {
  21.     vTaskDelay(4000/portTICK_PERIOD_MS);
  22.     printf("wifi cred found");
  23.     //esp_wifi_scan_stop();
  24.         esp_wifi_stop();
  25.         esp_wifi_deinit();
  26. app();
  27. }
  28. else{
  29.     vTaskDelay(4000/portTICK_PERIOD_MS);
  30.     printf("wifi cred not found");
  31.     //xTaskCreate(&task1, "task1", 10000, NULL, 2, NULL);
  32.     //esp_wifi_scan_stop();
  33. //  esp_wifi_stop();
  34. //  esp_wifi_deinit();
  35.     ble_init();
  36.  
  37. }
  38. return 0;
  39. }
but now
  1. Rebooting...
  2. ets Jul 29 2019 12:21:46
  3.  
  4. rst:0xc (SW_CPU_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
  5. configsip: 0, SPIWP:0xee
  6. clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  7. mode:DIO, clock div:2
  8. load:0x3fff0030,len:6944
  9. load:0x40078000,len:15500
  10. load:0x40080400,len:3844
  11. 0x40080400: _init at ??:?
  12.  
  13. entry 0x4008064c
  14. I (27) boot: ESP-IDF v5.0.1-dirty 2nd stage bootloader
  15. I (27) boot: compile time 06:14:10
  16. I (27) boot: chip revision: v3.0
  17. I (31) boot.esp32: SPI Speed      : 40MHz
  18. I (35) boot.esp32: SPI Mode       : DIO
  19. I (40) boot.esp32: SPI Flash Size : 8MB
  20. I (45) boot: Enabling RNG early entropy source...
  21. I (50) boot: Partition Table:
  22. I (53) boot: ## Label            Usage          Type ST Offset   Length
  23. I (61) boot:  0 nvs              WiFi data        01 02 00009000 00006000
  24. I (68) boot:  1 phy_init         RF data          01 01 0000f000 00001000
  25. I (76) boot:  2 factory          factory app      00 00 00010000 00177000
  26. I (83) boot: End of partition table
  27. I (87) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=24540h (148800) map
  28. I (150) esp_image: segment 1: paddr=00034568 vaddr=3ffbdb60 size=051bch ( 20924) load
  29. I (158) esp_image: segment 2: paddr=0003972c vaddr=40080000 size=068ech ( 26860) load
  30. I (169) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=b1f88h (728968) map
  31. I (433) esp_image: segment 4: paddr=000f1fb0 vaddr=400868ec size=179b4h ( 96692) load
  32. I (488) boot: Loaded app from partition at offset 0x10000
  33. I (488) boot: Disabling RNG early entropy source...
  34. I (500) cpu_start: Pro cpu up.
  35. I (500) cpu_start: Starting app cpu, entry point is 0x40081414
  36. 0x40081414: call_start_cpu1 at C:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/port/cpu_start.c:142
  37.  
  38. I (487) cpu_start: App cpu up.
  39. I (516) cpu_start: Pro cpu start user code
  40. I (516) cpu_start: cpu freq: 160000000 Hz
  41. I (516) cpu_start: Application information:
  42. I (521) cpu_start: Project name:     bleprph
  43. I (526) cpu_start: App version:      1
  44. I (531) cpu_start: Compile time:     May  9 2023 06:13:44
  45. I (537) cpu_start: ELF file SHA256:  0ef03b4e9d963ee2...
  46. I (543) cpu_start: ESP-IDF:          v5.0.1-dirty
  47. I (548) cpu_start: Min chip rev:     v0.0
  48. I (553) cpu_start: Max chip rev:     v3.99
  49. I (558) cpu_start: Chip rev:         v3.0
  50. I (562) heap_init: Initializing. RAM available for dynamic allocation:
  51. I (570) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
  52. I (576) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
  53. I (582) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
  54. I (588) heap_init: At 3FFC90F8 len 00016F08 (91 KiB): DRAM
  55. I (594) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
  56. I (600) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
  57. I (607) heap_init: At 4009E2A0 len 00001D60 (7 KiB): IRAM
  58. I (614) spi_flash: detected chip: generic
  59. I (618) spi_flash: flash io: dio
  60. 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.
  61. I (636) cpu_start: Starting scheduler on PRO CPU.
  62. I (0) cpu_start: Starting scheduler on APP CPU.
  63. oneI (693) wifi:wifi driver task: 3ffcce70, prio:23, stack:6656, core=0
  64. I (694) system_api: Base MAC address is not set
  65. I (694) system_api: read default base MAC address from EFUSE
  66. I (703) wifi:wifi firmware version: 17afb16
  67. I (704) wifi:wifi certification version: v7.0
  68. I (708) wifi:config NVS flash: enabled
  69. I (711) wifi:config nano formating: disabled
  70. I (716) wifi:Init data frame dynamic rx buffer num: 32
  71. I (720) wifi:Init management frame dynamic rx buffer num: 32
  72. I (726) wifi:Init management short buffer num: 32
  73. I (730) wifi:Init dynamic tx buffer num: 32
  74. I (734) wifi:Init static rx buffer size: 1600
  75. I (738) wifi:Init static rx buffer num: 10
  76. I (742) wifi:Init dynamic rx buffer num: 32
  77. I (747) wifi_init: rx ba win: 6
  78. I (750) wifi_init: tcpip mbox: 32
  79. I (754) wifi_init: udp mbox: 6
  80. I (757) wifi_init: tcp mbox: 6
  81. I (761) wifi_init: tcp tx win: 5744
  82. I (765) wifi_init: tcp rx win: 5744
  83. I (769) wifi_init: tcp mss: 1440
  84. I (773) wifi_init: WiFi IRAM OP enabled
  85. I (778) wifi_init: WiFi RX IRAM OP enabled
  86. I (784) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
  87. I (893) wifi:mode : sta (c0:49:ef:08:84:e0)
  88. I (894) wifi:enable tsf
  89. I (3399) scan: Total APs scanned = 9
  90. I (3400) scan: SSID             JADHAV
  91. ^JADHAVI (3400) scan: RSSI              -53
  92. I (3402) scan: Authmode         WIFI_AUTH_WPA_WPA2_PSK
  93. I (3408) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_CCMP
  94. I (3413) scan: Group Cipher     WIFI_CIPHER_TYPE_CCMP
  95. I (3419) scan: Channel          6
  96.  
  97. I (3422) scan: SSID             Mukund
  98. ^JADHAVI (3426) scan: RSSI              -60
  99. I (3432) scan: Authmode         WIFI_AUTH_WPA2_PSK
  100. I (3437) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_CCMP
  101. I (3443) scan: Group Cipher     WIFI_CIPHER_TYPE_CCMP
  102. I (3448) scan: Channel          4
  103.  
  104. I (3452) scan: SSID             Ocean_2.4g
  105. ^JADHAVI (3456) scan: RSSI              -71
  106. I (3462) scan: Authmode         WIFI_AUTH_WPA_WPA2_PSK
  107. I (3467) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_TKIP_CCMP
  108. I (3473) scan: Group Cipher     WIFI_CIPHER_TYPE_TKIP
  109. I (3479) scan: Channel          6
  110.  
  111. I (3482) scan: SSID             Archana Pardeshi
  112. ^JADHAVI (3487) scan: RSSI              -87
  113. I (3493) scan: Authmode         WIFI_AUTH_WPA_WPA2_PSK
  114. I (3498) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_CCMP
  115. I (3504) scan: Group Cipher     WIFI_CIPHER_TYPE_CCMP
  116. I (3509) scan: Channel          10
  117.  
  118. I (3513) scan: SSID             techofy_g
  119. ^JADHAVI (3517) scan: RSSI              -90
  120. I (3523) scan: Authmode         WIFI_AUTH_WPA_WPA2_PSK
  121. I (3528) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_CCMP
  122. I (3534) scan: Group Cipher     WIFI_CIPHER_TYPE_CCMP
  123. I (3539) scan: Channel          3
  124.  
  125. I (3543) scan: SSID
  126. ^JADHAVI (3546) scan: RSSI              -76
  127. I (3552) scan: Authmode         WIFI_AUTH_UNKNOWN
  128. I (3557) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_UNKNOWN
  129. I (3563) scan: Group Cipher     WIFI_CIPHER_TYPE_UNKNOWN
  130. I (3568) scan: Channel          64
  131.  
  132. I (3572) scan: SSID             @�@@�@@(B@��@��@��@
  133.  
  134. ^JADHAVI (3578) scan: RSSI              0
  135. I (3583) scan: Authmode         WIFI_AUTH_UNKNOWN
  136. I (3588) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_NONE
  137. I (3594) scan: Group Cipher     WIFI_CIPHER_TYPE_NONE
  138. I (3599) scan: Channel          0
  139.  
  140. I (3603) scan: SSID
  141. ^JADHAVI (3606) scan: RSSI              0
  142. I (3612) scan: Authmode         WIFI_AUTH_WPA2_WPA3_PSK
  143. I (3617) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_UNKNOWN
  144. I (3623) scan: Group Cipher     WIFI_CIPHER_TYPE_CCMP
  145. I (3629) scan: Channel          63
  146.  
  147. I (3632) scan: SSID             �?x�A?
  148. ^JADHAVI (3636) scan: RSSI              68
  149. I (3642) scan: Authmode         WIFI_AUTH_OPEN
  150. I (3647) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_UNKNOWN
  151. I (3653) scan: Group Cipher     WIFI_CIPHER_TYPE_UNKNOWN
  152. I (3658) scan: Channel          63
  153.  
  154. wifi cred foundI (7665) wifi:flush txq
  155. I (7665) wifi:stop sw txq
  156. I (7666) wifi:lmac stop hw txq
  157. I (7667) wifi:Deinit lldesc rx mblock:10
  158. ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x400d7fd0
  159. 0x400d7fd0: initialise_wifi at C:/Espressif/tools/espressif-ide/2.9.0/workspace/bleprph/main/wifi_enterprise_main.c:114 (discriminator 1)
  160.  
  161. file: "./main/wifi_enterprise_main.c" line 114
  162. func: initialise_wifi
  163. expression: esp_event_loop_create_default()
  164.  
  165. abort() was called at PC 0x40091f53 on core 0
  166. 0x40091f53: _esp_error_check_failed at C:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/esp_err.c:47
  167.  
  168.  
  169.  
  170. Backtrace: 0x40081ffe:0x3ffbb9b0 0x40091f5d:0x3ffbb9d0 0x40098486:0x3ffbb9f0 0x40091f53:0x3ffbba60 0x400d7fd0:0x3ffbba90 0x400d81ef:0x3ffbbc10 0x400d74e5:0x3ffbbc40 0x401803d3:0x3ffbbc60
  171. 0x40081ffe: panic_abort at C:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/panic.c:423
  172.  
  173. 0x40091f5d: esp_system_abort at C:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/esp_system.c:153
  174.  
  175. 0x40098486: abort at C:/Espressif/frameworks/esp-idf-v5.0.1/components/newlib/abort.c:38
  176.  
  177. 0x40091f53: _esp_error_check_failed at C:/Espressif/frameworks/esp-idf-v5.0.1/components/esp_system/esp_err.c:47
  178.  
  179. 0x400d7fd0: initialise_wifi at C:/Espressif/tools/espressif-ide/2.9.0/workspace/bleprph/main/wifi_enterprise_main.c:114 (discriminator 1)
  180.  
  181. 0x400d81ef: app at C:/Espressif/tools/espressif-ide/2.9.0/workspace/bleprph/main/wifi_enterprise_main.c:185
  182.  
  183. 0x400d74e5: app_main at C:/Espressif/tools/espressif-ide/2.9.0/workspace/bleprph/main/main.c:238
  184.  
  185. 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: No registered users and 126 guests