zephyr: esp32c3: Connection fail loop

Describe the bug The sample code for connecting to wifi (samples/boards/esp32/wifi_station), works fine on esp32 but does not work on esp32c3. Instead of connecting, a disconnect loop is obtained.

This is on a generic esp32c3 development board. Zephyr version 3.0.99.

This happens on a WPA1, WPA2, and Open access point. Building the same code for esp32 and running on a normal esp32 yields perfectly normal behaviour.

To Reproduce Steps to reproduce the behavior:

  1. make copy of sample samples/boards/esp32/wifi_station
  2. edit prj.conf with details to connect to AP
  3. build (west build -b esp32c3_devkitm -d build_dir wifi_fix --pristine)
  4. flash generated image (west flash -d build_dir --esp-device /dev/ttyUSB0)

Expected behavior Board connects to access point and get a DHCP address.

Impact Unable to connect to wifi on esp32c3.

Logs and console output Console output (the loop) on ESP32C3:

I (49) boot: ESP-IDF release/v4.3-120-gbcd7565ff 2nd stage bootloader
I (49) boot: compile time 15:06:09
I (50) boot: chip revision: 3
I (53) boot.esp32c3: SPI Speed      : 40MHz
I (58) boot.esp32c3: SPI Mode       : DIO
I (62) boot.esp32c3: SPI Flash Size : 2MB
I (67) boot: Enabling RNG early entropy source...
I (73) boot: Partition Table:
I (76) boot: ## Label            Usage          Type ST Offset   Length
I (83) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (91) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (98) boot:  2 factory          factory app      00 00 00010000 00100000
I (106) boot: End of partition table
I (110) boot_comm: chip revision: 3, min. application chip revision: 0
I (117) esp_image: segment 0: paddr=00010020 vaddr=00000020 size=0001ch (    28) 
I (126) esp_image: segment 1: paddr=00010044 vaddr=3fcb5f40 size=01470h (  5232) load
I (135) esp_image: segment 2: paddr=000114bc vaddr=3fcb73b0 size=00594h (  1428) load
I (143) esp_image: segment 3: paddr=00011a58 vaddr=3fcb7948 size=0006ch (   108) load
I (151) esp_image: segment 4: paddr=00011acc vaddr=40380000 size=0e56ch ( 58732) load
I (173) esp_image: segment 5: paddr=00020040 vaddr=3c000040 size=11a10h ( 72208) map
I (189) esp_image: segment 6: paddr=00031a58 vaddr=4038e56c size=02ae0h ( 10976) load
I (192) esp_image: segment 7: paddr=00034540 vaddr=00000000 size=0bad8h ( 47832) 
I (205) esp_image: segment 8: paddr=00040020 vaddr=42020020 size=5009ch (327836) map
I (280) boot: Loaded app from partition at offset 0x10000
I (280) boot: Disabling RNG early entropy source...
pp rom version: 9387209
net80211 rom version: 9387209
I (12) wifi:wifi driver task: 3fc926c8, prio:2, stack:3584, core=0
I (12) wifi:wifi firmware version: 7e2c914
I (12) wifi:wifi certification version: v7.0
I (12) wifi:config NVS flash: disabled
I (12) wifi:config nano formating: disabled
I (12) wifi:Init data frame dynamic rx buffer num: 32
I (12) wifi:Init management frame dynamic rx buffer num: 32
I (12) wifi:Init management short buffer num: 32
I (12) wifi:Init dynamic tx buffer num: 32
I (12) wifi:Init static tx FG buffer num: 2
I (12) wifi:Init static rx buffer size: 1600
I (12) wifi:Init static rx buffer num: 10
I (12) wifi:Init dynamic rx buffer num: 32
I (12) phy_init: phy_version 500,985899c,Apr 19 2021,16:05:08
I (12) wifi:set rx active PTI: 0, rx ack PTI: 0, and default PTI: 0
I (12) wifi:mode : softAP (21:58:a1:06:57:50)
I (12) wifi:Total power save buffer number: 16
I (12) wifi:Init max length of beacon: 752/752
I (12) wifi:Init max length of beacon: 752/752
*** Booting Zephyr OS build zephyr-v3.0.0-942-g0e5d438ee2ab  ***
I (12) wifi:mode : sta (21:58:a1:06:57:50)
I (16) wifi:enable tsf
[00:00:00.227,083] <inf> esp32_wifi: WIFI_EVENT_STA_START
I (1231) wifi:new:<11,0>, old:<1,1>, ap:<255,255>, sta:<11,0>, prof:1
I (1232) wifi:state: init -> auth (b0)
I (2232) wifi:state: auth -> init (200)
I (2233) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
[00:00:02.441,507] <inf> esp32_wifi: WIFI_EVENT_STA_DISCONNECTED
I (4303) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (4303) wifi:state: init -> auth (b0)
[00:00:04.489,562] <inf> esp32_wifi: WIFI_EVENT_STA_DISCONNECTED
I (5304) wifi:state: auth -> init (200)
I (5304) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
[00:00:05.513,192] <inf> esp32_wifi: WIFI_EVENT_STA_DISCONNECTED
I (7375) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (7375) wifi:state: init -> auth (b0)
[00:00:07.561,847] <inf> esp32_wifi: WIFI_EVENT_STA_DISCONNECTED
I (8376) wifi:state: auth -> init (200)
I (8377) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
[00:00:08.585,222] <inf> esp32_wifi: WIFI_EVENT_STA_DISCONNECTED
I (10447) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (10447) wifi:state: init -> auth (b0)
[00:00:10.636,250] <inf> esp32_wifi: WIFI_EVENT_STA_DISCONNECTED
I (11448) wifi:state: auth -> init (200)
I (11449) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
[00:00:11.657,236] <inf> esp32_wifi: WIFI_EVENT_STA_DISCONNECTED

