ESP32-C3使用WIFI_STA例程卡死在初始化(phy_init:)

k_ying
Posts: 3
Joined: Tue Mar 29, 2022 1:22 pm

ESP32-C3使用WIFI_STA例程卡死在初始化(phy_init:)

Postby k_ying » Wed Mar 30, 2022 2:29 am

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

k_ying
Posts: 3
Joined: Tue Mar 29, 2022 1:22 pm

Re: ESP32-C3使用WIFI_STA例程卡死在初始化(phy_init:)

Postby k_ying » Thu Mar 31, 2022 5:01 am

用另一块相同设计的备用电路板,焊上另一块新买的C3-MINI模块,烧录相同的代码、正常了 :o 应该只是之前那块射频莫名有问题...

k_ying
Posts: 3
Joined: Tue Mar 29, 2022 1:22 pm

Re: ESP32-C3使用WIFI_STA例程卡死在初始化(phy_init:)

Postby k_ying » Tue Apr 05, 2022 5:50 am

又做了一版硬件,发现其实不是芯片的问题,是WiFi启动后不能用Jtag调试口IO18、IO19吗?我用串口调试才能收到后面的输出...

Who is online

Users browsing this forum: No registered users and 63 guests