esp-idf: Wifi station sometimes unable to connect (IDFGH-46)

sometimes wifi station never connects and just immediately fires the disconnect event in response to connect request:

reason given is 201. there are no visible differences in initialization messages and there are no code differences - this just sometimes happens on our automated hardware test rig. it doesn’t happen often, i’d say once in a couple dozen times.

AP is out of suspicion: at the very same time other hw tests, including on another esp32 device, connect to it just fine.

wifi messages for normal run:

E (2765) wifi: esp_wifi_get_mode 768 wifi is not init
mgos_wifi_set_mode   WiFi mode: STA
E (2775) wifi: esp_wifi_set_mode 761 wifi is not init
I (2785) wifi: frc2_timer_task_hdl:3ffc1fac, prio:22, stack:2048
I (2795) wifi: Init lldesc rx mblock:25
I (2795) wifi: Init lldesc rx ampdu len mblock:7
I (2805) wifi: Init lldesc rx ampdu entry mblock:4
I (2815) wifi: pp_task_hdl : 3ffcfa6c, prio:23, stack:8192
E (2815) wifi: esp_wifi_connect 794 wifi not start
I (2825) wifi: mode : sta (24:0a:c4:00:39:f8)
event_handler        event: 2
mgos_wifi_setup_sta  WiFi STA: Connecting to Cesanta
mgos_i2c_create      I2C initialized (SDA: 22, SCL: 23)
mgos_sys_config_init HTTP server started on [80]
mg_rpc_channel_mqtt  0x3ffd0fac docker-agent.2B2088A1119E6083/rpc
mg_rpc_channel_uart  0x3ffd1074 UART0
mgos_init            Init done, RAM: 153684 free, 151108 min free
Tick
I (4465) wifi: n:11 0, o:1 0, ap:255 255, sta:11 0, prof:1
I (5025) wifi: state: init -> auth (b0)
I (5035) wifi: state: auth -> assoc (0)
Tock
I (5045) wifi: state: assoc -> run (10)
I (5055) wifi: connected with Cesanta, channel 11
mgos_wifi_on_change_ Wifi: connected

bad run:

E (2749) wifi: esp_wifi_get_mode 768 wifi is not init
mgos_wifi_set_mode   WiFi mode: STA
E (2759) wifi: esp_wifi_set_mode 761 wifi is not init
I (2759) wifi: frc2_timer_task_hdl:3ffc131c, prio:22, stack:2048
I (2769) wifi: Init lldesc rx mblock:25
I (2779) wifi: Init lldesc rx ampdu len mblock:7
I (2779) wifi: Init lldesc rx ampdu entry mblock:4
I (2789) wifi: pp_task_hdl : 3ffced58, prio:23, stack:8192
E (2799) wifi: esp_wifi_connect 794 wifi not start
I (2799) wifi: mode : sta (24:0a:c4:00:39:f8)
event_handler        event: 2
mgos_wifi_setup_sta  WiFi STA: Connecting to Cesanta
mgos_sys_config_init HTTP server started on [80]
mg_rpc_channel_mqtt  0x3ffd02b4 docker-agent.2D0C09498A207136/rpc
mg_rpc_add_channel   0x3ffd02b4 '*' MQTT
mg_rpc_channel_uart  0x3ffd0368 UART0
mg_rpc_add_channel   0x3ffd0368 '' UART
mgos_init            Init done, RAM: 161224 free, 161224 min free
mgos_upd_boot_finish 1 0
wifi_event_handler   WiFi STA: disconnected, reason 201; reconnecting
mgos_wifi_on_change_ Wifi: disconnected
wifi_event_handler   WiFi STA: disconnected, reason 201; reconnecting
mgos_wifi_on_change_ Wifi: disconnected
... (this continues in a tight loop) ...

(ignore the “not init” and “not start” errors, they are handled in the code and wifi is inited and started as required).

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 26 (16 by maintainers)

Most upvoted comments

I guess it’s not your case, but anyway… Something similar happened to me after updating to esp-idf v3.3. With older versions there was no problem. The bug was uncorrect wifi_config_t initialization. wifi_config_t wifi_config = {0} at the beginning helped.