Page 1 of 1

LilyGo T-Eth-Lite problems

Posted: Sun Dec 10, 2023 3:39 pm
by simonjo
Hi,

I try to get LilyGo T-Eth-Lite to work with ESP-IDF 4.2, I use the ethernet-example code.

At first I got
E (556) emac_esp32: emac_esp32_init(308): reset timeout
E (556) esp_eth: esp_eth_driver_install(198): init mac failed

Which was caused by wrong CONFIG_EXAMPLE_ETH_PHY_RST_GPIO

So I checked all RMII vs GPIO settings and they seem to match
- GPIO21 TX_EN
- GPIO19 TX0
- GPIO22 TX1
- GPIO25 RX0
- GPIO26 RX1
- GPIO27 CRS_DV
- GPIO23 MDC
- GPIO18 MDIO
- GPIO12 PHYRST

Now I get following error...
I (399) system_api: Base MAC address is not set
I (399) system_api: read default base MAC address from EFUSE
E (399) rtl8201: rtl8201_pwrctl(239): power up failed
E (409) rtl8201: rtl8201_init(279): power control failed
E (409) esp_eth: esp_eth_driver_install(199): init phy failed
ESP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x4008402f
file: "../main/ethernet_example_main.c" line 131
func: app_main
expression: esp_eth_driver_install(&config, &eth_handle)


Anybody an idea where E (399)... comes from?

This is the code used:
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();

phy_config.phy_addr = CONFIG_EXAMPLE_ETH_PHY_ADDR;
phy_config.reset_gpio_num = CONFIG_EXAMPLE_ETH_PHY_RST_GPIO;

#if CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET
mac_config.smi_mdc_gpio_num = CONFIG_EXAMPLE_ETH_MDC_GPIO;
mac_config.smi_mdio_gpio_num = CONFIG_EXAMPLE_ETH_MDIO_GPIO;
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config);

esp_eth_phy_t *phy = esp_eth_phy_new_rtl8201(&phy_config);

esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
esp_eth_handle_t eth_handle = NULL;

ESP_ERROR_CHECK(esp_eth_driver_install(&config, &eth_handle));
/* attach Ethernet driver to TCP/IP stack */
ESP_ERROR_CHECK(esp_netif_attach(eth_netif, esp_eth_new_netif_glue(eth_handle)));
/* start Ethernet driver state machine */
ESP_ERROR_CHECK(esp_eth_start(eth_handle));

Re: LilyGo T-Eth-Lite problems

Posted: Sun Dec 10, 2023 7:46 pm
by simonjo
After digging into the RTL8201 PHY implementation it seems like the problem has to do with a wrong init setting in the example code.

Original is says
phy_config.phy_addr = CONFIG_EXAMPLE_ETH_PHY_ADDR; // 1

This 1 seems to be wrong, so I changed it to
phy_config.phy_addr = ESP_ETH_PHY_ADDR_AUTO; // -1

This lets the PHY driver resolve the address and now it works straight ;)