Skip to content

ESP32 and W5500 - COMPLETE FAILURE OF COMPONENT #6193

Description

@ESP32andmore

The problem

Using a ESP32 with the W5500 Ethernet chip, ESPHome fails to initialize device. The hardware has been verified to be fully functional with a Arduino sketch using WebServer_ESP32_W5500 lib @25mhz.

Which version of ESPHome has the issue?

2204.8.0

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

Most recent

What platform are you using?

ESP32

Board

Coolboxx II, ESP-DEV-Module

Component causing the issue

W5500

Example YAML snippet

substitutions:
  devicename: avfan1eth
  fdevicename: AVfan1eth
  ip: 192.168.0.201 # For static IP adressing

  ssid: !secret wifi_ssid
  password: !secret wifi_password

  alarm_temp: "50" # Threshold for alarm when implemented
  ptemp: "20"
  itemp: "0.1"

# Connect your Dallas sensors with logger: DEBUG enabled (factory flash default).
# Open the ESPHome webtool, connect to the ECB board, view the "Logs" window, hit "Reset",
# and search for Dallas scan addresses and replace the below addresses with your unique ones.
# Example Scan
#[18:16:42][D][dallas.sensor:084]:     0x8b3ca8f64935b228 4
#[18:16:42][D][dallas.sensor:084]:     0x783c0af6490d3628 2
#[18:16:42][D][dallas.sensor:084]:     0xc13c01f09642c928 1
#[18:16:42][D][dallas.sensor:084]:     0x043c6ef649772f28 3
  dallasaddress1: "0xc13c01f09642c928"
  dallasaddress2: "0x783c0af6490d3628"
  dallasaddress3: "0x043c6ef649772f28"
  dallasaddress4: "0x8b3ca8f64935b228"

#external_components:
#  - source:
#      type: git
#      url: https://github.com/ssieb/esphome
#      ref: onewire
#    components: [ one_wire, gpio ]
#    refresh: 1min


esphome:
  name: ${devicename}
  friendly_name: ${fdevicename}

  on_boot:
  - priority: 900.0
    then:
      - lambda: |-
          id(cpu_speed) = ESP.getCpuFreqMHz();

esp32:
  board: wemos_d1_mini32
  framework:
    type: arduino

preferences:
  flash_write_interval: 10min

ethernet:
  type: W5500
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19
  cs_pin: GPIO15
  interrupt_pin: GPIO36
  reset_pin: GPIO26
  manual_ip:
    static_ip: ${ip}
    gateway: 192.168.0.1
    subnet: 255.255.255.0
    dns1: 192.168.0.1
    dns2: 8.8.8.8

...

Anything in the logs that might be useful for us?

