Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding W5500 support to ethernet component #4424

Merged
merged 7 commits into from Mar 1, 2024

Conversation

JeroenVanOort
Copy link
Contributor

@JeroenVanOort JeroenVanOort commented Feb 13, 2023

What does this implement/fix?

This adds support for the W5500 chip to the ethernet component.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Related issue or feature (if applicable): fixes esphome/feature-requests#1235

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#2843

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040

Example entry for config.yaml:

ethernet:
  type: W5500
  clk_pin: GPIO19
  mosi_pin: GPIO21
  miso_pin: GPIO23
  cs_pin: GPIO18
  interrupt_pin: GPIO36
  reset_pin: GPIO22

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@keshavdv
Copy link

I tried to give this a go, but couldn't make it very far. Because this is the first SPI-based ethernet chip being added, I think there's more that needs to change in esphome. All of the configurable options for the ethernet component (MDC/MDIO pins, etc) don't apply and there's no way to set the config for other more critical options (interrupt pin for MACRAW mode, CS pin for SPI). Here's what I see:

Config (the values don't make sense, but are required fields):

ethernet:
  type: W5500
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO0_IN
  phy_addr: 0

Output:

[01:08:37][I][app:029]: Running through setup()...
[01:08:37][C][ethernet:028]: Setting up Ethernet...
[01:08:38][D][esp-idf:000]: E (452) esp.emac: emac_esp32_init(349): reset timeout
[01:08:38]
[01:08:38][D][esp-idf:000]: E (453) esp_eth: esp_eth_driver_install(214): init mac failed
[01:08:38]
[01:08:38][E][ethernet:091]: ETH driver install error: (263) ESP_ERR_TIMEOUT
[01:08:38][E][component:113]: Component ethernet was marked as failed.

@JeroenVanOort
Copy link
Contributor Author

O wow, how could I not have spotted that. I'll look into this more closely in the coming days.

In the meantime: if anyone has suggestion for how to get the config schema to support this, be welcome to share snippets of code or to make your own PR. I'm just starting to understand this all.

@jesserockz
Copy link
Member

Haha yeah, if it was this easy I would have added all of the SPI drivers when upgrading the ethernet component late last year.

In terms of making the config work, we can change to using a cv.typed_schema() and each of the existing ones can use a common schema and the SPI ones can use a new common schema.

@JeroenVanOort
Copy link
Contributor Author

Ok, I thought I had the typed_schema figured out (adding options for (s)clk, miso, mosi and cs pins) until I noticed that the SPI component exists, which should probably be used here. I haven't tried yet, but I can probably use the spi_device_schema.

But then what? I found https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_eth.html#spi-ethernet-module , but I don't really understand how that would work with the SPI component yet.

Any hints are welcome!

@keshavdv
Copy link

I did have success using the custom component in https://github.com/spali/esphome-components/blob/master/components/ethernet_spi/ethernet_spi.cpp with the W5500, which I think might contain most of the "necessary" bits to making something like this work. There are quite a lot of substantial changes so maybe this is better as an independent component?

@spali
Copy link

spali commented Feb 21, 2023

I didn't put more effort in https://github.com/spali/esphome-components/tree/master/components/ethernet_spi because I think it should be integrated into the base ethernet component to be compatible with everything that depends on ethernet like the web server component etc.
Didn't had time to look into the an actual implementation but I think a mutually exclusive config schema (either default or SPI) based on the selected type would be the way to go.
If you figure it out how this config schema can be implemented, feel free to copy&paste any code from my component as you like.

@JeroenVanOort
Copy link
Contributor Author

@spali Thank you for your message.

It seems that the config schema is not the hardest part: as Jesse suggested a typed_schema can be used to differentiate the parameters between RMII and SPI based devices. Combining that with the work you have already done, it shouldn't be too complicated to get things to work. The yaml could look like this:

ethernet:
  type: W5500
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19
  cs_pin: GPIO26

The thing is: that would completely bypass the SPI component. I think that (but I'm by no means an expert on any of this would mean that you would have to have a separate SPI bus for the ethernet chip. I.e. it would be impossible to share the SPI pins in use for the ethernet chip with other SPI devices. Possibly it would be nicer if we could do something like this:

spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

ethernet:
  type: W5500
  cs_pin: GPIO26

I personally doubt this is feasible, because I don't see the connection or overlap between the SPI component and the code for SPI based ethernet chips. But I'm just a PHP programmer working on some hobby electronics projects, so it's very plausible that I'm not seeing something that is very much there.

Second question is: would going with the first, simpler, route, be a reason to not support SPI based ethernet connectivity at all? I hope @jesserockz or any of the other maintainers have the time to share their vision on that.

@spali
Copy link

spali commented Mar 7, 2023

From the user perspective, I think the SPI component (second example of you) would make sense to define the common SPI stuff, as it can have multiple SPI bus and it seems to align also with other SPI components configuration like displays etc. in esphome.
But yes... the code would only get the pins from the SPI component but the actual implementation would be completely independent because esp-idf built it that way.
When I find time, I could try to use my M5stack core with the W5500 module to test if the display (SPI based) works together with the W5500 in esp-idf.

@spali
Copy link

spali commented Mar 10, 2023

Ok got some time to do a small test.
Used my m5stack m2go with an ili9xxx SPI based display and the W5500 module.
Display alone works.
My ethernet_spi component alone works.

Together the display does not work. If I comment the spi_bus_initialize in my component, then the display works, but my component fails due esp-idf tells me the SPI bus is not initialized.

I fear this is a fundamental problem of how esphome uses the SPI bus on esp-idf. @jesserockz correct me, but I think esphome does not use the esp-idf provided methods to initialize the SPI bus. And maybe this just won't work together. If that assumption is true... either esphome must use the esp-idf methods for SPI stuff (may break a lot of SPI related stuff) or we must somehow reimplement the convenient ethernet driver stuff from esp-idf to work on top of how esphome works (if that is possible).

@jesserockz Do we have any existing SPI devices that partially or fully make use of the esp-idf provided methods?

edit: @JeroenVanOort Basically kind of a prove what you already mentioned 😉

@spali
Copy link

spali commented Mar 11, 2023

got a working draft: github://spali/esphome@w5500 or https://github.com/spali/esphome/tree/w5500/esphome/components/ethernet

Currently SPI is handled in the ethernet component. Declaring the SPI component let it still work, but in my tests with an SPI display only one component works at a time.
So it is at least a full and better replacement for my ethernet_spi component. But does not work when other SPI devices are required.

Most critical part to do now would be to somehow streamline SPI part to work with the existing spi component. To be honest I don't know enough about the SPI internals to streamline this.

When or better if we get this working... we can clean the code to maybe create an ethernet base class and only share the code that is not implementation (driver) specific.

@mhendriks
Copy link

@spali thanks for the great work.

I tested your code on a custom made W5500 / ESP32C3, see picture below. After adjusting the SPI_HOST -> 2 it works great. ESP32C3 has 1 SPI Host less;-)

Screenshot 2023-02-04 at 17 53 00

The board is made for processing P1 smart meter data (DSMR). The DSMR component unfortunately only works on the Arduino framework. Is there a way to use your code for the Arduino framework as well?

@clomads
Copy link

clomads commented Mar 13, 2023

@mhendriks was wondering about your config. I'm trying to get it setup on C3 as well and I'm still getting compiling issues. Where is the SPI_HOST thing you mentioned?

@mhendriks
Copy link

mhendriks commented Mar 13, 2023

@mhendriks was wondering about your config. I'm trying to get it setup on C3 as well and I'm still getting compiling issues. Where is the SPI_HOST thing you mentioned?

replace the SPI3_HOST in ethernet_component.cpp (2x)

See the config below

substitutions:
  device_name: eth-dongle-v2
  device_description: "P1 Dongle Pro with ethernet access"
  friendly_name: ETH Dongle P1 Pro
  prj_version: "2023.3.1"

esphome:
  name: ${device_name}
  comment: "${device_description}" 
  platformio_options:
    upload_speed: 1500000
    board_build.flash_mode: dio
    
  project: 
    name: "smartstuff.eth_dongle_v2"
    version: ${prj_version}

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf

external_components:
  - source: my_components
    components: [ ethernet ]
      
ethernet:
  type: W5500
  cs_pin: 10
  clk_pin: 4
  mosi_pin: 6
  miso_pin: 5
  interrupt_pin: 1
  clock_speed: 25
     
ota:

logger:
  level: DEBUG

api:
      
sensor:
  - platform: uptime
    name: "_Uptime"

@spali
Copy link

spali commented Mar 13, 2023

@mhendriks @clomads
Pushed a fix to my branch which should fix this for C3 S2 and S3.
Just make sure to have the latest version of the branch.

@clomads
Copy link

clomads commented Mar 13, 2023

Thank you both for your work @spali @mhendriks
I'm not sure what I'm doing wrong here. Pulling directly from the repo as an external component and I'm not getting any errors in the editor, so it understands the code. Here's my YAML and I've attached one of my logs. It probably doesn't matter, but I'm using download function so I can use ESPHome web when I can get it to compile.

esphome:
  name: ethc3
  friendly_name: ethC3

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf

logger:
api:
ota:

external_components:
  - source: github://spali/esphome@w5500
    components: [ ethernet ]
    refresh: 0s

ethernet:
  type: W5500
  cs_pin: 10
  clk_pin: 4
  mosi_pin: 6
  miso_pin: 5
  interrupt_pin: 1
  clock_speed: 25

binary_sensor:
  - platform: gpio
    pin:
      number: 9
      inverted: True
    name: "Boot Button"

logs_ethc3_compile.txt

@spali
Copy link

spali commented Mar 13, 2023

try newer esphome or try at least newer espidf framework. possible that 4.4.3 or better 4.4.4 is required.

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf
    version: 4.4.4

@mhendriks
Copy link

@spali thanks for the fixes/changes.

I didn't tell yesterday that I had removed the part below. This because of the error: 'esp_eth_mac_new_esp32' was not declared in this scope. The adjustments work great on the C3 (after removing the part below).

Tested on:

  • esp32c3
  • esphome 2023.2.4
  • espidf version: 4.4.2
  • platform_version 5.2.0
    case ETHERNET_TYPE_LAN8720: {
      mac = esp_eth_mac_new_esp32(&mac_config);
      phy = esp_eth_phy_new_lan87xx(&phy_config);
      break;
    }
    case ETHERNET_TYPE_RTL8201: {
      mac = esp_eth_mac_new_esp32(&mac_config);
      phy = esp_eth_phy_new_rtl8201(&phy_config);
      break;
    }
    case ETHERNET_TYPE_DP83848: {
      mac = esp_eth_mac_new_esp32(&mac_config);
      phy = esp_eth_phy_new_dp83848(&phy_config);
      break;
    }
    case ETHERNET_TYPE_IP101: {
      mac = esp_eth_mac_new_esp32(&mac_config);
      phy = esp_eth_phy_new_ip101(&phy_config);
      break;
    }
    case ETHERNET_TYPE_JL1101: {
      mac = esp_eth_mac_new_esp32(&mac_config);
      phy = esp_eth_phy_new_jl1101(&phy_config);
      break;
    }

@clomads you are using exactly the same io assignment for the spi interface. You are shure this is correct?

@clomads
Copy link

clomads commented Mar 13, 2023

@spali @mhendriks I'm on latest main release 2023.2.4 via HA add-on and I checked another device with IDF by adding debug component and it's compiling with 4.4.2 by default so forcing 4.4 made the compiler freak out even more.

My main error as shown in my log file is: 'esp_eth_mac_new_esp32' was not declared in this scope so it's gotta be those lines that @mhendriks removed. I copied your config directly to reduce variables for now. I'll see if I can fork this to get it running unless @spali wants to make the updates.

@clomads
Copy link

clomads commented Mar 14, 2023

I got it to compile by removing those lines that @mhendriks mentioned. No network connection yet bc I'm gonna have to tighten up my wiring or put it on a perfboard.

@spali
Copy link

spali commented Mar 14, 2023

found and fixed the problem for the not declared methods. Not sure why the define CONFIG_ETH_USE_ESP32_EMAC is not set for some boards (maybe not supported in the framework), but hope works now for you without manual modification.

@JeroenVanOort
Copy link
Contributor Author

JeroenVanOort commented Mar 25, 2023

Thank you all for the work on this! I was able to get it to work using a plain ESP32.

Like @mhendriks I'm also trying to use the DSMR component so I looked at getting this to work with the Arduino framework. What seems to be holding it back are the two calls to add_idf_sdkconfig_option in __init__.py, but after commenting them out, it works just fine. Just leaving them out would probably break compatibility with esp-idf (didn't try though), but only making the calls if the framework is esp-idf doesn't sound impossible.

