You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WT32_ETH01运行ESP-IDF以太网示例无法获取IP地址求助

WT32_ETH01运行ESP-IDF ethernet-basic示例DHCP无法获取IP问题

问题现象

  • 在WT32_ETH01开发板上运行ESP-IDF的ethernet-basic示例,PHY连接状态正常,但始终无法从路由器获取IP地址
  • 用笔记本搭建tftpd64 DHCP服务器,测试其他设备可正常获取IP,但WT32_ETH01连接后仍无法获取
  • Wireshark抓包显示,WT32_ETH01仅能接收DHCP服务器发送的消息,自身无任何数据发送
  • 添加代码esp_err_t retv = esp_netif_dhcpc_start(eth_netif);后问题无改善,设备仍卡在DHCP发现阶段,接收的数据包被丢弃

串口输出日志

启动阶段日志

I (31) boot: ESP-IDF v5.1.1-dirty 2nd stage bootloader
I (31) boot: compile time Sep 25 2023 17:17:25        
I (31) boot: Multicore bootloader
I (36) boot: chip revision: v1.1
I (39) boot.esp32: SPI Speed      : 40MHz
I (44) boot.esp32: SPI Mode       : DIO
I (49) boot.esp32: SPI Flash Size : 2MB
I (53) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (62) boot: ## Label            Usage          Type ST Offset   Length
I (69) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (77) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (84) boot:  2 factory          factory app      00 00 00010000 00100000
I (92) boot: End of partition table
I (96) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=15898h ( 88216) map
I (136) esp_image: segment 1: paddr=000258c0 vaddr=3ffb0000 size=021c8h (  8648) load
I (140) esp_image: segment 2: paddr=00027a90 vaddr=40080000 size=08588h ( 34184) load
I (156) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=2a230h (172592) map
I (219) esp_image: segment 4: paddr=0005a258 vaddr=40088588 size=04398h ( 17304) load
I (233) boot: Loaded app from partition at offset 0x10000
I (233) boot: Disabling RNG early entropy source...
I (244) cpu_start: Multicore app
I (245) cpu_start: Pro cpu up.
I (245) cpu_start: Starting app cpu, entry point is 0x40081204
0x40081204: call_start_cpu1 at C:/Espressif/frameworks/esp-idf-v5.1.1/components/esp_system/port/cpu_start.c:154

I (0) cpu_start: App cpu up.
I (263) cpu_start: Pro cpu start user code
I (263) cpu_start: cpu freq: 160000000 Hz
I (263) cpu_start: Application information:
I (267) cpu_start: Project name:     ethernet_basic
I (273) cpu_start: App version:      1
I (277) cpu_start: Compile time:     Oct  1 2023 15:10:22
I (284) cpu_start: ELF file SHA256:  ca123a482e4a6baa...
I (290) cpu_start: ESP-IDF:          v5.1.1-dirty
I (295) cpu_start: Min chip rev:     v0.0
I (300) cpu_start: Max chip rev:     v3.99 
I (304) cpu_start: Chip rev:         v1.1
I (309) heap_init: Initializing. RAM available for dynamic allocation:
I (317) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (322) heap_init: At 3FFB2E48 len 0002D1B8 (180 KiB): DRAM
I (329) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (335) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (341) heap_init: At 4008C920 len 000136E0 (77 KiB): IRAM
I (349) spi_flash: detected chip: generic
I (352) spi_flash: flash io: dio
W (356) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (370) app_start: Starting scheduler on CPU0
I (374) app_start: Starting scheduler on CPU1
I (374) main_task: Started on CPU0
I (384) main_task: Calling app_main()
netif: netmask of interface  set to 255.0.0.0
netif: GW address of interface  set to 127.0.0.1
netif_set_ipaddr: netif address being changed
netif: added interface lo IP addr 127.0.0.1 netmask 255.0.0.0 gw 127.0.0.1
dns_init: initializing
I (424) esp_eth.netif.netif_glue: 80:64:6f:e9:ed:57
I (424) esp_eth.netif.netif_glue: ethernet attached to netif
etharp_timer

DHCP启动后日志

dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
netif: added interface en IP addr 0.0.0.0 netmask 0.0.0.0 gw 0.0.0.0I (3334) main_task: Returned from app_main()

I (3334) eth_example: Ethernet Started
netif: setting default interface en
dhcp_start(netif=0x3ffbb73c) en1
dhcp_start(): restarting DHCP configuration
dhcp_start(): starting DHCP configuration
udp_bind(ipaddr = 0.0.0.0, port = 68)
udp_bind: bound to 0.0.0.0, port 68)
udp_connect: connected to 0.0.0.0, port 67)
dhcp_discover()
dhcp_discover(): dhcp state is DISCOVER
dhcp_select: could not allocate DHCP request
pbuf_alloc(length=308)
pbuf_alloc(length=308) == 0x3ffb41fc
transaction id xid(62b99c8b)
dhcp_discover: making request
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, LWIP_IANA_PORT_DHCP_SERVER)
pbuf_add_header: old 0x3ffb4244 new 0x3ffb423c (8)
udp_send: added header in given pbuf 0x3ffb41fc
udp_send: sending datagram of length 316
udp_send: UDP packet length 316
emac_esp32_rx_task() received frame of len: 60
udp_send: UDP checksum 0xcc48
udp_send: ip_output_if (,,,,0x11,)
pbuf_add_header: old 0x3ffb423c new 0x3ffb4228 (20)
pbuf_alloced_custom(length=60)
ip4_output_if: en1
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |       336     | (v, hl, tos, len)
+-------------------------------+
|        0      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |   17  |    0xba9d     | (ttl, proto, chksum)
+-------------------------------+
|    0  |    0  |    0  |    0  | (src)
+-------------------------------+
|  255  |  255  |  255  |  255  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
pbuf_add_header: old 0x3ffb4228 new 0x3ffb421a (14)
ethernet_output: sending packet 0x3ffb41fc
dhcp_discover: deleting()ing
pbuf_free(0x3ffb41fc)
pbuf_free: deallocating 0x3ffb41fc
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 500 msecs
etharp_timer
I (3484) eth_example: Ethernet Link Up
dhcp_coarse_tmr()
I (3494) eth_example: Ethernet HW Addr 80:64:6f:e9:ed:57

