ESP32-POE-ISO ESPHome: wrong chip ID

Started by arcimus, September 20, 2023, 12:51:51 AM

Previous topic - Next topic

arcimus

Hello,

ESP32-POE-ISO powers on and accepts flashing, but ethernet does not connect.  Wifi works fine.  Logging shows:
[D][esp-idf:000]: E (368) lan87xx: lan87xx_init(499): wrong chip ID
[D][esp-idf:000]: E (369) esp_eth: esp_eth_driver_install(215): init phy failed

I read that this may be related to: https://github.com/espressif/arduino-esp32/issues/6142

However, it's my understanding that ESPHome uses espressif and therefore the delay should be in place.

I also attempted with ESPHome set to use the latest espressif and platform.  The error is now slightly different:
[V][esp-idf:000]: E (991) lan87xx: lan87xx_init(299): wrong chip OUI
[V][esp-idf:000]: E (992) esp_eth: esp_eth_driver_install(229): init phy failed

ESPHome yaml:
esphome:
  name: esphome-web-6fb690
  friendly_name: ESPHome Web 6fb690

esp32:
  board: esp32-poe-iso
  framework:
    type: esp-idf
    version: latest
    platform_version: 6.4.0

# Enable logging
logger:
  level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "donaldduck="

ota:

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0
  power_pin: GPIO12

LubOlimex

Which version of ESP32-POE-ISO do you have? If you use WROVER version change "clk_mode: GPIO17_OUT" to  "clk_mode: GPIO0_OUT" so it looks like that:

ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO0_OUT
phy_addr: 0
power_pin: GPIO12

Let me know how it goes.
Technical support and documentation manager at Olimex

arcimus

Thanks for your reply.  I do not have the WROVER version.  I have the ESP32-PoE-ISO Rev.L.  I tried the different ethernet settings anyway, same error.

LubOlimex

Then you initial config was alright:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0
power_pin: GPIO12

Notice that just a few days ago a customer reported success with ESPHome and same chip (despite that he used WROVER version board uses same Ethernet chip): https://github.com/OLIMEX/ESP32-POE-ISO/issues/13

If the issue remains:

- report to esphome team or community with all details about the software you used

- test with different version of esphome (latest, older) depending on what you used so far

- try some other environment and demo to confirm the issue is not with the ethernet of the board, maybe use Arduino IDE for ESP32, which has a config for Olimex ESP32-PoE-ISO in the board selector, then download the demo ETH_LAN8720 from File -> Examples -> Ethernet.

- double check your cabling and network, sometimes networking problems come for the network settings themselves

Technical support and documentation manager at Olimex

arcimus

I decided to keep it simple and try the ETH_LAN8720.ino example in Arduino IDE.  I followed the instructions here, but each time I attempt an upload, I get:
esptool.py v4.5.1
Serial port COM4
Connecting......................................

A fatal error occurred: Failed to connect to ESP32: No serial data received.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
Failed uploading: uploading error: exit status 2

Once, I received:
A fatal error occurred: Failed to connect to ESP32: Download mode successfully detected, but getting no sync reply: The serial TX path seems to be down.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
Failed uploading: uploading error: exit status 2

I had no problems flashing ESPHome through the same setup.

Not sure if it's related, but when I view the Serial Monitor in Arduino IDE and press the RST1 button, sometimes I get:
rst:0x1 (POWERON_RESET),boot:0x2 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_FEO_V2))
waiting for download
... but most of the time I see it boot ESPHome, ending with the wrong chip OUI error.

LubOlimex

That is not good, can be caused by a lot of things. You can search online for that error "A fatal error occurred: Failed to connect to ESP32: Download mode successfully detected, but getting no sync reply: The serial TX path seems to be down.". I'd recommend first testing with another cable and USB port.

Technical support and documentation manager at Olimex

John_L

I have the same problem, working with ESP-IDF.

E (1002) lan87xx: lan87xx_init(499): wrong chip ID
E (1002) esp_eth: esp_eth_driver_install(215): init phy failed

My code for LAN Networking is working perfectly fine on ESP32-Gateway boards, but fails on ESP32-PoE.
The menuconfig settings are all exactly the same, using RMII and the right pinning and so on.
Comparing the schematics for both boards, i cannot see any difference at all concering the Ethernet circuitry.

Here is my Ethernet initialization code:
   // MAC config
   eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
   mac_config.smi_mdc_gpio_num = CONFIG_MYDEVICE_ETH_MDC_GPIO;
   mac_config.smi_mdio_gpio_num = CONFIG_MYDEVICE_ETH_MDIO_GPIO;

   // PHY config
   eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
   phy_config.phy_addr = CONFIG_MYDEVICE_ETH_PHY_ADDR;
   phy_config.reset_gpio_num = CONFIG_MYDEVICE_ETH_PHY_RST_GPIO;

   esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config);
   esp_eth_phy_t *phy = esp_eth_phy_new_lan87xx(&phy_config);

   esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
   eth_handle = NULL;
  
   ESP_ERROR_CHECK(esp_eth_driver_install(&config, &eth_handle));
   ESP_ERROR_CHECK(esp_netif_attach(eth_netif, esp_eth_new_netif_glue(eth_handle)));
   ESP_ERROR_CHECK(esp_eth_start(eth_handle));

As already mentioned, this code is working on ESP32-Gateway boards which leaves me bewildered what is going on.

Thanks a lot for help.

LubOlimex

This doesn't seem like the same problem.

1. What are the exact names and variants of the ESP32 boards that you got? Neither ESP32-POE nor ESP32-GATEWAY has WROVER module, correct?

2. What is the hardware revision letter of ESP32-GATEWAY and what is the hardware revision of ESP32-POE? This should be printed at the bottom of the board under the name of the board.

3. What are the pin definitions in your code when it comes to the Ethernet? I mean what exactly are mdc_pin, mdio_pin, clk_mode, power_pin ?
Technical support and documentation manager at Olimex

John_L

1. Both boards have ESP32-WROOM module
-----------------------------------
2. ESP32-POE: REV. L / ESP32-GATEWAY: REV. G
-----------------------------------
3. mdc_pin 23
   mdio_pin 18
   clk_mode 'Output RMII clock from internal' Pin 17
   power_pin ?? What do you mean by that? Cannot find anything like that in the menuconfig

LubOlimex

It was somewhere around the power options, I believe it had to be enabled and GPIO assigned. But exact location varies depending on the ESP-IDF version used. It should be GPIO12. In the code it is "#define PIN_PHY_POWER 12" see here:

https://github.com/OLIMEX/ESP32-POE/blob/master/SOFTWARE/ESP-IDF/ESP32_PoE_Ethernet_IDFv4.4/main/ethernet_example_main.c

If you are using ESP-IDF, then try our Ethernet examples for ESP32-POE (use the folder depending on the ESP-IDF version that you use):

https://github.com/OLIMEX/ESP32-POE/tree/master/SOFTWARE/ESP-IDF

Maybe use the examples as basis or inspiration in your code.
Technical support and documentation manager at Olimex

John_L

The example works, think i can go on from there.
I did not use the gpio_pad_selection, maybe that was the error...

tahnk you very much  :D

arcimus

Coming back to this after having to work on some other things.

esphome is up to date.  I made various new esphome attempts all result in the same "wrong chip ID" error.  I tried different board and framework settings, as well as a couple different ethernet suggestions.

I updated Arduino IDE including the ESP32 packages.  In Arduino IDE, I was able to compile and upload the ETH_LAN8720.ino example.  Same "wrong chip ID" error.

A dozen or so results are easily googleable to see that there are folks out there getting the ESP32-POE-ISO to work with esphome.  Do I somehow have a bad board?  Any other suggestions?