I think these are the TODO's for now:

  • Only call add_idf_sdkconfig_option when esp-idf framework is used.
  • Reuse the schema from the spi component
    Edit: on second thought, doesn't seem to have added value
  • Resolving the other TODO's in the code
  • Add a test case
  • Add documentation

Nice to have's:

  • Make the interrupt pin optional (I believe some people use hardware that doesn't connect the pin)
  • Make it easier to add compatibility for other SPI based chips later (if someone would copy-paste the code for the W5500 for another chip, there would be some duplicate code for setting the pins and stuff. It probably isn't very hard to abstract this for SPI chips in general.)
    Edit: let's do this later.

@spali Where do we go from here? I could work on all but resolving the other TODO's in the code and make a PR to your branch, from which you make a PR to upstream. This PR can be closed. Other option would be for me to copy to code to my branch, update this PR with my changes and then get it merged. But that kinda feels like stealing the credits for the effort you made.

One last thing regarding the chips that have one less SPI bus than the plain ESP32: does this mean that SPI ethernet would could not go together with the SPI component? I understand there will need to be 2 separate SPI buses, but it seems like these chips wouldn't be able to do that. If so, this could use a check in the code and must absolutely be mentioned in the documentation that is to be added.

@spali
Copy link

spali commented Mar 26, 2023

Don't worry about stealing 😉 I'm fine if you copy paste. Would prefer that you are independent of me for finishing this PR.

Regarding SPI... yes that would be a limitation for now, as I couldn't get any other SPI device to work as soon as I used the esp-idf SPI initialization stuff (did not test if devices are on separate SPI bus). But I don't know if the PR would get merged with that limitation. I was hoping someone with more in deep knowledge of the current SPI implementation could help us here to get it work.

@mhendriks
Copy link

@JeroenVanOort Would you be able and willing to share your Arduino version of the code? I would also like to experiment with it ;-)

@majkrzak
Copy link
Contributor

majkrzak commented Jan 3, 2024

With M5Stack POE CAM https://docs.m5stack.com/en/unit/poe_cam and following config:

esphome:
  name: domofon

esp32:
  board: m5stack-core2
  framework:
    type: esp-idf

external_components:
- source:
    type: git
    url: https://github.com/JeroenVanOort/esphome/
    ref: eth-w5500
  components:
  - ethernet

ethernet:
  type: W5500
  mosi_pin: GPIO13
  miso_pin: GPIO38
  clk_pin: GPIO23
  cs_pin: GPIO4
  clock_speed: 10Mhz

ota:

logger:
  level: debug

it fails with:

[17:15:37][I][app:029]: Running through setup()...
[17:15:37][C][ethernet:034]: Setting up Ethernet...
[17:15:37]Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
[17:15:37]
[17:15:37]Core  0 register dump:
[17:15:37]PC      : 0x400dfdcb  PS      : 0x00060630  A0      : 0x800e045a  A1      : 0x3ffbdbc0  
WARNING Decoded 0x400dfdcb: gpio_ll_input_enable at /home/majkrzak/.platformio/packages/framework-espidf/components/hal/esp32/include/hal/gpio_ll.h:319
 (inlined by) gpio_input_enable at /home/majkrzak/.platformio/packages/framework-espidf/components/driver/gpio.c:191
[17:15:37]A2      : 0x0000001d  A3      : 0x00000000  A4      : 0x000000c0  A5      : 0x00000020  
[17:15:37]A6      : 0x00000017  A7      : 0x00000000  A8      : 0xc010001d  A9      : 0x00013ffc  
[17:15:37]A10     : 0x000000ff  A11     : 0x00000000  A12     : 0x000000c0  A13     : 0xfffffffd  
[17:15:37]A14     : 0x00000000  A15     : 0x00000000  SAR     : 0x00000000  EXCCAUSE: 0x0000001c  
[17:15:37]EXCVADDR: 0x0000001d  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0xffffffff  
[17:15:37]
[17:15:37]
[17:15:37]Backtrace: 0x400dfdc8:0x3ffbdbc0 0x400e0457:0x3ffbdbf0 0x400e7518:0x3ffbdc20 0x400e3e52:0x3ffbdc60 0x400d3e81:0x3ffbdcc0 0x40120ee1:0x3ffbddb0 0x40120f59:0x3ffbddd0 0x400d8b68:0x3ffbddf0 0x400d9c51:0x3ffbde20 0x400d2e43:0x3ffbdeb0
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x400dfdc8: gpio_ll_input_enable at /home/majkrzak/.platformio/packages/framework-espidf/components/hal/esp32/include/hal/gpio_ll.h:319
 (inlined by) gpio_input_enable at /home/majkrzak/.platformio/packages/framework-espidf/components/driver/gpio.c:191
WARNING Decoded 0x400e0457: gpio_set_direction at /home/majkrzak/.platformio/packages/framework-espidf/components/driver/gpio.c:284
WARNING Decoded 0x400e7518: emac_w5500_init at /home/majkrzak/.platformio/packages/framework-espidf/components/esp_eth/src/esp_eth_mac_w5500.c:595
WARNING Decoded 0x400e3e52: esp_eth_driver_install at /home/majkrzak/.platformio/packages/framework-espidf/components/esp_eth/src/esp_eth.c:214 (discriminator 2)
WARNING Decoded 0x400d3e81: esphome::ethernet::EthernetComponent::setup() at /home/majkrzak/Development/esphome/.esphome/build/domofon/src/esphome/components/ethernet/ethernet_component.cpp:179
WARNING Decoded 0x40120ee1: esphome::Component::call_setup() at /home/majkrzak/Development/esphome/.esphome/build/domofon/src/esphome/core/component.cpp:77
WARNING Decoded 0x40120f59: esphome::Component::call() at /home/majkrzak/Development/esphome/.esphome/build/domofon/src/esphome/core/component.cpp:98
WARNING Decoded 0x400d8b68: esphome::Application::setup() at /home/majkrzak/Development/esphome/.esphome/build/domofon/src/esphome/core/application.cpp:38
WARNING Decoded 0x400d9c51: setup() at /home/majkrzak/Development/esphome/.esphome/build/domofon/src/main.cpp:144
WARNING Decoded 0x400d2e43: esphome::loop_task(void*) at /home/majkrzak/Development/esphome/.esphome/build/domofon/src/esphome/components/esp32/core.cpp:67

With default platform it works (despite nasty line:)

[17:28:40][I][ethernet:220]: Starting ethernet connection
[17:28:47]\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfd\xff\xff\xff\xbf\xfd\xbd\xff\xfd\xdf\xdf\xff\xff\xf7\xbf\xff\xff\xff\xff\xff\xfb\xff\xff\xbf\xff\xff\xff\xff\xff\xff\xff\xff\xff\xbf\xfd\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xbf\xff\xff\xff\xff\xbf\xff\xff\xfd\xf7\xff\xfe\xff\xff\xbf\xaf\xdf\xff\xff\xff\xff\xff\xff\xbf\xff\xfd\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xf7\xff\xff\xff\xef\xff\xff\xff\xff\xff\xff\xfd\xff\xff\xff\xff\xff\xff\xef\xf7\xef\xff\xff\xff\xff\xfb\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfd\xff\xff\xbf\xfb\xf7\xff\xbf\xff\xfb\xff\xff\xf7\xff\xdf\xff\xff\xff\xff\xff\xff\xbf\xff\xff\xff\xff\xff\xff\xef\xfb\xbdo\xff\xfb\xff\xbf\xff\xff\xdf\xff\xff\xff\xe7\xff\xef\xff\xff\xff\xff\xff\xff\xff\xfd\xff\xff\xff\xfd\xff\xff\xff\xff\xfb\xff\xbf\xff\xff\xff\xbd\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xbf\xff\xff\xff\xff\xff\xbd\xff\xff\xff\xff\xff\xbf\xff\xfb\x9f\xff\xff\xff\xff\xff\xff\xff\xff\xbf\xff\xff\xf7\xf7\xfb\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xdf\xff\xff\xfd\xff\xff\xff\xff}\xff\xf7\xfd\xff\xf7\xff\xfb\xff\xff\xff\xef\xff\xff\xff\xff\xff\xff\xff\xfd\xff\xff\xdf\xdf\xff\xff\xff\xff\xff\xff\xef\xff\xaf\xff\xff\xff\xff\xff\xff\xef\xff\xff\xff\xff\xff\xbf\xff\xff\xff\xff\xff\xff\xff\xbf\xfd\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xbf\xff\xff\xff\xff\xfd\xff\xaf\xff\xff\xff\xff\xff\xff\xfb\xff\xff\xff\xff\xf7\xff\xff\xff\xfd\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xdf߿\xff\xff\xf7\xdf\xff\xaf\xff\xff\xff\xff\xff\xdf\xef\xff\xff\xff\xff\xff\xfd\xff\xff\xff\xff\xff\xff\xff\xff\xff\xbf\xef\xff\xef\xef\xff\xff\xf7\xff\xff\xff\xff\xff\xff\xff\xef\xff\xff\xff\xff\xbf\xff\xff\xff\xff\xff\xff\xff\xbf\xff\xff\xff\xff\xff\xff\xff\xf7\xbf\xff\xbf\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xf5\xbf\xff\xff\xff\xff\xbf\xff\xff\xff\xff\xbf\xff\xff\xff\xf5\xff\xff\xff\xff\xff\xff\xff\xf7\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xfe\xfb\xff\xff\xff\xfd\xdf\xff\xf7\xef\xff\xfd\xff\xfd\xbf\xff\xff\xff\xff\xfb\xff\xff\xff\xff\xff\xff[C][mdns:115]: mDNS:

