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

Add support for Davicom DM9051 SPI Ethernet Controller #2427

Open
tudstudent opened this issue Oct 12, 2023 · 23 comments · May be fixed by esphome/esphome#6861
Open

Add support for Davicom DM9051 SPI Ethernet Controller #2427

tudstudent opened this issue Oct 12, 2023 · 23 comments · May be fixed by esphome/esphome#6861

Comments

@tudstudent
Copy link

Describe the problem you have/What new integration you would like
Introduce support for the Davicom DM9051 SPI Ethernet Controller

Please describe your use case for this integration and alternatives you've tried:
The ETH01 Evo modules are equipped with this "new" ETH chip, enabling POE usage, however device not currently supported in ESPHome.

Additional context

Davicom Website - Product Page
Espreff Description on how to implement

Unfortunately I am not a programmer, will be able to test, but not to make pull requests in this topic, therefore asking for implementation to this community.

@tudstudent
Copy link
Author

Additionally:
Driver source code

@cleymaba
Copy link

cleymaba commented Nov 3, 2023

Support for DM9051 was added to Arduino ESP32 Core version 3.0.0

Espressif Announcement

@khabbar-a
Copy link

I bought 5 eth01-evo units on Aliexpress that mount this chip thinking they were compatible with esphome but I wasn't able to make them work, does anyone have a solution thanks

@tudstudent
Copy link
Author

The EVO work perfectly, EXCEPT the physical ETH01 port.
Unfortunately as you have seen my request this is not (yet) supported in ESPHome.

All other functionalities work fine.

I suppose you have them working by WiFi?

@d3rsch0rsch
Copy link

+1 for this requests, as the eth01-evo ist by far the cheapest solution for PoE enabled ESP32.

@skinkie
Copy link

skinkie commented Dec 28, 2023

I have added an issue to the eth01-evo repo with full documentation and an example to get wired ethernet working.
AI6YP/eth01-evo#2

@tube0013
Copy link

With the W5500 support added which is also based on an SPI implementation, should this be too hard to add now?

@Imanol82
Copy link

Any update?
Thanks!

@sabaatworld
Copy link

I purchased a bunch of these boards, just to realize that it's not supported. It would be great if this board could be added to ESPHome.

@bmork
Copy link

bmork commented Jun 4, 2024

I started looking at this, with partial success. WiP code (expect lots of force-pushing and buggy commits!) is here:
https://github.com/bmork/esphome/tree/dm9051

Not sure I like the current ethernet SPI solution. Will probably try to change that into using the spi bus component. Doesn't seem impossible. I had to drop the only W5500 specific part (SPI framing) anyway, since the DM9051 uses different framing. Both drivers will auto-configure the format anyway as long as it's unset, so why bother? Letting the driver DTRT looks much better than moving that knowlegde into esphome.

But first task is to make RX more stable. It's pretty unusable as-is.

EDIT: very happy to admit I was completely wrong. Reducing SPI clock to 8 MHz seems to stabilize this completely. Will move focus to cleaning up the SPI bus config and submit this.

EDIT2: reconsidering. Guess it's best to add this feature using the current scheme, and then modify the scheme later in a separate PR.

bmork added a commit to bmork/esphome that referenced this issue Jun 4, 2024
Fixes esphome/feature-requests#2427

Tested on an ETH01-Evo board using

  ethernet:
    type: DM9051
    clk_pin: GPIO07
    mosi_pin: GPIO10
    miso_pin: GPIO03
    cs_pin: GPIO09
    interrupt_pin: GPIO08
    reset_pin: GPIO06
    clock_speed: 20MHz

A number of read errors was observed with 26 MHz
(default) or higher clock speeds. This might be a
board specific problem.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
bmork added a commit to bmork/esphome that referenced this issue Jun 4, 2024
Fixes esphome/feature-requests#2427

