Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Instability in Ethernet connections with RTL8201FI #11304

Unanswered
danieldecesaro asked this question in Q&A
Discussion options

Board

ESP32-WROOM

Device Description

ESP32-WROOM-32 + RTL8201FI with external oscilator

Hardware Configuration

ETH_CLK_MODE ETH_CLOCK_GPIO0_IN
ETH_POWER_PIN -1
ETH_TYPE ETH_PHY_RTL8201
ETH_ADDR 0
ETH_MDC_PIN 23
ETH_MDIO_PIN 18

Version

v2.0.9

IDE Name

Sloeber

Operating System

Windows 11

Flash frequency

80MHz

PSRAM enabled

yes

Upload speed

115200

Description

Hello everyone,

I'm changing my hardware project to use the RTL8201 instead of the LAN8720A.

The problem is that I can't get a stable connection with this new IC. When I start the communication, I can't always connect, and when I remove the cable and reconnect it, I don't receive the reconnection event. Can anyone help me with this???

I created a firmware as a proof of concept, below, along with the execution logs.

I'm using version 2.0.9 of the core, since this is the version that the rest of the project is based on, and a change would be extremely honorable.

Sketch

#include "Arduino.h"

                  #include <ETH.h>
                  #include <WiFi.h>
                  #include <ESPmDNS.h>
                  #include <DNSServer.h>
                
                  const char *WIFI_TAG = "RTL_8201";
                  
                  #ifdef ETH_CLK_MODE
                  #undef ETH_CLK_MODE
                  #endif
                  
                  // DNS Server
                  DNSServer dnsServer;
                  const byte DNSSERVER_PORT = 53;
                  const char *host = "RTL8201_test";
                  
                  #define ETH_CLK_MODE	ETH_CLOCK_GPIO0_IN
                  
                  // Pin# of the enable signal for the external crystal oscillator (-1 to disable for internal APLL source)
                  #define ETH_POWER_PIN   -1 //16
                  
                  // Type of the Ethernet PHY (LAN8720 or TLK110)
                  #define ETH_TYPE        ETH_PHY_RTL8201
                  
                  // I²C-address of Ethernet PHY (0 or 1 for LAN8720, 31 for TLK110)
                  #define ETH_ADDR        0
                  
                  // Pin# of the I²C clock signal for the Ethernet PHY
                  #define ETH_MDC_PIN     23
                  
                  // Pin# of the I²C IO signal for the Ethernet PHY
                  #define ETH_MDIO_PIN    18
                  
                  #define ETH_RST_PIN		17
                  
                  #define CONFIG_ETH_ENABLED 1
                  
                  void startmDNS() {
                      MDNS.end();
                      if (MDNS.begin(host)) {
	                      MDNS.addService("http", "tcp", 80);
	                      ESP_LOGI(WIFI_TAG, "mDNS inicializado em: 'http://%s.local", host);
                      } else {
	                      ESP_LOGE(WIFI_TAG, "Falha ao iniciar mDNS");
                      }
                  }
                  
                  String ipStr(const IPAddress &ip) {
                      // Retorna IPAddress em formato "n.n.n.n"
                      String sFn = "";
                      for (byte bFn = 0; bFn < 3; bFn++) {
	                      sFn += String((ip >> (8 * bFn)) & 0xFF) + ".";
                      }
                      sFn += String(((ip >> 8 * 3)) & 0xFF);
                      return sFn;
                  }
                  
                  void wifiEvent(WiFiEvent_t event) {
                      ESP_LOGI(WIFI_TAG, "EVENTO: %u", event);
                  }
                  
                  void EthConnected(WiFiEvent_t event, WiFiEventInfo_t info) {
                      ESP_LOGD(WIFI_TAG, "Cabo Ethernet conectado");
                  }
                  
                  void EthDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
                      ESP_LOGD(WIFI_TAG, "Cabo ethernet desconectado - razão: %u", info.wifi_sta_disconnected.reason);
                  }
                  
                  void EthGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
                      ESP_LOGI(WIFI_TAG, "ETHERNET IP: %s", ipStr(ETH.localIP()).c_str());
                      if (WiFi.isConnected()) {
	                      WiFi.disconnect();
	                      ESP_LOGE(WIFI_TAG, "WiFi Desconectado...");
                      }
                  
                      startmDNS();
                  }
                  
                  //void resetRTL(){
                  //	digitalWrite(ETH_RST_PIN, LOW);
                  //	digitalWrite(ETH_POWER_PIN, LOW);
                  //	delay(100);
                  //	digitalWrite(ETH_POWER_PIN, HIGH);
                  //	delay(100);
                  //	digitalWrite(ETH_RST_PIN, HIGH);
                  //
                  //	delay(1000);
                  //}
                  
                  bool ethernetConnect() {
                      ESP_LOGD(WIFI_TAG, "Inicializando Ethernet");
                  
                      pinMode(ETH_RST_PIN, OUTPUT);
                  
                      digitalWrite(ETH_RST_PIN, LOW);
                      delay(25);
                      digitalWrite(ETH_RST_PIN, HIGH);
                      delay(100);
                  
                      //resetRTL();
                      if (ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE)) {
	                      ETH.setHostname(host);
                  
	                      ESP_LOGI(WIFI_TAG, "SPEED: %d", ETH.linkSpeed());
	                      ESP_LOGI(WIFI_TAG, "HOSTNAME: %s", ETH.getHostname());
                  
	                      delay(3000);
	                      return true;
                      }
                      return false;
                  }
                  
                  void startNetwork() {
                      WiFi.onEvent(wifiEvent);
                  
                      WiFi.onEvent(EthConnected, ARDUINO_EVENT_ETH_CONNECTED);
                      WiFi.onEvent(EthGotIP, ARDUINO_EVENT_ETH_GOT_IP);
                      WiFi.onEvent(EthDisconnected, ARDUINO_EVENT_ETH_DISCONNECTED);
                  
                      ethernetConnect();
                  }
                  
                  void setup() {
                      esp_log_level_set("*", ESP_LOG_VERBOSE);
                  
                      Serial.begin(115200);
                      Serial.setDebugOutput(true);
                      Serial.print("\n");
                  
                      esp_log_level_set("*", ESP_LOG_VERBOSE);
                  
                      startNetwork();
                  }
                  
                  uint8_t count = 0;
                  void loop() {
                      ETH.linkUp() ? ESP_LOGD(WIFI_TAG, "LINK UP!!!") : ESP_LOGD(WIFI_TAG, "LINK DOWN!!!");
                      delay(5000);
                      if (++count == 10)
	                      ESP.restart();
                  }

