ESP32 外接LAN8720,GPIO0对其提供CLK,Ethernet例程初始化出错

kelly1947
Posts: 7
Joined: Mon Sep 16, 2019 6:49 am

ESP32 外接LAN8720,GPIO0对其提供CLK,Ethernet例程初始化出错

Postby kelly1947 » Tue Oct 15, 2019 11:25 am

我用ESP32外接LAN8720,因为要使用ESP32的第二路UART,只能使用GPIO0提供CLK。
使用的代码是IDF里的ethernet例子,报错如下:

Code: Select all

I (229) cpu_start: App cpu up.
I (247) heap_init: Initializing. RAM available for dynamic allocation:
I (254) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (260) heap_init: At 3FFB40A8 len 0002BF58 (175 KiB): DRAM
I (266) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (273) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (279) heap_init: At 400885D0 len 00017A30 (94 KiB): IRAM
I (285) cpu_start: Pro cpu start user code
I (303) cpu_start: Chip Revision: 1
W (303) cpu_start: Chip revision is higher than the one configured in menuconfig. Suggest to upgrade it.
I (307) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (319) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
E (1329) emac: Timed out waiting for PHY register 0x2 to have value 0x0007(mask 0xffff). Current value 0xffff
E (2329) emac: Timed out waiting for PHY register 0x3 to have value 0xc0f0(mask 0xfff0). Current value 0xffff
E (2329) emac: Initialise PHY device Timeout
ESP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x40084140
0x40084140: _esp_error_check_failed at /mnt/hgfs/workspace/esp32/IDF/esp-idf-v3.3/components/esp32/panic.c:720

file: "/mnt/hgfs/workspace/esp32/project/ethernet/main/ethernet_example_main.c" line 153
func: app_main
expression: esp_eth_enable()

ELF file SHA256: 597d55ebf237c1cffa5f47c73148a159b22726d94a7b78100bd941d7d5fc906e

Backtrace: 0x40083cdc:0x3ffb5e80 0x40084143:0x3ffb5ea0 0x400d32c1:0x3ffb5ec0 0x400d1742:0x3ffb5f20 0x40085d91:0x3ffb5f40
0x40083cdc: invoke_abort at /mnt/hgfs/workspace/esp32/IDF/esp-idf-v3.3/components/esp32/panic.c:715

0x40084143: _esp_error_check_failed at /mnt/hgfs/workspace/esp32/IDF/esp-idf-v3.3/components/esp32/panic.c:721

0x400d32c1: app_main at /mnt/hgfs/workspace/esp32/project/ethernet/main/ethernet_example_main.c:153 (discriminator 1)

0x400d1742: main_task at /mnt/hgfs/workspace/esp32/IDF/esp-idf-v3.3/components/esp32/cpu_start.c:542

0x40085d91: vPortTaskWrapper at /mnt/hgfs/workspace/esp32/IDF/esp-idf-v3.3/components/freertos/port.c:403


Rebooting...
使用的Example Config如下:

Code: Select all

#
# Example Configuration
#
CONFIG_PHY_IP101=
CONFIG_PHY_TLK110=
CONFIG_PHY_LAN8720=y
CONFIG_PHY_ADDRESS=1
CONFIG_PHY_CLOCK_GPIO0_IN=y
CONFIG_PHY_CLOCK_GPIO0_OUT=
CONFIG_PHY_CLOCK_GPIO16_OUT=
CONFIG_PHY_CLOCK_GPIO17_OUT=
CONFIG_PHY_CLOCK_MODE=0
CONFIG_PHY_USE_POWER_PIN=y
CONFIG_PHY_POWER_PIN=5
CONFIG_PHY_SMI_MDC_PIN=23
CONFIG_PHY_SMI_MDIO_PIN=18
请问这个是在哪里出了问题呢?我看了官方的开发板也是使用了IO0提供CLK给IP101,且我测试了代码是可以用的。

ESP_houwenxiang
Posts: 118
Joined: Tue Jun 26, 2018 3:09 am

Re: ESP32 外接LAN8720,GPIO0对其提供CLK,Ethernet例程初始化出错

Postby ESP_houwenxiang » Fri Oct 18, 2019 11:50 am

Hi
请检查 IO0 上是否有电容, 作为 CLK 输出 pin 的时候最好 IO0 上没有接电容, 这会影响时序.

谢谢!!
wookooho

chenlei2830
Posts: 1
Joined: Sun Mar 29, 2020 12:58 pm

Re: ESP32 外接LAN8720,GPIO0对其提供CLK,Ethernet例程初始化出错

Postby chenlei2830 » Sun Mar 29, 2020 1:00 pm

你好,我也遇到类似的问题了,请问您是怎么解决的。

ESP_morris
Posts: 290
Joined: Wed Sep 05, 2018 6:23 am

Re: ESP32 外接LAN8720,GPIO0对其提供CLK,Ethernet例程初始化出错

Postby ESP_morris » Wed Apr 08, 2020 7:31 am

GPIO0 输出RMII时钟切记在Kconfig中要勾选 CONFIG_PHY_CLOCK_GPIO0_OUT

另外,以太网部分除了可以参考example中的README讲解,也可以参阅官方的API Reference 文档:https://docs.espressif.com/projects/esp ... p_eth.html

simon2020
Posts: 5
Joined: Tue Apr 28, 2020 2:44 pm

Re: ESP32 外接LAN8720,GPIO0对其提供CLK,Ethernet例程初始化出错

Postby simon2020 » Tue Apr 28, 2020 2:59 pm

我也是接的lan8720,用gpio0输出波,用示波器检测gpio0有50mhz的时钟,但是没法正常工作,得不到IP地址,是不是要把gpio0的相位翻转一下,请问软件里怎么翻转gpio0的相位。

ESP_morris
Posts: 290
Joined: Wed Sep 05, 2018 6:23 am

Re: ESP32 外接LAN8720,GPIO0对其提供CLK,Ethernet例程初始化出错

Postby ESP_morris » Thu May 07, 2020 3:56 am

simon2020 wrote:
Tue Apr 28, 2020 2:59 pm
我也是接的lan8720,用gpio0输出波,用示波器检测gpio0有50mhz的时钟,但是没法正常工作,得不到IP地址,是不是要把gpio0的相位翻转一下,请问软件里怎么翻转gpio0的相位。
软件翻转GPIO0的时钟相位做不到,只能硬件加个反相器。
得不到IP地址就是因为RMII时钟在MAC侧和PHY侧的相位偏差太大,无法同步。
建议还是使用晶振提供该RMII时钟,更稳定。

Who is online

Users browsing this forum: No registered users and 48 guests