Tested on an ETH01-Evo board using

  ethernet:
    type: DM9051
    clk_pin: GPIO07
    mosi_pin: GPIO10
    miso_pin: GPIO03
    cs_pin: GPIO09
    interrupt_pin: GPIO08
    reset_pin: GPIO06
    clock_speed: 20MHz

A number of read errors was observed with 26 MHz
(default) or higher clock speeds. This might be a
board specific problem.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
@bmork bmork linked a pull request Jun 4, 2024 that will close this issue
13 tasks
bmork added a commit to bmork/esphome that referenced this issue Jun 4, 2024
Fixes esphome/feature-requests#2427

Tested on an ETH01-Evo board using

  ethernet:
    type: DM9051
    clk_pin: GPIO07
    mosi_pin: GPIO10
    miso_pin: GPIO03
    cs_pin: GPIO09
    interrupt_pin: GPIO08
    reset_pin: GPIO06
    clock_speed: 20MHz

A number of read errors was observed with 26 MHz
(default) or higher clock speeds. This might be a
board specific problem.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
bmork added a commit to bmork/esphome that referenced this issue Jun 4, 2024
Fixes esphome/feature-requests#2427

Tested on an ETH01-Evo board using

  ethernet:
    type: DM9051
    clk_pin: GPIO07
    mosi_pin: GPIO10
    miso_pin: GPIO03
    cs_pin: GPIO09
    interrupt_pin: GPIO08
    reset_pin: GPIO06
    clock_speed: 20MHz

A number of read errors was observed with 26 MHz
(default) or higher clock speeds. This might be a
board specific problem.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
bmork added a commit to bmork/esphome that referenced this issue Jun 4, 2024
Fixes esphome/feature-requests#2427

Tested on an ETH01-Evo board using

  ethernet:
    type: DM9051
    clk_pin: GPIO07
    mosi_pin: GPIO10
    miso_pin: GPIO03
    cs_pin: GPIO09
    interrupt_pin: GPIO08
    reset_pin: GPIO06
    clock_speed: 20MHz

A number of read errors was observed with 26 MHz
(default) or higher clock speeds. This might be a
board specific problem.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
bmork added a commit to bmork/esphome that referenced this issue Jun 6, 2024
Fixes esphome/feature-requests#2427

Tested on an ETH01-Evo board using

  ethernet:
    type: DM9051
    clk_pin: GPIO07
    mosi_pin: GPIO10
    miso_pin: GPIO03
    cs_pin: GPIO09
    interrupt_pin: GPIO08
    reset_pin: GPIO06
    clock_speed: 20MHz

A number of read errors was observed with 26 MHz
(default) or higher clock speeds. This might be a
board specific problem.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
@bmork
Copy link

bmork commented Jun 6, 2024

So I realized why the current code didn't use the esphome spi component: We need commit ecd1759a0ba6 ("feat(esp_eth): abstraction of SPI driver for SPI Ethernet modules") in esp-idf for that, and it was added as recently as v5.2

I did a quick hack, but it is not exactly ready to merge... It boots and sort of works. But it's easy to make it fall over with an

spi_master: spi_device_acquire_bus(1031): Cannot acquire bus when a polling transaction is in progress.

error by simply flood pinging the device. I will leave it there until we both have a use case and esp-idf v5.2 or higher is recommended. The current PR is fine.

My experimental hack is here if anyone is interested: https://github.com/bmork/esphome/tree/dm9051-spidev-experimental

bmork added a commit to bmork/esphome that referenced this issue Aug 7, 2024
Fixes esphome/feature-requests#2427

Tested on an ETH01-Evo board using

  ethernet:
    type: DM9051
    clk_pin: GPIO07
    mosi_pin: GPIO10
    miso_pin: GPIO03
    cs_pin: GPIO09
    interrupt_pin: GPIO08
    reset_pin: GPIO06
    clock_speed: 20MHz

A number of read errors was observed with 26 MHz
(default) or higher clock speeds. This might be a
board specific problem.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
bmork added a commit to bmork/esphome that referenced this issue Aug 7, 2024
Fixes esphome/feature-requests#2427

