Slow Wifi initialization

ElementGreen
Posts: 1
Joined: Tue Oct 19, 2021 6:51 pm

Slow Wifi initialization

Postby ElementGreen » Tue Oct 19, 2021 7:27 pm

I have a Heltec Wifi Kit 32 which has an ESP32 chip which I am running an esp-idf project on. I am having some issues with extremely slow Wifi initialization. As a point of reference I built the esp-idf/examples/protocols/http_server/simple example which has the same problematic behavior as my application. I also built an Arduino example which appears to work fine, so it seems it is something related to esp-idf.

Of note is that using menuconfig I change the CPU frequency to 240 MHz, RTC clock to 32 KHz crystal, and crystal frequency to 26 MHz which is necessary to get esp-idf projects to run on the Heltec Wifi Kit 32 board (well the 26 MHz crystal setting in particular).

With the default behavior with the example project it uses DHCP and takes over 5 minutes for it to obtain an IP. See relevant serial console output below:

Code: Select all

I (601) wifi:wifi driver task: 3ffbfb38, prio:23, stack:6656, core=0
I (601) system_api: Base MAC address is not set
I (601) system_api: read default base MAC address from EFUSE
I (611) wifi:wifi firmware version: c1a3efe
I (611) wifi:wifi certification version: v7.0
I (611) wifi:config NVS flash: enabled
I (611) wifi:config nano formating: disabled
I (621) wifi:Init data frame dynamic rx buffer num: 32
I (621) wifi:Init management frame dynamic rx buffer num: 32
I (631) wifi:Init management short buffer num: 32
I (631) wifi:Init dynamic tx buffer num: 32
I (641) wifi:Init static rx buffer size: 1600
I (641) wifi:Init static rx buffer num: 10
I (641) wifi:Init dynamic rx buffer num: 32
I (651) wifi_init: rx ba win: 6
I (651) wifi_init: tcpip mbox: 32
I (661) wifi_init: udp mbox: 6
I (661) wifi_init: tcp mbox: 6
I (661) wifi_init: tcp tx win: 5744
I (671) wifi_init: tcp rx win: 5744
I (671) wifi_init: tcp mss: 1440
I (681) wifi_init: WiFi IRAM OP enabled
I (681) wifi_init: WiFi RX IRAM OP enabled
I (691) example_connect: Connecting to ElementsOfSound...
I (691) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (791) wifi:mode : sta (94:b9:7e:c0:b5:bc)
I (791) wifi:enable tsf
I (801) example_connect: Waiting for IP(s)
I (2841) wifi:new:<11,0>, old:<1,0>, ap:<255,255>, sta:<11,0>, prof:1
I (2851) wifi:state: init -> auth (b0)
I (2851) wifi:state: auth -> assoc (0)
I (2851) wifi:state: assoc -> run (10)
I (2861) wifi:connected with ElementsOfSound, aid = 6, channel 11, BW20, bssid = 60:e3:27:4e:03:20
I (2861) wifi:security: Open Auth, phy: bg, rssi: -61
I (2861) wifi:pm start, type: 1

I (2871) wifi:AP's beacon interval = 102400 us, DTIM period = 2
I (4591) example_connect: Got IPv6 event: Interface "example_connect: sta" address: fe80:0000:0000:0000:96b9:7eff:fec0:b5bc, type: ESP_IP6_ADDR_IS_LINK_LOCAL
I (351591) esp_netif_handlers: example_connect: sta ip: 192.168.0.124, mask: 255.255.255.0, gw: 192.168.0.2
I (351591) example_connect: Got IPv4 event: Interface "example_connect: sta" address: 192.168.0.124
I (351601) example_connect: Connected to example_connect: sta
I (351601) example_connect: - IPv4 address: 192.168.0.124
I (351611) example_connect: - IPv6 address: fe80:0000:0000:0000:96b9:7eff:fec0:b5bc, type: ESP_IP6_ADDR_IS_LINK_LOCAL
I (351621) example: Starting server on port: '80'
I (351631) example: Registering URI handlers
As can be seen it was 350 seconds after startup before an IP was obtained.

With my firmware application I am using a static IP address. This results in an immediate allocation of an IP, but it still takes around 30 seconds before I can ping the device or connect to a TCP/IP port. I used Wireshark to capture the traffic to my PC and found that no packets are being transmitted from the ESP32 except a Logical-Link Control broadcast message which occurs soon after startup. Then it takes around 30 seconds until it finally responds to ARP requests and transmits packets. By enabling LWIP and verbose ESP32 logging, I discovered that the packets are being received by the ESP32 and it appears to be at least trying to transmit response packets. I traced it down as far as the private function esp_wifi_internal_tx(), which returns 0 (ESP_OK), but the packet is never seen on the network, until after the long delay period after startup.

Any ideas why this ESP32 is having trouble transmitting packets after startup? I am going to delve into the Arduino code next to see if I can figure out what is making that work right, when the esp-idf applications do not.

ESP_Sprite
Posts: 8999
Joined: Thu Nov 26, 2015 4:08 am

Re: Slow Wifi initialization

Postby ESP_Sprite » Wed Oct 20, 2021 1:18 am

Possibly there's wrong calibration data in the flash... you could try erasing the entire flash before reprogramming the board. If not, you may just have a dud board on your hands.

Who is online

Users browsing this forum: Bing [Bot] and 118 guests