Same code, ESP32 output:

I (27) boot: ESP-IDF release/v4.3-120-gbcd7565ff 2nd stage bootloader
I (27) boot: compile time 15:01:25
I (28) boot: chip revision: 1
I (31) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot.esp32: SPI Speed      : 40MHz
I (43) boot.esp32: SPI Mode       : DIO
I (48) boot.esp32: SPI Flash Size : 4MB
I (52) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (61) boot: ## Label            Usage          Type ST Offset   Length
I (69) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (76) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (83) boot:  2 factory          factory app      00 00 00010000 00100000
I (91) boot: End of partition table
I (95) boot_comm: chip revision: 1, min. application chip revision: 0
I (102) esp_image: segment 0: paddr=00010020 vaddr=00000020 size=0001ch (    28) 
I (111) esp_image: segment 1: paddr=00010044 vaddr=3ffb0000 size=01830h (  6192) load
I (121) esp_image: segment 2: paddr=0001187c vaddr=3ffb1830 size=0054ch (  1356) load
I (128) esp_image: segment 3: paddr=00011dd0 vaddr=40080000 size=0e268h ( 57960) load
I (161) esp_image: segment 4: paddr=00020040 vaddr=3f400040 size=12c9ch ( 76956) map
I (190) esp_image: segment 5: paddr=00032ce4 vaddr=4008e268 size=06364h ( 25444) load
I (201) esp_image: segment 6: paddr=00039050 vaddr=00000000 size=06fc8h ( 28616) 
I (212) esp_image: segment 7: paddr=00040020 vaddr=400d0020 size=407d0h (264144) map
I (322) boot: Loaded app from partition at offset 0x10000
I (323) boot: Disabling RNG early entropy source...
I (686) wifi:wifi driver task: 3ffcb288, prio:2, stack:3584, core=0
I (687) wifi:wifi firmware version: 7e2c914
I (687) wifi:wifi certification version: v7.0
I (689) wifi:config NVS flash: disabled
I (692) wifi:config nano formating: disabled
I (697) wifi:Init data frame dynamic rx buffer num: 32
I (701) wifi:Init management frame dynamic rx buffer num: 32
I (707) wifi:Init management short buffer num: 32
I (711) wifi:Init dynamic tx buffer num: 32
I (715) wifi:Init static rx buffer size: 1600
I (719) wifi:Init static rx buffer num: 10
I (723) wifi:Init dynamic rx buffer num: 32
I (728) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (870) wifi:mode : softAP (24:6f:28:2b:63:d5)
I (870) wifi:Total power save buffer number: 16
I (870) wifi:Init max length of beacon: 752/752
I (872) wifi:Init max length of beacon: 752/752
*** Booting Zephyr OS build zephyr-v3.0.0-942-g0e5d438ee2ab  ***
I (882) wifi:mode : sta (24:6f:28:2b:63:d4)
I (885) wifi:enable tsf
[00:00:00.889,000] <inf> esp32_wifi: WIFI_EVENT_STA_START
I (2102) wifi:new:<11,0>, old:<1,1>, ap:<255,255>, sta:<11,0>, prof:1
I (2102) wifi:state: init -> auth (b0)
I (2109) wifi:state: auth -> assoc (0)
I (2114) wifi:state: assoc -> run (10)
I (2114) wifi:connected with propus_open, aid = 1, channel 11, BW20, bssid = 96:83:c4:02:a1:c0
I (2116) wifi:security: Open Auth, phy: bgn, rssi: -45
I (2121) wifi:pm start, type: 1

I (2181) wifi:AP's beacon interval = 102400 us, DTIM period = 2
[00:00:02.124,000] <inf> esp32_wifi: WIFI_EVENT_STA_CONNECTED
[00:00:04.905,000] <inf> net_dhcpv4: Received: 10.30.1.189
[00:00:04.905,000] <inf> esp32_wifi_sta: Your address: 10.30.1.189
[00:00:04.905,000] <inf> esp32_wifi_sta: Lease time: 43200 seconds
[00:00:04.905,000] <inf> esp32_wifi_sta: Subnet: 255.255.255.0
[00:00:04.905,000] <inf> esp32_wifi_sta: Router: 10.30.1.1

Environment (please complete the following information):

  • OS: Linux
  • Toolchain (Zephyr 3.0.99 (0e5d438ee2ab38ca79d9c4375a9d9ca56bc8df2e, main), Espressif (1.24.0.123_64eb9ff-8.4.0))

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 29 (9 by maintainers)

Most upvoted comments

Hi, I managed to get this fixed, will submit the PR soon.

I was able to reproduce the issue as well. I’ll check this.

I have been updating hal layer to bring the latest modifications and check if it solves it.

Is that HAL update already available upstream or did you only test it locally? I would be interested in testing as well, but don’t know how to update the HAL manually.

@sylvioalves Hi, Just want to clarify if there are any updates? Recently I spent some time fighting with this issue 😦

@martinjaeger I have started working on this a few days ago, but no success yet. Will ping you once fixed.

Excellent, thanks a lot @sylvioalves!