Debug Message

[ 28][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz

[ 61][D][RTL8201_test.ino:94] ethernetConnect(): [RTL_8201] Inicializando Ethernet
[ 2729][V][WiFiGeneric.cpp:437] _arduino_event_cb(): Ethernet Started
[ 2730][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 18 - ETH_START
[ 2732][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 18
[ 2738][V][WiFiGeneric.cpp:430] _arduino_event_cb(): Ethernet Link Up
[ 2744][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 20 - ETH_CONNECTED
[ 2752][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 20
[ 2758][D][RTL8201_test.ino:65] EthConnected(): [RTL_8201] Cabo Ethernet conectado
[ 2788][I][RTL8201_test.ino:107] ethernetConnect(): [RTL_8201] SPEED: 100
[ 2789][I][RTL8201_test.ino:108] ethernetConnect(): [RTL_8201] HOSTNAME: RTL8201_test
[ 3754][V][WiFiGeneric.cpp:445] _arduino_event_cb(): Ethernet got newip:192.168.1.229
[ 3754][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 22 - ETH_GOT_IP
[ 3758][D][WiFiGeneric.cpp:1137] _eventCallback(): ETH IP: 192.168.1.229, MASK: 255.255.255.0, GW: 192.168.1.1
[ 3768][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 22
[ 3774][I][RTL8201_test.ino:73] EthGotIP(): [RTL_8201] ETHERNET IP: 192.168.1.229
[ 3792][I][RTL8201_test.ino:44] startmDNS(): [RTL_8201] mDNS inicializado em: 'http://RTL8201_test.local
[ 5791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 10791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 15791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 20791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 25791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 30791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 35791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 40791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 45791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 50791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 28][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz

[ 61][D][RTL8201_test.ino:94] ethernetConnect(): [RTL_8201] Inicializando Ethernet
[ 4229][V][WiFiGeneric.cpp:437] _arduino_event_cb(): Ethernet Started
[ 4230][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 18 - ETH_START
[ 4232][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 18
[ 4279][I][RTL8201_test.ino:107] ethernetConnect(): [RTL_8201] SPEED: 10
[ 4280][I][RTL8201_test.ino:108] ethernetConnect(): [RTL_8201] HOSTNAME: RTL8201_test
[ 7282][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 12282][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 17282][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 22282][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 27282][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 32282][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 37282][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 42282][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 47282][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 52282][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 28][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz

[ 61][D][RTL8201_test.ino:94] ethernetConnect(): [RTL_8201] Inicializando Ethernet
[ 2730][V][WiFiGeneric.cpp:437] _arduino_event_cb(): Ethernet Started
[ 2730][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 18 - ETH_START
[ 2732][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 18
[ 2738][V][WiFiGeneric.cpp:430] _arduino_event_cb(): Ethernet Link Up
[ 2744][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 20 - ETH_CONNECTED
[ 2752][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 20
[ 2758][D][RTL8201_test.ino:65] EthConnected(): [RTL_8201] Cabo Ethernet conectado
[ 2788][I][RTL8201_test.ino:107] ethernetConnect(): [RTL_8201] SPEED: 100
[ 2789][I][RTL8201_test.ino:108] ethernetConnect(): [RTL_8201] HOSTNAME: RTL8201_test
[ 3747][V][WiFiGeneric.cpp:445] _arduino_event_cb(): Ethernet got newip:192.168.1.229
[ 3747][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 22 - ETH_GOT_IP
[ 3751][D][WiFiGeneric.cpp:1137] _eventCallback(): ETH IP: 192.168.1.229, MASK: 255.255.255.0, GW: 192.168.1.1
[ 3760][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 22
[ 3766][I][RTL8201_test.ino:73] EthGotIP(): [RTL_8201] ETHERNET IP: 192.168.1.229
[ 3785][I][RTL8201_test.ino:44] startmDNS(): [RTL_8201] mDNS inicializado em: 'http://RTL8201_test.local
[ 5791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 10791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 15791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 20791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 25791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 30791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 35791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 40791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 42739][V][WiFiGeneric.cpp:434] _arduino_event_cb(): Ethernet Link Down
[ 42739][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 21 - ETH_DISCONNECTED
[ 42742][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 21
[ 42748][D][RTL8201_test.ino:69] EthDisconnected(): [RTL_8201] Cabo ethernet desconectado - razão: 0
[ 45791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 50791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 28][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz

[ 61][D][RTL8201_test.ino:94] ethernetConnect(): [RTL_8201] Inicializando Ethernet
[ 2730][V][WiFiGeneric.cpp:437] _arduino_event_cb(): Ethernet Started
[ 2730][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 18 - ETH_START
[ 2732][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 18
[ 2738][V][WiFiGeneric.cpp:430] _arduino_event_cb(): Ethernet Link Up
[ 2744][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 20 - ETH_CONNECTED
[ 2752][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 20
[ 2758][D][RTL8201_test.ino:65] EthConnected(): [RTL_8201] Cabo Ethernet conectado
[ 2788][I][RTL8201_test.ino:107] ethernetConnect(): [RTL_8201] SPEED: 100
[ 2789][I][RTL8201_test.ino:108] ethernetConnect(): [RTL_8201] HOSTNAME: RTL8201_test
[ 3747][V][WiFiGeneric.cpp:445] _arduino_event_cb(): Ethernet got newip:192.168.1.229
[ 3747][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 22 - ETH_GOT_IP
[ 3751][D][WiFiGeneric.cpp:1137] _eventCallback(): ETH IP: 192.168.1.229, MASK: 255.255.255.0, GW: 192.168.1.1
[ 3760][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 22
[ 3766][I][RTL8201_test.ino:73] EthGotIP(): [RTL_8201] ETHERNET IP: 192.168.1.229
[ 3785][I][RTL8201_test.ino:44] startmDNS(): [RTL_8201] mDNS inicializado em: 'http://RTL8201_test.local
[ 5791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 10791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!
[ 12739][V][WiFiGeneric.cpp:434] _arduino_event_cb(): Ethernet Link Down
[ 12739][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 21 - ETH_DISCONNECTED
[ 12742][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 21
[ 12748][D][RTL8201_test.ino:69] EthDisconnected(): [RTL_8201] Cabo ethernet desconectado - razão: 0
[ 15791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 20791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 25791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 30791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 35791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 40791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 45791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 50791][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK DOWN!!!
[ 28][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz

[ 61][D][RTL8201_test.ino:94] ethernetConnect(): [RTL_8201] Inicializando Ethernet
[ 2930][V][WiFiGeneric.cpp:437] _arduino_event_cb(): Ethernet Started
[ 2930][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 18 - ETH_START
[ 2932][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 18
[ 2938][V][WiFiGeneric.cpp:430] _arduino_event_cb(): Ethernet Link Up
[ 2944][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 20 - ETH_CONNECTED
[ 2952][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 20
[ 2958][D][RTL8201_test.ino:65] EthConnected(): [RTL_8201] Cabo Ethernet conectado
[ 2988][I][RTL8201_test.ino:107] ethernetConnect(): [RTL_8201] SPEED: 100
[ 2989][I][RTL8201_test.ino:108] ethernetConnect(): [RTL_8201] HOSTNAME: RTL8201_test
[ 3947][V][WiFiGeneric.cpp:445] _arduino_event_cb(): Ethernet got newip:192.168.1.229
[ 3947][D][WiFiGeneric.cpp:1038] _eventCallback(): Arduino Event: 22 - ETH_GOT_IP
[ 3951][D][WiFiGeneric.cpp:1137] _eventCallback(): ETH IP: 192.168.1.229, MASK: 255.255.255.0, GW: 192.168.1.1
[ 3960][I][RTL8201_test.ino:61] wifiEvent(): [RTL_8201] EVENTO: 22
[ 3966][I][RTL8201_test.ino:73] EthGotIP(): [RTL_8201] ETHERNET IP: 192.168.1.229
[ 3985][I][RTL8201_test.ino:44] startmDNS(): [RTL_8201] mDNS inicializado em: 'http://RTL8201_test.local
[ 5991][D][RTL8201_test.ino:140] loop(): [RTL_8201] LINK UP!!!

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
Status: Awaiting triage Issue is waiting for triage
1 participant
Converted from issue

This discussion was converted from issue #11303 on April 25, 2025 14:06.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.