feat(esp32): add support for Native ESP32 Ethernet and WT32-ETH01 variant#9586
feat(esp32): add support for Native ESP32 Ethernet and WT32-ETH01 variant#9586balya wants to merge 2 commits into
Conversation
|
|
@balya, Welcome to Meshtastic!Thanks for opening your first pull request. We really appreciate it. We discuss work as a team in discord, please join us in the #firmware channel. Welcome to the team 😄 |
There was a problem hiding this comment.
Pull request overview
Adds native ESP32 Ethernet (internal MAC/PHY such as LAN8720) support and introduces a WT32-ETH01-E22 board variant, while refactoring networking code to abstract Ethernet client/server types and enable TLS for MQTT over native Ethernet.
Changes:
- Added
MeshEthernetClient/MeshEthernetServertypedef abstraction for Ethernet API server support (native ESP32 ETH + existing SPI Ethernet). - Updated MQTT client selection logic to allow TLS (via
WiFiClientSecure) on native ESP32 Ethernet. - Added new
wt32-eth01-e22ESP32 variant (pins + PlatformIO environment), plus assorted build/config housekeeping (.trunk, .gitignore).
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| variants/esp32/wt32-eth01-e22/variant.h | New WT32-ETH01-E22 pin + feature definitions (LAN8720 + SX1262). |
| variants/esp32/wt32-eth01-e22/platformio.ini | New PlatformIO environment for the WT32-ETH01-E22 build. |
| src/mqtt/MQTT.h | Extends MQTT transport type selection to support native ETH + TLS via WiFiClientSecure. |
| src/modules/AdminModule.cpp | Reports Ethernet link/IP for native ESP32 ETH (and other ETH paths). |
| src/mesh/wifi/WiFiAPClient.h | Adds ETH include handling for native ESP32 ETH and broadens initEthernet declaration. |
| src/mesh/wifi/WiFiAPClient.cpp | Adds native ESP32 Ethernet init path and event handling. |
| src/mesh/eth/ethClient.cpp | Adjusts API server init call to match updated signature. |
| src/mesh/api/ethServerAPI.h | Introduces MeshEthernetClient/Server typedefs and adapts eth server API templates. |
| src/mesh/api/ethServerAPI.cpp | Updates implementation for the new eth server API typing and initApiServer handling. |
| src/mesh/InterfacesTemplates.cpp | Updates template instantiations to use MeshEthernet* abstractions. |
| src/main.cpp | Adjusts include logic for ethernet components (native ETH vs RAK/W5100S paths). |
| src/DebugConfiguration.h | Updates ETH include selection to support native ESP32 ETH alongside existing ETH modes. |
| .trunk/trunk.yaml | Updates/extends trunk toolchain versions and enabled runtimes/linters. |
| .gitignore | Adds .history and expands macOS ignore patterns. |
| #include "ethServerAPI.h" | ||
| #include "configuration.h" |
There was a problem hiding this comment.
ethServerAPI.cpp now includes ethServerAPI.h before configuration.h. Because ethServerAPI.h is wrapped in #if HAS_ETHERNET, targets that define HAS_ETHERNET only via configuration/variant headers will see an empty header here, and then this .cpp later compiles the #if HAS_ETHERNET block (after including configuration.h) and references types that were never declared. Fix by including configuration.h before ethServerAPI.h (or make ethServerAPI.h independent of include order).
| #include "ethServerAPI.h" | |
| #include "configuration.h" | |
| #include "configuration.h" | |
| #include "ethServerAPI.h" |
| #if HAS_WIFI || (defined(ESP32) && defined(ETH_PHY_TYPE)) | ||
| #include <WiFiClient.h> | ||
| #if __has_include(<WiFiClientSecure.h>) | ||
| #include <WiFiClientSecure.h> | ||
| #endif | ||
| #endif | ||
| #if HAS_ETHERNET && !defined(USE_WS5500) | ||
|
|
||
| #if HAS_ETHERNET && !defined(ETH_PHY_TYPE) && !defined(USE_WS5500) | ||
| #include <EthernetClient.h> | ||
| #endif | ||
|
|
There was a problem hiding this comment.
MQTT.h’s client-type selection can break for USE_WS5500 builds when HAS_WIFI is 0 (e.g., MESHTASTIC_EXCLUDE_WIFI=1). In that configuration the code falls into the #elif HAS_ETHERNET branch and aliases MQTTClient to EthernetClient, but EthernetClient.h is not included when USE_WS5500 is defined (and W5500 uses the WiFiClient-based stack). Consider treating USE_WS5500 like native ESP32 ETH here (include/typedef WiFiClient + optional WiFiClientSecure) or otherwise ensure the selected client type is declared via includes for all macro combinations.
caveman99
left a comment
There was a problem hiding this comment.
Lemme wae through this... hold your beer.
|
Uh.. Sorry for asking. When will the WT32-ETH or at least LAN8720 support be includet? |
|
@MeisterQ Since @balya didn't respond, I think I'll work on his changes, apply the changes from the reviewers and make my pull reqest. If you need to run it now, under my fork: https://github.com/slomkowski/meshtastic-firmware/tree/develop WT32-ETH01 works OK. Feel free to test it and provide feedback. I'll answer your questions. |
Thank you. I will give it a try. Can you give me some hints where to define all this pins etc? Im not pretty familiar with it. I had the original source code in my platformio and could compile it. Will it use an internal or external clock? My custom board uses the internal clock and no PHY PWR. I just made myself an PoE powered Ethernet Board with LAN8720 and RA-01SH SX1267 based chip. Hopefully this all will work |
|
@MeisterQ I think you'll find all pinout information in the file I'm not familiar with the intricacies of Ethernet configuration for ESP32, but in the code, the config is in Pinout for SX1262 which is proven to work is also in You'll probably need to make your own PlatformIO variant and define your pinout in your own |
Im currently testing it. I could have upload your fork already, but i was choosing the wrong variant, because im not very familiar with PlatformIO. I hope i will get it running. Sometimes im occuring errors like "PlattformIO: Upload is not known" and so on.. Thats really weird. I will keep you updated if i get it running. |
It seems like its always crashing after trying to start the webserver. |
|
On my WT32-ETH01 board, I initially didn't have this error. But after uploading custom OTA uploader to OTA partition, it started to happen. I haven't managed to trace the cause of it, I thought it was something on my side. To mitigate it, I commented out |
Thank you. This fixed my problem aswell. Its now running on my own designed PoE Board. Thank you very much! Will you think about pulling this into the main project after fixing the webserver issue? |
Yes, I'm applying the fixes from the reviews. If I fix the webserver issue, I may send a pull request. |
Thank you very much for your help! |
Did you have MQTT running on your Ethernet Board? |
|
Yes. If it sill breaks, put the logs under #9891. I didn't look closer at the MQTT, I was under the impression it worked. |
|
I finally managed to clean this up, and it seems to be working okay now. The main issue was with the event loop, so I moved the registration to the very beginning of the Ethernet initialization. I also updated the WiFiEvent signature for newer cores and added a heap check before generating the SSL certificate. Without PSRAM, it was just crashing as soon as the webserver tried to start, but now it stays stable. I've tested it on my hardware — Ethernet is working, the API is up on port 4403, and the app connects without any issues. Just a heads up: I wouldn't really recommend using this specific board for Meshtastic. The memory is extremely tight, and you basically have to disable almost all extra modules just to keep it from running out of heap. |
|
Hi @caveman99 @robekl @thebentern Sorry to bother you directly. I understand that everyone is busy and that maintaining the project takes a lot of time. I just want to make sure I did not miss anything on my side. Maybe the PR is missing some required changes, was submitted in the wrong way, or there are concerns with the implementation. Could you please let me know what needs to be fixed or improved for this PR to be considered for merging? |
|
Whats going on here now? Is is already merged into the original project? |

Description
This PR introduces support for Native ESP32 Ethernet (using the internal MAC and PHY-interface, e.g., LAN8720) and adds the WT32-ETH01 board variant.
Previously, Ethernet support was tightly coupled with external SPI-based modules (W5500/RAK). This change abstracts the Ethernet client/server types, allowing Meshtastic to run on boards with native Ethernet hardware while maintaining full backward compatibility with existing SPI Ethernet and WiFi-only boards.
Key Changes:
Attestations
Note: I do not have access to all Heltec/LilyGo hardware for regression testing. However, the changes are guarded by ETH_PHY_TYPE and HAS_WIFI macros to ensure zero impact on existing SPI-Ethernet and WiFi-only targets.