@gargamelonly
Copy link

Great work.
It is working for me with this configuration (Interrupt pin was a must to make it work):

esphome:
  name: racksensor
  friendly_name: RackSensor
  platformio_options:
    board_build.flash_mode: dio
    
esp32:
  board: esp32doit-devkit-v1
  framework:
    type: esp-idf

external_components:
- source:
    type: git
    url: https://github.com/JeroenVanOort/esphome/
    ref: eth-w5500
  components:
  - ethernet

ethernet:
  type: W5500
  mosi_pin: GPIO23
  miso_pin: GPIO19
  clk_pin: GPIO18
  cs_pin: GPIO5
  reset_pin: GPIO26
  interrupt_pin: GPIO22
  clock_speed: 25MHz

logger:
  level: DEBUG

@electronicDuck
Copy link

Well done to all for their work on this! Can this be extended to the rpi2040 too please? I have some W5500-EVB-Pico units to test on if it helps

@t3chguy
Copy link

t3chguy commented Jan 17, 2024

I have successfully tested this with the M5Stack AtomPoE using:

external_components:
  - source:
      type: git
      url: https://github.com/JeroenVanOort/esphome/
      ref: eth-w5500
    components: [ ethernet,network,api,esp32 ]

ethernet:
  type: W5500
  clk_pin: GPIO22
  mosi_pin: GPIO33
  miso_pin: GPIO23
  cs_pin: GPIO19
  clock_speed: 16Mhz

@emilianogetino
Copy link

emilianogetino commented Jan 26, 2024

for [pixelwave]

platformio_options: board_build.flash_mode: dio

Please could you put your configuration with the correction here? I can't get it to work, thank you

@emilianogetino
Copy link

emilianogetino commented Jan 26, 2024

Board LILYGO T-ETH-Lite [https://www.lilygo.cc/products/t-eth-lite]
It already works perfectly, thank you.
My code in case anyone needs:
`esp32:
board: esp32-s3-devkitc-1
framework:
type: esp-idf

esphome:
name: calefaccion
friendly_name: Calefaccion
platformio_options:
board_build.flash_mode: dio

logger:
baud_rate: 0 #no enviar a puerto serie
level: DEBUG

api:
encryption:
key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

external_components:

ethernet:
type: W5500
clk_pin: GPIO10
mosi_pin: GPIO12
miso_pin: GPIO11
cs_pin: GPIO09
interrupt_pin: GPIO13
reset_pin: GPIO14
#clock_speed: 25Mhz`

I don't know how to insert the code so that it is correct, I'm sorry, if someone explains it to me I would appreciate it.

@lboue
Copy link

lboue commented Feb 3, 2024

I have successfully tested with the M5Stack Module-LAN-13.2 too:

external_components:
  - source:
      type: git
      url: https://github.com/JeroenVanOort/esphome/
      ref: eth-w5500
    components: [ ethernet,network,api,esp32 ]

# M5StackCoreS3 Module-LAN-13.2
# Ethernet Controller	W5500
# https://docs.m5stack.com/en/module/LAN%20Module%2013.2
ethernet:
  type: W5500
  clk_pin: GPIO36
  mosi_pin: GPIO37
  miso_pin: GPIO35
  cs_pin: GPIO1
  clock_speed: 16Mhz
  #int: GPIO10
  #rst: GPIO0

Bootlog

[I][app:102]: ESPHome version 2024.1.0-dev compiled on Feb  3 2024, 17:46:10
[C][logger:443]: Logger:
[C][logger:444]:   Level: DEBUG
[C][logger:445]:   Log Baud Rate: 115200
[C][logger:447]:   Hardware UART: USB_CDC
[C][ethernet:308]: Ethernet:
[C][ethernet:450]:   IP Address: 192.168.1.140
[C][ethernet:451]:   Hostname: 'm5stackcores3-module-lan-132'
[C][ethernet:452]:   Subnet: 255.255.255.0
[C][ethernet:453]:   Gateway: 192.168.1.254
[C][ethernet:458]:   DNS1: 192.168.1.254
[C][ethernet:479]:   MAC Address: F6:12:FA:85:**:**
[C][ethernet:484]:   Is Full Duplex: YES
[C][ethernet:489]:   Link Speed: 100
[C][ethernet:311]:   CLK Pin: 36
[C][ethernet:312]:   MISO Pin: 35
[C][ethernet:313]:   MOSI Pin: 37
[C][ethernet:314]:   CS Pin: 1
[C][ethernet:315]:   IRQ Pin: 95
[C][ethernet:316]:   Reset Pin: -1
[C][ethernet:317]:   Clock Speed: 16 MHz
[C][ethernet:326]:   Type: W5500
[C][mdns:115]: mDNS:
[C][mdns:116]:   Hostname: m5stackcores3-module-lan-132
[C][ota:097]: Over-The-Air Updates:
[C][ota:098]:   Address: m5stackcores3-module-lan-132.local:3232

@dorkmatt
Copy link

dorkmatt commented Feb 5, 2024

Tested on the m5stack Atom Lite (ESP32-PICO-D4 based). Only the framework: arduino actually links up and gets a DHCP lease, the esp-idf never gets that far.

I've tried both board: m5stack-atom and board: m5stack-core-esp32 - in both cases, the ethernet connection is lost every 10 seconds (using arduino framework)

Removing network components such as OTA, web_server, time, etc doesn't seem to make a difference. The connection being lost is confirmed with an ongoing ICMP ping.

Config

# ESPHome 2023.12.9
esphome:
  name: m5stackatompoe
 
esp32:
  # https://docs.m5stack.com/en/atom/atom_poe
  board: "m5stack-core-esp32" # m5stack-atom is not reliable

logger:
  level: VERY_VERBOSE

external_components:
  - source:
      type: git
      url: https://github.com/JeroenVanOort/esphome/
      ref: eth-w5500
    components: [ ethernet,network,api,esp32 ]

ethernet:
  type: W5500
  clk_pin: GPIO22
  mosi_pin: GPIO33
  miso_pin: GPIO23
  cs_pin: GPIO19
  clock_speed: 16Mhz   

Bootlog

INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyUSB0 with baud rate 115200
[15:23:46][     3][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, AP[I][logger:351]: Log initialized
[15:23:46][I][app:029]: Running through setup()...
[15:23:46][V][app:030]: Sorting components by setup priority...
[15:23:46][VV][scheduler:063]: set_interval(name='', interval=60000, offset=25026)
[15:23:46][C][ethernet:034]: Setting up Ethernet...
[15:23:46][VV][esp-idf:000]: E (331) gpio: gpio_set_direction(274): GPIO number error
[15:23:46]
[15:23:46][VV][esp-idf:000]: E (331) gpio: gpio_set_pull_mode(238): GPIO number error
[15:23:46]
[15:23:46][VV][esp-idf:000]: E (342) gpio: gpio_set_intr_type(147): GPIO number error
[15:23:46]
[15:23:46][VV][esp-idf:000]: E (352) gpio: gpio_intr_enable(165): GPIO number error
[15:23:46]
[15:23:46][VV][esp-idf:000]: E (352) gpio: gpio_isr_handler_add(466): GPIO number error
[15:23:46]
[15:23:46][VV][scheduler:226]: Running interval '' with interval=60000 last_execution=4294882292 (now=375)
[15:23:46][I][ethernet:220]: Starting ethernet connection
[15:23:46][V][ethernet:407]: DHCP Client Status: 0
[15:23:48][V][ethernet:363]: [Ethernet event] ETH connected (num=2)
[15:23:50][V][ethernet:369]: [Ethernet event] ETH Got IP (num=4)
[15:23:50][I][app:062]: setup() finished successfully!
[15:23:50][I][app:102]: ESPHome version 2023.12.9 compiled on Feb  4 2024, 15:22:23
[15:23:50][C][logger:439]: Logger:
[15:23:50][C][logger:440]:   Level: VERY_VERBOSE
[15:23:50][C][logger:441]:   Log Baud Rate: 115200
[15:23:50][C][logger:443]:   Hardware UART: UART0
[15:23:50][C][ethernet:308]: Ethernet:
[15:23:50][C][ethernet:450]:   IP Address: 192.168.40.187
[15:23:50][C][ethernet:451]:   Hostname: 'm5stackatompoe'
[15:23:50][C][ethernet:452]:   Subnet: 255.255.255.0
[15:23:50][C][ethernet:453]:   Gateway: 192.168.40.1
[15:23:50][C][ethernet:458]:   DNS1: 192.168.40.1
[15:23:50][C][ethernet:459]:   DNS2: 0.0.0.0
[15:23:50][C][ethernet:479]:   MAC Address: E8:6B:EA:xx:xx:xx
[15:23:50][C][ethernet:484]:   Is Full Duplex: YES
[15:23:50][C][ethernet:489]:   Link Speed: 100
[15:23:50][C][ethernet:311]:   CLK Pin: 22
[15:23:50][C][ethernet:312]:   MISO Pin: 23
[15:23:50][C][ethernet:313]:   MOSI Pin: 33
[15:23:50][C][ethernet:314]:   CS Pin: 19
[15:23:50][C][ethernet:315]:   IRQ Pin: 200
[15:23:50][C][ethernet:316]:   Reset Pin: -1
[15:23:50][C][ethernet:317]:   Clock Speed: 16 MHz
[15:23:50][C][ethernet:326]:   Type: W5500
[15:23:50][C][mdns:115]: mDNS:
[15:23:50][C][mdns:116]:   Hostname: m5stackatompoe
[15:23:50][V][mdns:117]:   Services:
[15:23:50][V][mdns:119]:   - _http, _tcp, 80
[15:23:50][V][mdns:121]:     TXT: version = 2023.12.9
[15:24:00][V][ethernet:363]: [Ethernet event] ETH disconnected (num=3)
[15:24:00][W][ethernet:246]: Connection via Ethernet lost! Re-connecting...
[15:24:00][V][ethernet:407]: DHCP Client Status: 0
[15:24:02][V][ethernet:363]: [Ethernet event] ETH connected (num=2)
[15:24:04][V][ethernet:369]: [Ethernet event] ETH Got IP (num=4)
[15:24:04][I][ethernet:231]: Connected via Ethernet!
[15:24:04][C][ethernet:450]:   IP Address: 192.168.40.187
[15:24:04][C][ethernet:451]:   Hostname: 'm5stackatompoe'
[15:24:04][C][ethernet:452]:   Subnet: 255.255.255.0
[15:24:04][C][ethernet:453]:   Gateway: 192.168.40.1
[15:24:04][C][ethernet:458]:   DNS1: 192.168.40.1
[15:24:04][C][ethernet:459]:   DNS2: 0.0.0.0
[15:24:04][C][ethernet:479]:   MAC Address: E8:6B:EA:xx:xx:xx
[15:24:04][C][ethernet:484]:   Is Full Duplex: YES
[15:24:04][C][ethernet:489]:   Link Speed: 100
[15:24:18][V][ethernet:363]: [Ethernet event] ETH disconnected (num=3)
[15:24:18][W][ethernet:246]: Connection via Ethernet lost! Re-connecting...
[15:24:18][V][ethernet:407]: DHCP Client Status: 0
[15:24:20][V][ethernet:363]: [Ethernet event] ETH connected (num=2)
[15:24:21][VV][scheduler:226]: Running interval '' with interval=60000 last_execution=4294942292 (now=35002)
[15:24:22][V][ethernet:369]: [Ethernet event] ETH Got IP (num=4)
[15:24:22][I][ethernet:231]: Connected via Ethernet!

This component also conflicts with any use of BLE and crashes:

Connecting....
Chip is ESP32-PICO-D4 (revision v1.1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: e8:6b:ea:xx:xx:xx
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00010000 to 0x0015cfff...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Compressed 1361984 bytes to 884000...
Wrote 1361984 bytes (884000 compressed) at 0x00010000 in 79.3 seconds (effective 137.4 kbit/s)...
Hash of data verified.
Compressed 18912 bytes to 13028...
Wrote 18912 bytes (13028 compressed) at 0x00001000 in 1.4 seconds (effective 107.7 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 144...
Wrote 3072 bytes (144 compressed) at 0x00008000 in 0.1 seconds (effective 410.5 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 654.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyUSB0 with baud rate 115200
[16:02:15][I][logger:351]: Log initialized
[16:02:15][I][app:029]: Running through setup()...
[16:02:15][C][esp32_ble:027]: Setting up BLE...
[16:02:15][C][ethernet:034]: Setting up Ethernet...
[16:02:16]Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
[16:02:16]
[16:02:16]Core  1 register dump:
[16:02:16]PC      : 0x400e3d7b  PS      : 0x00060230  A0      : 0x800e45ca  A1      : 0x3ffcc9c0  
WARNING Decoded 0x400e3d7b: gpio_ll_input_enable at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/gpio_ll.h:313
 (inlined by) gpio_input_enable at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/driver/gpio.c:191
[16:02:16]A2      : 0x00000021  A3      : 0x00000000  A4      : 0x000000a5  A5      : 0x00000020  
[16:02:16]A6      : 0x00000000  A7      : 0x3ffb6c68  A8      : 0xc0100021  A9      : 0x00013ffc  
[16:02:16]A10     : 0x00000007  A11     : 0x00000000  A12     : 0x000000a5  A13     : 0x3ffd1398  
[16:02:16]A14     : 0x007bef48  A15     : 0x00000004  SAR     : 0x00000005  EXCCAUSE: 0x0000001c  
[16:02:16]EXCVADDR: 0x00000021  LBEG    : 0x40090df0  LEND    : 0x40090dfb  LCOUNT  : 0x00000000  
[16:02:16]
[16:02:16]
[16:02:16]Backtrace:0x400e3d78:0x3ffcc9c00x400e45c7:0x3ffcc9f0 0x400f4a06:0x3ffcca20 0x400f0ebe:0x3ffcca60 0x400d604c:0x3ffccac0 0x401c9aa9:0x3ffccbb0 0x401c9b2d:0x3ffccbd0 0x400da9b0:0x3ffccbf0 0x400dc644:0x3ffccc20 0x400e3866:0x3ffcccb0 
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x400e3d78: gpio_ll_input_enable at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/gpio_ll.h:313
 (inlined by) gpio_input_enable at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/driver/gpio.c:191
WARNING Decoded 0x400e45c7: gpio_set_direction at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/driver/gpio.c:284
WARNING Decoded 0x400f4a06: emac_w5500_init at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_eth/src/esp_eth_mac_w5500.c:595
WARNING Decoded 0x400f0ebe: esp_eth_driver_install at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_eth/src/esp_eth.c:214 (discriminator 2)
WARNING Decoded 0x400d604c: esphome::ethernet::EthernetComponent::setup() at /data/build/m5stackatompoe/src/esphome/components/ethernet/ethernet_component.cpp:179
WARNING Decoded 0x401c9aa9: esphome::Component::call_setup() at /data/build/m5stackatompoe/src/esphome/core/component.cpp:77
WARNING Decoded 0x401c9b2d: esphome::Component::call() at /data/build/m5stackatompoe/src/esphome/core/component.cpp:98
WARNING Decoded 0x400da9b0: esphome::Application::setup() at /data/build/m5stackatompoe/src/esphome/core/application.cpp:38
WARNING Decoded 0x400dc644: setup() at /data/build/m5stackatompoe/src/main.cpp:216
WARNING Decoded 0x400e3866: loopTask(void*) at /data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:42
[16:02:17]
[16:02:17]
[16:02:17]
[16:02:17]
[16:02:17]ELF file SHA256: 0000000000000000
[16:02:17]
[16:02:17]Rebooting...

@maxgerhardt
Copy link

maxgerhardt commented Feb 16, 2024

this is the first SPI-based ethernet chip being added

Oh wow, I didn't expect this.. But this PR gives me the right ideas to implement this for the Arduino-Pico RP2040 core. A W5500-ECB-Pico board specifically, on-board W5500 chip and ethernet jack. I'm a bit suprised that noone ever wanted to run ESPHome on such a platform? But I'll take the opportunity.

Edit: Have done so in https://github.com/maxgerhardt/w5500-evb-pico-esphome

@JeroenVanOort
Copy link
Contributor Author

JeroenVanOort commented Feb 22, 2024

How would you suggest to do this? I'm not very familiar with the ESPHome codebase.

FINAL_VALIDATE_SCHEMA is used to validate the current component schema against any other in the config.

@jesserockz Could you provide some practical help? I don't understand what you're pointing to. With this, I hope this PR can be merged soon.

@t3chguy
Copy link

t3chguy commented Feb 24, 2024

@JeroenVanOort your latest changes seem to have broken it for me on the M5 Atom PoE on ESPHome 2024.2.0

I (29) boot: ESP-IDF 4.4.6 2nd stage bootloader
I (29) boot: compile time 15:11:34
I (29) boot: Multicore bootloader
I (33) boot: chip revision: v1.0
I (37) boot.esp32: SPI Speed      : 40MHz
I (41) boot.esp32: SPI Mode       : DIO
I (46) boot.esp32: SPI Flash Size : 4MB
I (50) boot: Enabling RNG early entropy source...
I (56) boot: Partition Table:
I (59) boot: ## Label            Usage          Type ST Offset   Length
I (67) boot:  0 otadata          OTA data         01 00 00009000 00002000
I (74) boot:  1 phy_init         RF data          01 01 0000b000 00001000
I (81) boot:  2 app0             OTA app          00 10 00010000 001c0000
I (89) boot:  3 app1             OTA app          00 11 001d0000 001c0000
I (96) boot:  4 nvs              WiFi data        01 02 00390000 0006d000
I (104) boot: End of partition table
I (108) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=3766ch (226924) map
I (199) esp_image: segment 1: paddr=00047694 vaddr=3ffbdb60 size=04970h ( 18800) load
I (206) esp_image: segment 2: paddr=0004c00c vaddr=40080000 size=0400ch ( 16396) load
I (213) esp_image: segment 3: paddr=00050020 vaddr=400d0020 size=c8d5ch (822620) map
I (511) esp_image: segment 4: paddr=00118d84 vaddr=4008400c size=167d8h ( 92120) load
I (562) boot: Loaded app from partition at offset 0x10000
I (562) boot: Disabling RNG early entropy source...
I (574) cpu_start: Multicore app
I (574) cpu_start: Pro cpu up.
I (574) cpu_start: Starting app cpu, entry point is 0x4008346c
I (565) cpu_start: App cpu up.
I (595) cpu_start: Pro cpu start user code
I (595) cpu_start: cpu freq: 160000000
I (595) cpu_start: Application information:
I (599) cpu_start: Project name:     m5atompoe
I (604) cpu_start: App version:      2024.2.0
I (609) cpu_start: Compile time:     Feb 24 2024 15:10:20
I (615) cpu_start: ELF file SHA256:  469f35d16ff58f67...
I (621) cpu_start: ESP-IDF:          4.4.6
I (626) cpu_start: Min chip rev:     v0.0
I (631) cpu_start: Max chip rev:     v3.99 
I (636) cpu_start: Chip rev:         v1.0
I (641) heap_init: Initializing. RAM available for dynamic allocation:
I (648) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (654) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (660) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (666) heap_init: At 3FFCA3C0 len 00015C40 (87 KiB): DRAM
I (672) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (678) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (685) heap_init: At 4009A7E4 len 0000581C (22 KiB): IRAM
I (692) spi_flash: detected chip: gd
I (695) spi_flash: flash io: dio
I (701) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
[I][logger:359]: Log initialized
[C][ota:483]: There have been 1 suspected unsuccessful boot attempts.
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[C][esp32_rmt_led_strip:021]: Setting up ESP32 LED Strip...
[D][esp-idf:000]: I (1159) gpio: GPIO[39]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 

[D][binary_sensor:034]: 'Atom Button': Sending initial state OFF
[C][light:035]: Setting up light 'Magnifying Light'...
[C][light:035]: Setting up light 'Atom Light'...
[D][light:036]: 'Atom Light' Setting:
[D][light:041]:   Color mode: RGB
[D][light:085]:   Transition length: 1.0s
[C][esp32_ble:027]: Setting up BLE...
[C][ethernet:034]: Setting up Ethernet...
Guru Meditation Error: Core  0 panic'ed (LoadStoreAlignment). Exception was unhandled.

Core  0 register dump:
PC      : 0x40130df5  PS      : 0x00060033  A0      : 0x801310f3  A1      : 0x3ffce740  
A2      : 0x3ff49062  A3      : 0x00000000  A4      : 0x3ffbdba8  A5      : 0x3ffd2f98  
A6      : 0x00000000  A7      : 0x00000002  A8      : 0x3ff49000  A9      : 0xffffff7f  
A10     : 0x3ffbdba8  A11     : 0x3ffc312c  A12     : 0x000000a5  A13     : 0xfffffffd  
A14     : 0x00000000  A15     : 0x00000000  SAR     : 0x00000005  EXCCAUSE: 0x00000009  
EXCVADDR: 0x3ff49062  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0x00000000  


Backtrace: 0x40130df2:0x3ffce740 0x401310f0:0x3ffce770 0x40139904:0x3ffce7a0 0x40135dd7:0x3ffce7e0 0x400dea41:0x3ffce840 0x40193399:0x3ffce930 0x40193411:0x3ffce950 0x400e5654:0x3ffce970 0x400e7e06:0x3ffce9a0 0x400dadef:0x3ffcea70




ELF file SHA256: 469f35d16ff58f67

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6652
ho 0 tail 12 room 4
load:0x40078000,len:15060
load:0x40080400,len:3836
entry 0x4008069c

Switching back to WiFi it works fine =(

@JeroenVanOort
Copy link
Contributor Author

Have you tried lowering the clock speed? For example:

ethernet:
  clock_speed: 10Mhz

@t3chguy
Copy link

t3chguy commented Feb 25, 2024

It worked fine previously at 16MHz and has the same error at 10MHz.

@EverythingSmartHome
Copy link

Can confirm that the following code works for me on ESP32-S3 using the Arduino Framework:

external_components:
  - source:
      type: git
      url: https://github.com/JeroenVanOort/esphome/
      ref: eth-w5500
    components: [ ethernet ]

ethernet:
  type: W5500
  clk_pin: GPIO18
  interrupt_pin: GPIO46
  mosi_pin: GPIO17
  miso_pin: GPIO16
  cs_pin: GPIO8
  clock_speed: 16Mhz

Been running for 4 days straight without any drops, very stable so far but will run for a while longer.

For some reason as mentioned above, it doesn't seem to work if the framework is switched to ESP-IDF which surprised me, I expected the other way around if anything.

@jesserockz
Copy link
Member

How would you suggest to do this? I'm not very familiar with the ESPHome codebase.

FINAL_VALIDATE_SCHEMA is used to validate the current component schema against any other in the config.

@jesserockz Could you provide some practical help? I don't understand what you're pointing to. With this, I hope this PR can be merged soon.

Ill see if I can figure it out. I was not a big part in the recent SPI refactor so I am learning how that works too.

@JeroenVanOort JeroenVanOort requested a review from a team as a code owner February 29, 2024 22:22
@codecov-commenter
Copy link

codecov-commenter commented Feb 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.80%. Comparing base (4d8b5ed) to head (dd06b69).
Report is 35 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #4424      +/-   ##
==========================================
+ Coverage   53.70%   53.80%   +0.09%     
==========================================
  Files          50       50              
  Lines        9408     9445      +37     
  Branches     1654     1661       +7     
==========================================
+ Hits         5053     5082      +29     
  Misses       4056     4056              
- Partials      299      307       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jesserockz jesserockz merged commit 4a9d777 into esphome:dev Mar 1, 2024
56 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

W5500 spi ethernet