�[0;35m[C][ethernet:041]: Setting up Ethernet...�[0m
�[0;36m[D][esp-idf:000]: E (871) w5500.mac: w5500_reset(221): reset timeout
�[0m
�[0;36m[D][esp-idf:000]: E (872) w5500.mac: emac_w5500_init(602): reset w5500 failed
�[0m
�[0;36m[D][esp-idf:000]: E (882) esp_eth: esp_eth_driver_install(214): init mac failed
�[0m
�[1;31m[E][ethernet:192]: ETH driver install error: (263) ESP_ERR_TIMEOUT�[0m
�[1;31m[E][component:119]: Component ethernet was marked as failed.�[0m
�[1;31m[E][component:164]: Component ethernet set Error flag: unspecified�[0m

Then:

�[0;36m[D][esp-idf:000]�[1;31m[w5500_tsk]�[0;36m: E (4791) spi_master: check_trans_valid(689): txdata transfer > host maximum
�[0m
�[0;36m[D][esp-idf:000]�[1;31m[w5500_tsk]�[0;36m: E (4802) w5500.mac: w5500_read(97): spi transmit failed
�[0m
�[0;36m[D][esp-idf:000]�[1;31m[w5500_tsk]�[0;36m: E (4802) w5500.mac: w5500_read_buffer(188): read RX buffer failed
�[0m
�[0;36m[D][esp-idf:000]�[1;31m[w5500_tsk]�[0;36m: E (4813) w5500.mac: emac_w5500_receive(572): read payload failed, len=65533, offset=1
�[0m

Then:

�[0;36m[D][esp-idf:000]�[1;31m[w5500_tsk]�[0;36m: E (4791) spi_master: check_trans_valid(689): txdata transfer > host maximum
�[0m
�[0;36m[D][esp-idf:000]�[1;31m[w5500_tsk]�[0;36m: E (4802) w5500.mac: w5500_read(97): spi transmit failed
�[0m
�[0;36m[D][esp-idf:000]�[1;31m[w5500_tsk]�[0;36m: E (4802) w5500.mac: w5500_read_buffer(188): read RX buffer failed
�[0m
�[0;36m[D][esp-idf:000]�[1;31m[w5500_tsk]�[0;36m: E (4813) w5500.mac: emac_w5500_receive(572): read payload failed, len=65533, offset=1
�[0m

Then:


Guru Meditation Error: Core  1 panic'ed (Unhandled debug exception). 
Debug exception reason: Stack canary watchpoint triggered (w5500_tsk) 
Core  1 register dump:
PC      : 0x4008eeff  PS      : 0x00060036  A0      : 0x8008d9e8  A1      : 0x3ffca0b0
A2      : 0x3ffbefe8  A3      : 0xb33fffff  A4      : 0x0000cdcd  A5      : 0x00060023
A6      : 0x00060023  A7      : 0x0000abab  A8      : 0xb33fffff  A9      : 0xffffffff
A10     : 0x3f40f6f2  A11     : 0x00000000  A12     : 0x8008515e  A13     : 0x3ffbef3c
A14     : 0x007befe8  A15     : 0x003fffff  SAR     : 0x00000004  EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000  LBEG    : 0x400899b9  LEND    : 0x400899c9  LCOUNT  : 0xffffffff


Backtrace:0x4008eefc:0x3ffca0b00x4008d9e5:0x3ffca0f0 0x4008c148:0x3ffca120 0x4008c0f8:0xa5a5a5a5  |<-CORRUPTED




ELF file SHA256: 0000000000000000

Rebooting...

Additional information

Hardware works without error with this Arduino Sketch:

/****************************************************************************************************************************
WebServer.ino - Simple Arduino web server sample for Ethernet shield

For Ethernet shields using ESP32_W5500 (ESP32 + W5500)

WebServer_ESP32_W5500 is a library for the ESP32 with Ethernet W5500 to run WebServer

Based on and modified from ESP32-IDF https://github.com/espressif/esp-idf
Built by Khoi Hoang https://github.com/khoih-prog/WebServer_ESP32_W5500
Licensed under GPLv3 license
*****************************************************************************************************************************/

#if !( defined(ESP32) )
#error This code is designed for (ESP32 + W5500) to run on ESP32 platform! Please check your Tools->Board setting.
#endif

#define DEBUG_ETHERNET_WEBSERVER_PORT Serial

// Debug Level from 0 to 4
#define ETHERNET_WEBSERVER_LOGLEVEL 3

//////////////////////////////////////////////////////////

// Optional values to override default settings
// Don't change unless you know what you're doing
//#define ETH_SPI_HOST SPI3_HOST
#define SPI_CLOCK_MHZ 25

// Must connect INT to GPIOxx or not working
#define INT_GPIO 36

//#define MISO_GPIO 19
//#define MOSI_GPIO 23
//#define SCK_GPIO 18
//#define CS_GPIO 5

//////////////////////////////////////////////////////////

#include <WebServer_ESP32_W5500.h>

WiFiServer server(80);

// Enter a MAC address and IP address for your controller below.
#define NUMBER_OF_MAC 20

byte mac[][NUMBER_OF_MAC] =
{
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 },
};

// Select the IP address according to your local network
IPAddress myIP(192, 168, 0, 201);
IPAddress myGW(192, 168, 0, 1);
IPAddress mySN(255, 255, 255, 0);

// Google DNS Server IP
IPAddress myDNS(8, 8, 8, 8);

int reqCount = 0; // number of requests received

void setup()
{
Serial.begin(115200);

while (!Serial && (millis() < 5000));

Serial.print(F("\nStart WebServer on "));
Serial.print(ARDUINO_BOARD);
Serial.print(F(" with "));
Serial.println(SHIELD_TYPE);
Serial.println(WEBSERVER_ESP32_W5500_VERSION);

ET_LOGWARN(F("Default SPI pinout:"));
ET_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST);
ET_LOGWARN1(F("MOSI:"), MOSI_GPIO);
ET_LOGWARN1(F("MISO:"), MISO_GPIO);
ET_LOGWARN1(F("SCK:"), SCK_GPIO);
ET_LOGWARN1(F("CS:"), CS_GPIO);
ET_LOGWARN1(F("INT:"), INT_GPIO);
ET_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ);
ET_LOGWARN(F("========================="));

///////////////////////////////////

// To be called before ETH.begin()
ESP32_W5500_onEvent();

// start the ethernet connection and the server:
// Use DHCP dynamic IP and random mac
//bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ,
// int SPI_HOST, uint8_t *W6100_Mac = W6100_Default_Mac);
ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST );
//ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] );

// Static IP, leave without this line to get IP via DHCP
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
ETH.config(myIP, myGW, mySN, myDNS);

ESP32_W5500_waitForConnect();

///////////////////////////////////

// start the web server on port 80
server.begin();
}

void loop()
{
// listen for incoming clients
WiFiClient client = server.available();

if (client)
{
Serial.println(F("New client"));
// an http request ends with a blank line
bool currentLineIsBlank = true;

while (client.connected())
{
  if (client.available())
  {
    char c = client.read();
    Serial.write(c);

    // if you've gotten to the end of the line (received a newline
    // character) and the line is blank, the http request has ended,
    // so you can send a reply
    if (c == '\n' && currentLineIsBlank)
    {
      Serial.println(F("Sending response"));

      // send a standard http response header
      // use \r\n instead of many println statements to speedup data send
      client.print(
        "HTTP/1.1 200 OK\r\n"
        "Content-Type: text/html\r\n"
        "Connection: close\r\n"  // the connection will be closed after completion of the response
        "Refresh: 20\r\n"        // refresh the page automatically every 20 sec
        "\r\n");
      client.print("<!DOCTYPE HTML>\r\n");
      client.print("<html>\r\n");
      client.print(String("<h2>Hello World from ESP32andmore.com") + "!</h2>\r\n");
      client.print("Requests received: ");
      client.print(++reqCount);
      client.print("<br>\r\n");
      client.print("<br>\r\n");
      client.print("</html>\r\n");
      break;
    }

    if (c == '\n')
    {
      // you're starting a new line
      currentLineIsBlank = true;
    }
    else if (c != '\r')
    {
      // you've gotten a character on the current line
      currentLineIsBlank = false;
    }
  }
}

// give the web browser time to receive the data
delay(10);

// close the connection:
client.stop();
Serial.println(F("Client disconnected"));

}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions