ESP32-C3使用WIFI_STA例程卡死在初始化(phy_init:)
Posted: Wed Mar 30, 2022 2:29 am
ESP32-C3使用的是官方MINI模块,但是板子是自制的,前段时间跑通了LVGL很高兴,昨天开始尝试WIFI。
事情最初是这样子的:
1. 使用IDF里的station模式例程做测试发现烧录完Monitor直接输出报错,没有芯片启动log信息。而且网上说辞不一,定位不了问题。
2. 于是开始排查问题,在例程的nvs初始化后、wifi初始化之前加入延迟,烧录后Monitor成功看到BootLoader等log信息。
代码:
LOG输出:
然后就卡住了,没有像网络教程那样有后面的输出,比如连接WiFi的ssid密码以及是否成功或尝试重连等。而且感觉芯片会卡死,关闭再启动Monitor又会回到不加延迟的报错OSError: [Errno 71] Protocol error,且不可再正常烧录,需要拉低IO9进入下载模式才行。
3. 参考了本论坛中/英板块可能类似的问题,擦除flash、关闭nvs等操作,大多结果都差不多,只不过擦除第一次可能多一句:
目前排查的情况就是这些了,如我有什么疏漏的地方请告知我,有解决的可能思路请尽管提出,十分感谢各位。下一步计划是换一块模块看看情况,以及想请问这个phy init具体的情况,该配置是否可以更换版本,我看网上其他人log输出的版本不一样,会不会是该原因?
事情最初是这样子的:
1. 使用IDF里的station模式例程做测试发现烧录完Monitor直接输出报错,没有芯片启动log信息。而且网上说辞不一,定位不了问题。
- Exception in thread Thread-2 (_run_outer):
- Traceback (most recent call last):
- File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
- self.run()
- File "/usr/lib/python3.10/threading.py", line 946, in run
- self._target(*self._args, **self._kwargs)
- File "/home/kying/esp/esp-idf/tools/idf_monitor_base/stoppable_thread.py", line 58, in _run_outer
- self.run()
- File "/home/kying/esp/esp-idf/tools/idf_monitor_base/serial_reader.py", line 51, in run
- self.serial.open()
- File "/home/kying/.espressif/python_env/idf4.4_py3.10_env/lib/python3.10/site-packages/serial/serialposix.py", line 338, in open
- self._update_rts_state()
- File "/home/kying/.espressif/python_env/idf4.4_py3.10_env/lib/python3.10/site-packages/serial/serialposix.py", line 708, in _update_rts_state
- fcntl.ioctl(self.fd, TIOCMBIC, TIOCM_RTS_str)
- OSError: [Errno 71] Protocol error
代码:
- esp_err_t ret = nvs_flash_init();
- 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();
- }
- ESP_ERROR_CHECK(ret);
- ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
- printf("---------------- WiFi START! -----------------\n");
- vTaskDelay(5000/portTICK_RATE_MS);
- wifi_init_sta();
- ESP-ROM:esp32c3-api1-20210207
- Build:Feb 7 2021
- rst:0x15 (USB_UART_CHIP_RESET),boot:0xf (SPI_FAST_FLASH_BOOT)
- Saved PC:0x420515b8
- 0x420515b8: cpu_ll_waiti at /home/kying/esp/esp-idf/components/hal/esp32c3/include/hal/cpu_ll.h:168
- (inlined by) esp_pm_impl_waiti at /home/kying/esp/esp-idf/components/esp_pm/pm_impl.c:837
- SPIWP:0xee
- mode:DIO, clock div:1
- load:0x3fcd6100,len:0x16b8
- load:0x403ce000,len:0x930
- load:0x403d0000,len:0x2d40
- entry 0x403ce000
- I (24) boot: ESP-IDF v4.4-dirty 2nd stage bootloader
- I (24) boot: compile time 19:46:22
- I (25) boot: chip revision: 3
- I (26) boot.esp32c3: SPI Speed : 80MHz
- I (31) boot.esp32c3: SPI Mode : DIO
- I (36) boot.esp32c3: SPI Flash Size : 4MB
- I (41) boot: Enabling RNG early entropy source...
- I (46) boot: Partition Table:
- I (50) boot: ## Label Usage Type ST Offset Length
- I (57) boot: 0 nvs WiFi data 01 02 00009000 00006000
- I (64) boot: 1 phy_init RF data 01 01 0000f000 00001000
- I (72) boot: 2 factory factory app 00 00 00010000 00100000
- I (79) boot: End of partition table
- I (83) esp_image: segment 0: paddr=00010020 vaddr=3c080020 size=134e8h ( 79080) map
- I (104) esp_image: segment 1: paddr=00023510 vaddr=3fc8e200 size=02b4ch ( 11084) load
- I (107) esp_image: segment 2: paddr=00026064 vaddr=40380000 size=09fb4h ( 40884) load
- I (118) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=74e24h (478756) map
- I (193) esp_image: segment 4: paddr=000a4e4c vaddr=40389fb4 size=04118h ( 16664) load
- I (197) esp_image: segment 5: paddr=000a8f6c vaddr=50000010 size=00010h ( 16) load
- I (204) boot: Loaded app from partition at offset 0x10000
- I (205) boot: Disabling RNG early entropy source...
- I (222) cpu_start: Pro cpu up.
- I (230) cpu_start: Pro cpu start user code
- I (230) cpu_start: cpu freq: 160000000
- I (231) cpu_start: Application information:
- I (233) cpu_start: Project name: wifi_station
- I (239) cpu_start: App version: 1
- I (243) cpu_start: Compile time: Mar 29 2022 20:30:59
- I (249) cpu_start: ELF file SHA256: f2b0456acb581f1b...
- I (255) cpu_start: ESP-IDF: v4.4-dirty
- I (260) heap_init: Initializing. RAM available for dynamic allocation:
- I (268) heap_init: At 3FC94CC0 len 0002B340 (172 KiB): DRAM
- I (274) heap_init: At 3FCC0000 len 0001F060 (124 KiB): STACK/DRAM
- I (281) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM
- I (287) spi_flash: detected chip: generic
- I (292) spi_flash: flash io: dio
- I (296) sleep: Configure to isolate all GPIO pins in sleep state
- I (302) sleep: Enable automatic switching of GPIO sleep configuration
- I (310) cpu_start: Starting scheduler.
- I (321) wifi station: ESP_WIFI_MODE_STA
- ---------------- WiFi START! -----------------
- I (5321) pp: pp rom version: 9387209
- I (5321) net80211: net80211 rom version: 9387209
- I (5331) wifi:wifi driver task: 3fc9d908, prio:23, stack:6656, core=0
- I (5331) system_api: Base MAC address is not set
- I (5331) system_api: read default base MAC address from EFUSE
- I (5341) wifi:wifi firmware version: 7679c42
- I (5341) wifi:wifi certification version: v7.0
- I (5341) wifi:config NVS flash: enabled
- I (5341) wifi:config nano formating: disabled
- I (5351) wifi:Init data frame dynamic rx buffer num: 32
- I (5351) wifi:Init management frame dynamic rx buffer num: 32
- I (5361) wifi:Init management short buffer num: 32
- I (5361) wifi:Init dynamic tx buffer num: 32
- I (5371) wifi:Init static tx FG buffer num: 2
- I (5371) wifi:Init static rx buffer size: 1600
- I (5381) wifi:Init static rx buffer num: 10
- I (5381) wifi:Init dynamic rx buffer num: 32
- I (5381) wifi_init: rx ba win: 6
- I (5391) wifi_init: tcpip mbox: 32
- I (5391) wifi_init: udp mbox: 6
- I (5401) wifi_init: tcp mbox: 6
- I (5401) wifi_init: tcp tx win: 5744
- I (5401) wifi_init: tcp rx win: 5744
- I (5411) wifi_init: tcp mss: 1440
- I (5411) wifi_init: WiFi IRAM OP enabled
- I (5421) wifi_init: WiFi RX IRAM OP enabled
- I (5421) phy_init: phy_version 907,3369105-dirty,Dec 3 2021,14:55:12
3. 参考了本论坛中/英板块可能类似的问题,擦除flash、关闭nvs等操作,大多结果都差不多,只不过擦除第一次可能多一句:
但后面依旧卡死,没有log输出。起初网络上很多说这句Warnning是供电问题导致的,但我的设计使用的AMS1117-3.3供电理论支持1A MAX且加了10uf+0.1uf电容,我甚至后来拆了稳压芯片使用稳压源供电(USB仅提供Jtag调试)仍然有该行。后来论坛其他帖子和手册看到nvs擦除后就会回到full calibration,所以到头来大概不是供电问题。W (5634) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
目前排查的情况就是这些了,如我有什么疏漏的地方请告知我,有解决的可能思路请尽管提出,十分感谢各位。下一步计划是换一块模块看看情况,以及想请问这个phy init具体的情况,该配置是否可以更换版本,我看网上其他人log输出的版本不一样,会不会是该原因?