Tested on an ETH01-Evo board using

  ethernet:
    type: DM9051
    clk_pin: GPIO07
    mosi_pin: GPIO10
    miso_pin: GPIO03
    cs_pin: GPIO09
    interrupt_pin: GPIO08
    reset_pin: GPIO06
    clock_speed: 20MHz

A number of read errors was observed with 26 MHz
(default) or higher clock speeds. This might be a
board specific problem.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
@Imanol82
Copy link

Imanol82 commented Sep 5, 2024

Hello!
I was very excited to see that you had managed to get the ETH01-EVO working but I can't... Is it because it hasn't been officially uploaded yet or something like that?

image

But the result is this one:

image

What am I doing wrong?

Thank you very much!

@randybb
Copy link

randybb commented Sep 5, 2024

@Imanol82 It was not merged yet, this is the reason why it is not working. The PR was linked, but here is a direct link to the config esphome/esphome#6861 (comment)

@Imanol82
Copy link

Imanol82 commented Sep 5, 2024

Well, I'll have to wait for it to come out officially (because that doesn't work for me).
It looks like they are making a lot of progress :)

Thank you!

@randybb
Copy link

randybb commented Sep 5, 2024

You are missing the external component part - which will pull the component from that PR.

@Imanol82
Copy link

Imanol82 commented Sep 5, 2024

Sorry.
I'm a bit beginner. I don't understand what you're telling me.

Thank you very much!!!

@randybb
Copy link

randybb commented Sep 5, 2024

This part :)

external_components:
  - source: github://pr#6861
    components:
      - ethernet

@Imanol82
Copy link

Imanol82 commented Sep 5, 2024

Yes, now it is compiling

Thank you very much!

@Imanol82
Copy link

Imanol82 commented Sep 5, 2024

hahahaha now I'm not able to flash...

@Imanol82
Copy link

Imanol82 commented Sep 5, 2024

I win hahahaha. Online :)

image

Thank you very much @randybb

bmork added a commit to bmork/esphome that referenced this issue Oct 1, 2024
Fixes esphome/feature-requests#2427

Tested on an ETH01-Evo board using

  ethernet:
    type: DM9051
    clk_pin: GPIO07
    mosi_pin: GPIO10
    miso_pin: GPIO03
    cs_pin: GPIO09
    interrupt_pin: GPIO08
    reset_pin: GPIO06
    clock_speed: 20MHz

A number of read errors was observed with 26 MHz
(default) or higher clock speeds. This might be a
board specific problem.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
bmork added a commit to bmork/esphome that referenced this issue Nov 1, 2024
Fixes esphome/feature-requests#2427

Tested on an ETH01-Evo board using

  ethernet:
    type: DM9051
    clk_pin: GPIO07
    mosi_pin: GPIO10
    miso_pin: GPIO03
    cs_pin: GPIO09
    interrupt_pin: GPIO08
    reset_pin: GPIO06
    clock_speed: 20MHz

A number of read errors was observed with 26 MHz
(default) or higher clock speeds. This might be a
board specific problem.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
@Imanol82
Copy link

Imanol82 commented Nov 3, 2024

Has something happened with the new ESPHome update?

I get this error when trying to update the ETH01-EVO:

image

Thank you!

@bmork
Copy link

bmork commented Nov 4, 2024

@Imanol82 - the PR was updated to apply on top of
esphome/esphome@302ba28
which is in the dev branch now. I'm afraid this temporarily breaks using the PR as an external component with any released esphome versions.

You might be able to use the previous version at
esphome/esphome@d5bdf25
if necessary.

Or use the esphome dev branch instead of 2024.10.2

@Imanol82
Copy link

Imanol82 commented Nov 4, 2024

If it is a problem that you already have under control and I just have to wait, I will wait.

As it is, the ESP32 now works fine for me, it just won't let me update it.

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants