esphome
esphome copied to clipboard
Support DM9051 SPI ethernet device
What does this implement/fix?
Adds support for the Davicom DM9051 SPI Ethernet Controller
Types of changes
- [ ] Bugfix (non-breaking change which fixes an issue)
- [x] 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 https://github.com/esphome/feature-requests/issues/2427
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#3914
Test Environment
- [ ] ESP32
- [x] ESP32 IDF
- [ ] ESP8266
- [ ] RP2040
- [ ] BK72xx
- [ ] RTL87xx
Example entry for config.yaml:
# Example config.yaml for the ETH01-Evo board
ethernet:
type: DM9051
clk_pin: GPIO07
mosi_pin: GPIO10
miso_pin: GPIO03
cs_pin: GPIO09
interrupt_pin: GPIO08
reset_pin: GPIO06
clock_speed: 8MHz
Checklist:
- [x] The code change is tested and works locally.
- [x] Tests have been added to verify that the new code works (under
tests/folder).
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated in esphome-docs.
Codecov Report
Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
Project coverage is 17.00%. Comparing base (
f35be6b) to head (2b41ce2).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| esphome/components/ethernet/__init__.py | 0.00% | 3 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## dev #6861 +/- ##
=======================================
Coverage 17.00% 17.00%
=======================================
Files 1168 1168
Lines 48830 48830
Branches 5861 5861
=======================================
Hits 8305 8305
Misses 39948 39948
Partials 577 577
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Heyhey,
got one of the "DM9051 SPI ethernet" equipped ESP32-C3 (eth01-evo) and am willing to review. Unfortunately, I have now idea what to do and how to build. Can someone please elaborate?
@JakobTewes I'm no expert here, but luckily this question is answered in https://esphome.io/guides/faq.html#how-can-i-test-a-pull-request
So just use your reasonably uptodate esphome installation and add an external_component reference to this pull request. Something like
esphome:
name: eth01-evo
esp32:
variant: esp32c3
board: esp32-c3-devkitm-1
framework:
type: esp-idf
version: latest
platform_version: 6.5.0
external_components:
- source: github://pr#6861
components:
- ethernet
logger:
hardware_uart: UART0
api:
ota:
platform: esphome
ethernet:
type: DM9051
clk_pin: GPIO07
mosi_pin: GPIO10
miso_pin: GPIO03
cs_pin: GPIO09
interrupt_pin: GPIO08
reset_pin: GPIO06
clock_speed: 8MHz
And anything else you like of course. Then simply build and load the firmware like usual. E.g. esphome run test.yaml
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
AFAIU the current SPI ethernet implementation depends on esp-idf, so I wonder if it is appropriate to raise an error in the python code if a SPI device is selected using another framework?
This seems more user friendly than failing silently to me. And it simplifies all the ifdeffery somewhat. But it also means that we have to delete test-w5500.esp32-ard.yaml since it will fail to build (intentionally).
Built and installed (via USB) successfully with these options:
esphome:
name: $devicename
comment: ${device_description}
build_path: esp32
platformio_options:
upload_speed: 115200
esp32:
board: esp32-c3-devkitm-1
# currently needed, but not in the future
variant: esp32c3
framework:
type: esp-idf
version: latest
platform_version: 6.5.0
external_components:
- source: github://pr#6861
components:
- ethernet
ethernet:
# https://github.com/esphome/esphome/pull/6861
type: DM9051
clk_pin: GPIO07
mosi_pin: GPIO10
miso_pin: GPIO03
cs_pin: GPIO09
interrupt_pin: GPIO08
reset_pin: GPIO06
clock_speed: 8MHz
Now also tested via wireless upload and works like a charm.
hmm.. 🤔 Somehow I'm unable to build this... This is what I get
build logs
INFO ESPHome 2024.8.3
INFO Reading configuration /config/esphome/eth01.yaml...
WARNING The selected ESP-IDF framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
WARNING The selected ESP-IDF framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
WARNING GPIO9 is a strapping PIN and should only be used for I/O with care.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO8 is a strapping PIN and should only be used for I/O with care.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
INFO Updating https://github.com/espressif/[email protected]
INFO Compiling app...
Processing eth01-evo (board: esp32-c3-devkitm-1; framework: espidf; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
- framework-espidf @ 3.50102.240122 (5.1.2)
- tool-cmake @ 3.16.4
- tool-ninja @ 1.7.1
- tool-riscv32-esp-elf-gdb @ 12.1.0+20221002
- tool-xtensa-esp-elf-gdb @ 12.1.0+20221002
- toolchain-esp32ulp @ 2.35.0-20220830
- toolchain-riscv32-esp @ 12.2.0+20230208
Reading CMake configuration...
-- git rev-parse returned 'fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).'
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- The ASM compiler identification is GNU
-- Found assembler: /data/cache/platformio/packages/toolchain-riscv32-esp/bin/riscv32-esp-elf-gcc
-- Check for working C compiler: /data/cache/platformio/packages/toolchain-riscv32-esp/bin/riscv32-esp-elf-gcc
-- Check for working C compiler: /data/cache/platformio/packages/toolchain-riscv32-esp/bin/riscv32-esp-elf-gcc -- broken
-- Configuring incomplete, errors occurred!
See also "/data/esp32/.pioenvs/eth01-evo/CMakeFiles/CMakeOutput.log".
See also "/data/esp32/.pioenvs/eth01-evo/CMakeFiles/CMakeError.log".
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
CMake Error at /data/cache/platformio/packages/tool-cmake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"/data/cache/platformio/packages/toolchain-riscv32-esp/bin/riscv32-esp-elf-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /data/esp32/.pioenvs/eth01-evo/CMakeFiles/CMakeTmp
Run Build Command(s):/data/cache/platformio/packages/tool-ninja/ninja cmTC_8fadc && [1/2] Building C object CMakeFiles/cmTC_8fadc.dir/testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_8fadc.dir/testCCompiler.c.obj
/data/cache/platformio/packages/toolchain-riscv32-esp/bin/riscv32-esp-elf-gcc -march=rv32imc_zicsr_zifencei -o CMakeFiles/cmTC_8fadc.dir/testCCompiler.c.obj -c testCCompiler.c
riscv32-esp-elf-gcc: fatal error: cannot execute 'as': execvp: No such file or directory
compilation terminated.
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
/data/cache/platformio/packages/framework-espidf/tools/cmake/project.cmake:448 (__project)
CMakeLists.txt:3 (project)
========================== [FAILED] Took 1.99 seconds ==========================
using the following config
config
esphome:
name: eth01-evo
friendly_name: ETH01-evo
build_path: esp32
platformio_options:
upload_speed: 115200
esp32:
variant: esp32c3
board: esp32-c3-devkitm-1
framework:
type: esp-idf
version: latest
platform_version: 6.5.0
external_components:
- source: github://pr#6861
components:
- ethernet
ethernet:
# https://github.com/esphome/esphome/pull/6861
type: DM9051
clk_pin: GPIO07
mosi_pin: GPIO10
miso_pin: GPIO03
cs_pin: GPIO09
interrupt_pin: GPIO08
reset_pin: GPIO06
clock_speed: 8MHz
Edit :
Turns out it won't build on ESPHome 2024.8.3 builtin home-assistant, started the latest esphome image on my local docker instead of in home assistant and it did build and install over usb and even updated over the air... My mistake it seems, but strangely it still reports being ESPHome 2024.8.3 so I'm quite baffeled as to why it would build within a docker container within my wsl running ghcr.io/esphome/esphome and not within my HomeAssitant VM running ghcr.io/esphome/esphome-hassio:2024.8.3....
rebased onto dev after the openeth PR (#7020) was merged
force pushed resolved conflicts after 302ba2874e12 ("Support W5500 SPI-Ethernet polling mode if framework is supported (#7503)")
and added polling mode support for DM9051 too using that implementation.
@jesserockz ping?
@bmork
It is no longer possible to use your component for the DM9051 controller.
external_components:
- source: github://pr#6861
components:
- ethernet
I get the error below when compiling. When will your changes be merged?
ERROR Unable to import component ethernet:
Traceback (most recent call last):
File "/home/clement/.local/lib/python3.10/site-packages/esphome/loader.py", line 177, in _lookup_module
module = importlib.import_module(f"esphome.components.{domain}")
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/clement/Apps/GitHub/esphome-yambms/.esphome/external_components/7aa91a8f/esphome/components/ethernet/__init__.py", line 13, in <module>
from esphome.const import (
ImportError: cannot import name 'CONF_POLLING_INTERVAL' from 'esphome.const' (/home/clement/.local/lib/python3.10/site-packages/esphome/const.py)
Failed config
ethernet: [source packages/board/board_esp32-c3-eth01-evo.yaml:42]
Component not found: ethernet.
id: my_network
type: DM9051
clk_pin: 7
mosi_pin: 10
miso_pin: 3
cs_pin: 9
interrupt_pin: 8
reset_pin: 6
clock_speed: 20MHz
Thanks for your work.
It is no longer possible to use your component for the
DM9051controller.
This is because it now depends on https://github.com/esphome/esphome/commit/302ba2874e12960c76a624fa6066bf5df1ffac2e , which is only in the dev branch at the moment. The PR has to apply to dev to be mergeable.
You can still use the previous version of the PR as an external component. It's a little harder to configure since you have to point to https://github.com/esphome/esphome/commit/d5bdf2575c151abfad39b6c24c3856395a7d0901 instead of the PR shorthand version.
Or you can wait for the next esphome release, where https://github.com/esphome/esphome/commit/302ba2874e12960c76a624fa6066bf5df1ffac2e will be included at least. The the PR shorthand should work again. Until I have to fix some otther conflict with new code in the ethernet component...
When will your changes be merged?
You tell me. I have no idea
You can still use the previous version of the PR as an external component. It's a little harder to configure since you have to point to d5bdf25 instead of the PR shorthand version.
How do it?
What would be the address of the source component?
What would be the address of the source component?
Something like
external_components:
- source:
type: git
url: https://github.com/esphome/esphome
ref: d5bdf2575c151abfad39b6c24c3856395a7d0901
components:
- ethernet
Any one can help i am using the board eth01-evo with poe . i am finding it hard to find how to configure the ethernet port to be able to connect over my wired network. i am using Aruduino IDE as a compiler, anyone have an example please to follow to make this work ? Thanks
Any one can help i am using the board eth01-evo with poe . i am finding it hard to find how to configure the ethernet port to be able to connect over my wired network. i am using Aruduino IDE as a compiler, anyone have an example please to follow to make this work ? Thanks
works for me:
esphome:
name: eth01-evo
friendly_name: eth01-evo
esp32:
board: esp32-c3-devkitm-1
# currently needed, but not in the future
variant: esp32c3
framework:
type: esp-idf
version: latest
platform_version: 6.5.0
external_components:
- source: github://pr#6861
components:
- ethernet
ethernet:
# https://github.com/esphome/esphome/pull/6861
type: DM9051
clk_pin: GPIO07
mosi_pin: GPIO10
miso_pin: GPIO03
cs_pin: GPIO09
interrupt_pin: GPIO08
reset_pin: GPIO06
clock_speed: 20MHz
Any one can help i am using the board eth01-evo with poe . i am finding it hard to find how to configure the ethernet port to be able to connect over my wired network. i am using Aruduino IDE as a compiler, anyone have an example please to follow to make this work ? Thanks
works for me:
esphome: name: eth01-evo friendly_name: eth01-evo esp32: board: esp32-c3-devkitm-1 # currently needed, but not in the future variant: esp32c3 framework: type: esp-idf version: latest platform_version: 6.5.0 external_components: - source: github://pr#6861 components: - ethernet ethernet: # https://github.com/esphome/esphome/pull/6861 type: DM9051 clk_pin: GPIO07 mosi_pin: GPIO10 miso_pin: GPIO03 cs_pin: GPIO09 interrupt_pin: GPIO08 reset_pin: GPIO06 clock_speed: 20MHz
Thanks for your reply, however I am note using esp home as I have a simple project to get temperature and humidity reading and sending the data via SNMP oid so the data can be read by a software PRTG. i went for this board because of the POE capabilities. I have another board with ESP32 Wroom and the ethernet configuration is working fine (but no poe capabilities) so the board ETH01-EVO POE with esp32-C3 is giving me a challenge which libraries should work or not maybe anyone had the same issue ?
Sorry for reopening the topic but why if I update from 2024.11.3 to 2024.12.2 do the ESP32 ETH01-EVO POE stop working?
Can confirm - this works with 2024.12.2:
esp32:
board: esp32-c3-devkitm-1
# currently needed, but not in the future
variant: esp32c3
framework:
type: esp-idf
version: latest
# platform_version: 6.5.0
external_components:
- source: github://pr#6861
components:
- ethernet
ethernet:
# https://github.com/esphome/esphome/pull/6861
type: DM9051
clk_pin: GPIO07
mosi_pin: GPIO10
miso_pin: GPIO03
cs_pin: GPIO09
interrupt_pin: GPIO08
reset_pin: GPIO06
clock_speed: 8MHz
Hello.
I've received this error when try to update the esp module:
substitutions:
settings_skipped_updates: "30"
devicename: "baxi_esp"
esphome:
name: $devicename
esp32:
board: esp32-c3-devkitm-1
variant: esp32c3
framework:
type: esp-idf
version: latest
platform_version: 6.5.0
external_components:
- source:
type: git
url: https://github.com/esphome/esphome
ref: d5bdf2575c151abfad39b6c24c3856395a7d0901
components:
- ethernet
I have commented version line and that's all.
# platform_version: 6.5.0
Thank you very much!!
Hello, is there any news on the release of the support for those WT32-ETH01 like devices? Many thanks!
Would love to see this merged in. I can confirm that https://github.com/esphome/esphome/pull/6861#issuecomment-2571396522 works well.
However, I can't get device to connect to network over ethernet when bluetooth_proxy is enabled.
Update from my side: tested with a WT32-ETH01-EVO-PoE, works like a charm. Here's the code that somebody else already mentioned.
esphome:
name: eth01-evo
friendly_name: eth01-evo
esp32:
board: esp32-c3-devkitm-1
variant: esp32c3
framework:
type: esp-idf
version: latest
external_components:
- source: github://pr#6861
components:
- ethernet
ethernet:
# https://github.com/esphome/esphome/pull/6861
type: DM9051
clk_pin: GPIO07
mosi_pin: GPIO10
miso_pin: GPIO03
cs_pin: GPIO09
interrupt_pin: GPIO08
reset_pin: GPIO06
clock_speed: 8MHz
logger:
api:
ota:
platform: esphome
I'll try to update and I can´t, any idea?
I think is something with the static IP.
Sorry for asking but I don't know how to fix it :)
Same issue as @Imanol82 while trying to update to 2025.2.0. It worked perfectly fine before.
AttributeError: module 'esphome.config_validation' has no attribute 'ipv4'
Failed config
I assume something changed with the new version and this PR needs to be updated.
I do not have a static IP configured but still get the same error:
esphome:
name: wt32-xyz
esp32:
board: esp32-c3-devkitm-1
variant: esp32c3
framework:
type: esp-idf
version: latest
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: yyyyyy
ota:
password: xxxxx
platform: esphome
#wifi:
# ssid: !secret wifi_ssid
# password: !secret wifi_password
external_components:
- source: github://pr#6861
components:
- ethernet
ethernet:
# https://github.com/esphome/esphome/pull/6861
type: DM9051
clk_pin: GPIO07
mosi_pin: GPIO10
miso_pin: GPIO03
cs_pin: GPIO09
interrupt_pin: GPIO08
reset_pin: GPIO06
clock_speed: 8MHz
There was a change https://github.com/esphome/esphome/pull/8072 and since the whole ethernet component is pulled from the downloaded external component and it has been not updated, so it is not compatible with the current version. I guess cleaning build files OR refreshing component by adding refresh: 0s should help.
I rebased onto the current "dev" branch. Completely untested since I've pretty much given up on this PR.. But maybe it works?
I rebased onto the current "dev" branch. Completely untested since I've pretty much given up on this PR.. But maybe it works?
You're my hero :). It works perfectly fine first try. Thank you so much. I hope this will get merged in the future.
Update: I may have been too fast with my feedback. It compiles nicely and upload seems to work too. But after the reboot it still shows the old ESPHome version (2024.12.4) in the log output. Not sure if this is related to this PR. Will have to investigate further.
Update 2: My issue is not related to this PR. It seems it happened because I switched from Arduino framework to esp-idf.
Update 3 (last one): Serial reflashing did solve the issue and this PR is working perfectly fine.
@bmork Thanks for the rebase! I had bought a couple of these boards about 14 months ago, only to find that ethernet is not supported for ESP Home. This change helped me finally make use of these boards. I say this only to encourage you and hopefully you have get these changes merged in soon. :)