后续循环日志

ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:f0:de:f1:95:fa:52, type:806
pbuf_remove_header: old 0x3ffafbcc new 0x3ffafbda (14)
etharp_update_arp_entry: 0.0.0.0 - f0:de:f1:95:fa:52
etharp_update_arp_entry: will not add non-unicast IP address to ARP cache
etharp_input: incoming ARP request
etharp_input: we are unconfigured, ARP request ignored.
pbuf_free(0x3ffafc0c)
pbuf_free: deallocating 0x3ffafc0c
dhcp_fine_tmr(): request timeout
dhcp_timeout()
dhcp_timeout(): restarting discovery
dhcp_discover()
dhcp_discover(): dhcp state is DISCOVER
dhcp_select: could not allocate DHCP request
pbuf_alloc(length=308)
pbuf_alloc(length=308) == 0x3ffb41fc
transaction id xid(62b99c8b)
dhcp_discover: making request
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, LWIP_IANA_PORT_DHCP_SERVER)
pbuf_add_header: old 0x3ffb4244 new 0x3ffb423c (8)
udp_send: added header in given pbuf 0x3ffb41fc
udp_send: sending datagram of length 316
udp_send: UDP packet length 316
udp_send: UDP checksum 0xcc48
udp_send: ip_output_if (,,,,0x11,)
pbuf_add_header: old 0x3ffb423c new 0x3ffb4228 (20)
ip4_output_if: en1
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |       336     | (v, hl, tos, len)
+-------------------------------+
|        1      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |   17  |    0xba9c     | (ttl, proto, chksum)
+-------------------------------+
|    0  |    0  |    0  |    0  | (src)
+-------------------------------+
|  255  |  255  |  255  |  255  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
pbuf_add_header: old 0x3ffb4228 new 0x3ffb421a (14)
ethernet_output: sending packet 0x3ffb41fc
dhcp_discover: deleting()ing
pbuf_free(0x3ffb41fc)
pbuf_free: deallocating 0x3ffb41fc
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 1000 msecs
emac_esp32_rx_task() received frame of len: 60
pbuf_alloced_custom(length=60)
ethernet_input: dest:01:80:c2:00:00:0e, src:f0:de:f1:95:fa:52, type:88cc
pbuf_free(0x3ffafcd0)
pbuf_free: deallocating 0x3ffafcd0
emac_esp32_rx_task() received frame of len: 60
pbuf_alloced_custom(length=60)
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:f0:de:f1:95:fa:52, type:806
pbuf_remove_header: old 0x3ffafc90 new 0x3ffafc9e (14)
etharp_update_arp_entry: 0.0.0.0 - f0:de:f1:95:fa:52
etharp_update_arp_entry: will not add non-unicast IP address to ARP cache
etharp_input: incoming ARP request
etharp_input: we are unconfigured, ARP request ignored.
pbuf_free(0x3ffafcd0)
pbuf_free: deallocating 0x3ffafcd0
etharp_timer
dhcp_coarse_tmr()
dhcp_fine_tmr(): request timeout

排查方向与解决建议

  • 硬件与PHY配置检查
    • 确认WT32_ETH01的PHY地址配置,该板常用PHY地址为0或1,检查SDK配置中CONFIG_ETH_PHY_ADDR是否匹配硬件实际值
    • 更换网线或测试其他网口,排除物理链路故障;验证开发板以太网供电稳定性,必要时外接电源测试
  • LWIP与DHCP参数调整
    • 开启LWIP详细调试日志,追踪DHCP请求的发送流程,确认数据包是否真的从硬件发出
    • 关闭CONFIG_LWIP_DHCP_DOES_ARP_CHECK选项,避免ARP检查逻辑阻塞DHCP请求发送
    • 增大LWIP缓冲区参数,比如CONFIG_LWIP_TCP_MSS、CONFIG_LWIP_SO_RCVBUF,解决可能的内存分配不足问题
  • 驱动与SDK版本修复
    • 当前使用的ESP-IDF为v5.1.1-dirty,存在非官方修改,建议切换到官方稳定版v5.1.2或v5.2,排除版本问题
    • 核对以太网驱动的GPIO配置,确保MDIO、MDC等引脚定义与WT32_ETH01硬件一致
  • 静态IP验证链路
    • 临时关闭DHCP,手动配置静态IP、子网掩码和网关,测试设备是否能与局域网内其他设备通信,验证底层以太网链路是否正常

内容的提问来源于stack exchange,提问作者Malinko

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 18:42:01