Arduino IDE Output:
Sketch uses 757957 bytes (57%) of program storage space. Maximum is 1310720 bytes.
Global variables use 43732 bytes (13%) of dynamic memory, leaving 283948 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.5.1
Serial port COM4
Connecting.......
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: e0:5a:1b:6f:b6:90
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x000cafff...
Compressed 17568 bytes to 12204...
Writing at 0x00001000... (100 %)
Wrote 17568 bytes (12204 compressed) at 0x00001000 in 1.5 seconds (effective 96.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 265.4 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 646.4 kbit/s)...
Hash of data verified.
Compressed 764256 bytes to 491787...
Writing at 0x00010000... (3 %)
Writing at 0x0001c3a6... (6 %)
Writing at 0x00027ce6... (9 %)
Writing at 0x00032d28... (12 %)
Writing at 0x00037e7f... (16 %)
Writing at 0x0003d435... (19 %)
Writing at 0x00042c82... (22 %)
Writing at 0x00048cb0... (25 %)
Writing at 0x0004df68... (29 %)
Writing at 0x00053115... (32 %)
Writing at 0x0005847d... (35 %)
Writing at 0x0005d652... (38 %)
Writing at 0x0006289c... (41 %)
Writing at 0x0006812d... (45 %)
Writing at 0x0006d39b... (48 %)
Writing at 0x00073084... (51 %)
Writing at 0x00078790... (54 %)
Writing at 0x0007d987... (58 %)
Writing at 0x00082d6e... (61 %)
Writing at 0x00088276... (64 %)
Writing at 0x0008d7ef... (67 %)
Writing at 0x00093016... (70 %)
Writing at 0x00098e7a... (74 %)
Writing at 0x0009e7d5... (77 %)
Writing at 0x000a4b97... (80 %)
Writing at 0x000af236... (83 %)
Writing at 0x000b46c2... (87 %)
Writing at 0x000b9e32... (90 %)
Writing at 0x000bf7cb... (93 %)
Writing at 0x000c4be2... (96 %)
Writing at 0x000ca80a... (100 %)
Wrote 764256 bytes (491787 compressed) at 0x00010000 in 43.9 seconds (effective 139.4 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

rst:0x1 (POWERON_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:13260
load:0x40080400,len:3028
entry 0x400805e4
E (41) lan87xx: lan87xx_init(499): wrong chip ID
E (41) esp_eth: esp_eth_driver_install(215): init phy failed
ets Jul 29 2019 12:21:46

Stanimir5F

Hello arcimus!

Ideally I would like to see the exact code you are trying to upload but based on this
Quote from: arcimus on February 02, 2024, 11:01:31 PMI updated Arduino IDE including the ESP32 packages. In Arduino IDE, I was able to compile and upload the ETH_LAN8720.ino example.
I assume you haven't made changes and I have an idea what the issue may be.

In the latest version of the package (which is still in development as far as I am aware) they changed the default ETH_LAN8720 example a little bit.

In the older version the macros about the ethernet hardware were hidden inside the library files and the specifics could be overwritten from the "pins_arduino.h" header in the "variants" folder.
As for the new one these macros are presented at the very start of the sketch (before the include of the "ETH.h")

Take a look at it and more specifically lines 8-13.
By default it should be this:
#define ETH_PHY_TYPE        ETH_PHY_LAN8720
#define ETH_PHY_ADDR         0
#define ETH_PHY_MDC         23
#define ETH_PHY_MDIO        18
#define ETH_PHY_POWER       -1
#define ETH_CLK_MODE        ETH_CLOCK_GPIO0_IN
but in our hardware the PHY power is pin 12 and the EMAC clock OUT is pin 17 .
So the last 2 macros should be changed to:
#define ETH_PHY_POWER       12
#define ETH_CLK_MODE        ETH_CLOCK_GPIO17_OUT

Try it to see if it will solve the problem. Otherwise please post the code you are trying to upload (and also just in case the exact revision of the Espressif package you are using).

Stan, Olimex
May the Source be with You!

arcimus

Thanks for your reply.  I just tried again...

In Arduino IDE, I'm Running esp32 by Espressif 2.0.14 and Arduino ESP32 Boards by Arduino 2.0.13.

I found the current master version of the example here: https://github.com/espressif/arduino-esp32/blob/master/libraries/Ethernet/examples/ETH_LAN8720/ETH_LAN8720.ino
The one I'm using does not look like that.  I downloaded the current release v2.0.14 zip for espressif/arduino-esp32 and it also does not look like that.

Compiling the master version with the #define lines results in compilation errors.

https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html has a development release link.  I'll put that in Arduino IDE tomorrow and give it a shot.

Here's the v2.0.14 version
/*
    This sketch shows the Ethernet event usage

*/

#include <ETH.h>

static bool eth_connected = false;

void WiFiEvent(WiFiEvent_t event)
{
  switch (event) {
    case ARDUINO_EVENT_ETH_START:
      Serial.println("ETH Started");
      //set eth hostname here
      ETH.setHostname("esp32-ethernet");
      break;
    case ARDUINO_EVENT_ETH_CONNECTED:
      Serial.println("ETH Connected");
      break;
    case ARDUINO_EVENT_ETH_GOT_IP:
      Serial.print("ETH MAC: ");
      Serial.print(ETH.macAddress());
      Serial.print(", IPv4: ");
      Serial.print(ETH.localIP());
      if (ETH.fullDuplex()) {
        Serial.print(", FULL_DUPLEX");
      }
      Serial.print(", ");
      Serial.print(ETH.linkSpeed());
      Serial.println("Mbps");
      eth_connected = true;
      break;
    case ARDUINO_EVENT_ETH_DISCONNECTED:
      Serial.println("ETH Disconnected");
      eth_connected = false;
      break;
    case ARDUINO_EVENT_ETH_STOP:
      Serial.println("ETH Stopped");
      eth_connected = false;
      break;
    default:
      break;
  }
}

void testClient(const char * host, uint16_t port)
{
  Serial.print("\nconnecting to ");
  Serial.println(host);

  WiFiClient client;
  if (!client.connect(host, port)) {
    Serial.println("connection failed");
    return;
  }
  client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
  while (client.connected() && !client.available());
  while (client.available()) {
    Serial.write(client.read());
  }

  Serial.println("closing connection\n");
  client.stop();
}

void setup()
{
  Serial.begin(115200);
  WiFi.onEvent(WiFiEvent);
  ETH.begin();
}


void loop()
{
  if (eth_connected) {
    testClient("google.com", 80);
  }
  delay(10000);
}

Here's the current master branch version:
/*
    This sketch shows the Ethernet event usage

*/

// Important to be defined BEFORE including ETH.h for ETH.begin() to work.
// Example RMII LAN8720 (Olimex, etc.)
#define ETH_PHY_TYPE        ETH_PHY_LAN8720
#define ETH_PHY_ADDR         0
#define ETH_PHY_MDC         23
#define ETH_PHY_MDIO        18
#define ETH_PHY_POWER       -1
#define ETH_CLK_MODE        ETH_CLOCK_GPIO0_IN

#include <ETH.h>

static bool eth_connected = false;

// WARNING: WiFiEvent is called from a separate FreeRTOS task (thread)!
void WiFiEvent(WiFiEvent_t event)
{
  switch (event) {
    case ARDUINO_EVENT_ETH_START:
      Serial.println("ETH Started");
      // The hostname must be set after the interface is started, but needs
      // to be set before DHCP, so set it from the event handler thread.
      ETH.setHostname("esp32-ethernet");
      break;
    case ARDUINO_EVENT_ETH_CONNECTED:
      Serial.println("ETH Connected");
      break;
    case ARDUINO_EVENT_ETH_GOT_IP:
      Serial.println("ETH Got IP");
      ETH.printInfo(Serial);
      eth_connected = true;
      break;
    case ARDUINO_EVENT_ETH_LOST_IP:
      Serial.println("ETH Lost IP");
      eth_connected = false;
      break;
    case ARDUINO_EVENT_ETH_DISCONNECTED:
      Serial.println("ETH Disconnected");
      eth_connected = false;
      break;
    case ARDUINO_EVENT_ETH_STOP:
      Serial.println("ETH Stopped");
      eth_connected = false;
      break;
    default:
      break;
  }
}

void testClient(const char * host, uint16_t port)
{
  Serial.print("\nconnecting to ");
  Serial.println(host);

  WiFiClient client;
  if (!client.connect(host, port)) {
    Serial.println("connection failed");
    return;
  }
  client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
  while (client.connected() && !client.available());
  while (client.available()) {
    Serial.write(client.read());
  }

  Serial.println("closing connection\n");
  client.stop();
}

void setup()
{
  Serial.begin(115200);
  WiFi.onEvent(WiFiEvent);  // Will call WiFiEvent() from another thread.
  ETH.begin();
}

void loop()
{
  if (eth_connected) {
    testClient("google.com", 80);
  }
  delay(10000);
}

LubOlimex

Maybe the Ethernet got damaged somehow, maybe it a hardware problem, my advice is to either get another ESP32-POE-ISO board and compare behavior or drop me an e-mail support@olimex.com to start the warranty and returns procedure, our warranty and returns policy is detailed here:

https://www.olimex.com/wiki/GTC#Warranty
Technical support and documentation manager at Olimex