ESP32-POE-ISO ESPHome: wrong chip ID

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

Previous topic - Next topic

daabutts

I am chasing the same problem.  Here is the code:

/*
    This sketch shows the Ethernet event usage
*/

#define ETH_PHY_TYPE        ETH_PHY_LAN8720
#define ETH_PHY_ADDR        0
#define ETH_PHY_MDC        23
#define ETH_PHY_MDIO        18

#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
#define ETH_PHY_POWER 12

#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()
{
  Serial.print("ETH MAC: ");
  Serial.print(ETH.macAddress());
  Serial.print(", IPv4: ");
  Serial.println(ETH.localIP());
  delay(1000);
}

Here is the output:
...
entry 0x400805e4
E (122) lan87xx: lan87xx_pwrctl(409): power up timeout
E (122) lan87xx: lan87xx_init(491): power control failed
E (122) esp_eth: esp_eth_driver_install(215): init phy failed
ETH MAC: E (137) esp_eth: esp_eth_ioctl(348): ethernet driver handle can't be null
00:00:00:00:00:00, IPv4: 0.0.0.0

I have two ESP32-POE-ISO Rev L boards purchased from Mouser.com two weeks ago.  They both produce the same output. Using Arduino IDE V 2.2.1, CLI Version 0.34.0. 

What other information can I give you that would help you see the difference between my system and yours where Rev L works fine?

Thanks!
Devin





LubOlimex

1. Which variant of ESP32-POE-ISO are you both using exactly? If you are using ESP32-POE-ISO-WROVER - then GPIO17 is not routed to ETH clock, but GPIO0 is and the define should be:

#define ETH_CLK_MODE ETH_CLOCK_GPIO0_OUT

I get the same error as you two if I try to use the code for ESP32-POE-ISO on ESP32-POE-ISO-WROVER board without the change to the clock source.

2. Which version of Arduino package are you using?

3. Which demo are you using - did you load it from the Arduino IDE itself (from File -> Examples -> ESP32 section -> Ethernet -> ETH_LAN8720)? Please do that.

If you are using regular ESP32-POE-ISO with WROOM module (not WROVER) I think there is some mismatch between Arduino IDE for ESP32 package version and the example used. Make sure to update to latest package version from tools -> board manager - (write esp32 in search field) and under esp32 by espressif systems update it. Alternatively, maybe during upgrades and downgrades something in the libraries got broken, I've had it happened here in the past. My first advice is to uninstall it all (including manually deleting folders with Arduino libraries and install a new latest versions). Make sure to keep backup of anything important.
Technical support and documentation manager at Olimex

daabutts

Ok, that is the problem.  I didn't realize that Olimex built some EPS32-POE-ISO Rev L with WROVER chips and some with WROOM.  Good to know.

Using the change you have above, it works, here is my output:
entry 0x400805e4
ETH Started
ETH Connected
ETH MAC: C4:DD:57:6A:8C:6B, IPv4: 192.168.50.199, FULL_DUPLEX, 100Mbps

This is the code that works:
#define ETH_PHY_TYPE        ETH_PHY_LAN8720
#define ETH_PHY_ADDR        0
#define ETH_PHY_MDC        23
#define ETH_PHY_MDIO        18

//#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT  //ESP32-POE-ISO Rev L with WROOM
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_OUT    //ESP32-POE-ISO Rev L with WROVER
#define ETH_PHY_POWER 12

#include <ETH.h>

Thanks for your help!

arcimus

#18
I uninstalled Arduino IDE, reinstalled, and used their development release link: https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json

Doing so allowed install of esp32:3.0.0-alpha3 by espressif.  The ETH_LAN8720.ino example now includes the #define lines that Stan mentioned.  I was able to make Stan's changes, compile and upload.

However, we once again get a wrong chip error:
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:1256
load:0x40078000,len:13832
load:0x40080400,len:4
load:0x40080404,len:3048
entry 0x40080590
E (42) lan87xx: lan87xx_init(299): wrong chip OUI
E (43) esp_eth: esp_eth_driver_install(229): init phy failed

I have ordered a new ESP32-POE-ISO and will report my findings.

EDIT, just saw LubOlimex questions:
1.  I have ESP32-PoE-ISO Rev.L WROOM
2.  esp32:3.0.0-alpha3 by espressif, noted above
3. I used the ETH_LAN8720.ino you can browse to in the IDE, updated with Stan's definitions.  I did delete folders when I reinstalled.  Here's the code:
/*
    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       12
#define ETH_CLK_MODE        ETH_CLOCK_GPIO17_OUT

#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

Technical support and documentation manager at Olimex

Stanimir5F

Hi arcimus!

I tried with your code (literally copy paste) and it worked here. I am also with the esp32 3.0.0-alpha3. I don't know if that will affect the outcome at all but still I am using Windows 10 x64.

One other thing that you can test if you have installed esp-idf 5.x you can test with this example just to see if it is somehow hardware related..

The 5.3 in the name of the project is because it was done with 5.3 version of the esp-idf although it works with 5.1 as well. Note that in the menuconfig since there is no power pin, the reset phy is set to 12.

Stan, Olimex
May the Source be with You!

arcimus

I received another ESP32-POE-ISO from Mouser.  Works!  It's all setup with esphome connected via POE ethernet.  I'll look into returning my original unit.  Thanks much for your assistance.

dhy2k

Thanks everyone - great thread.

I have been trying to get Olimex-POE2 working with ESPHome on ethernet. I've had no problem with the previous POE version, but wanted the POE2 upgrade for the greater power to do door locks etc.

All the standard stuff on the internet & ESPHome didn't want to work for bringing up the ethernet.  Various errors including:

[D][esp-idf:000]: E (368) lan87xx: lan87xx_init(499): wrong chip ID


After a degree of fiddling (and connecting to the POE2 via USB-USB from my Macbook) this is the config that works for ESPHome & the Olimex-POE2.  Just sharing to help anyone else with the same headache :-)

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

LubOlimex

Thanks for sharing. The important part about PoE2 is that it uses ESP32-WROVER chip instead of ESP32-WROOM. Which leads to different Ethernet clock pin compared to ESP32-POE.
Technical support and documentation manager at Olimex