Skip to content

Improve W5500 Ethernet configuration and diagnostics - #541

Open
BanjoR wants to merge 2 commits into
DCC-EX:masterfrom
BanjoR:codex/commandstation-ex-commandstation-esp32-ethernet
Open

BanjoR wants to merge 2 commits into
DCC-EX:masterfrom
BanjoR:codex/commandstation-ex-commandstation-esp32-ethernet

Conversation

@BanjoR

@BanjoR BanjoR commented Aug 16, 2026

Copy link
Copy Markdown

Automatic issue closing

Fixes #308
Fixes #313

Issue #375 is broader network/DHCP behavior; this PR does not claim to close that full report.

Summary

Refresh W5100/W5500 Ethernet configuration and diagnostics for wired CommandStation builds:

  • add platform-gated chip-select selection through ETHERNET_CS and ETHERNET_CS_PIN
  • add the ESP32-Ethernet PlatformIO environment with configurable SPI and reset pins
  • add WIZnet hardware, link, DHCP, hostname, and IP diagnostics
  • document wired-network configuration, dependency limitations, and a reproducible W5500 bench procedure

Bounded scope and exclusions

The exact changed-file scope is limited to:

  • EthernetInterface.cpp
  • EthernetInterface.h
  • config.example.h
  • defines.h
  • platformio.ini

This change does not vendor or modify the Arduino Ethernet dependency, add Wi-Fi behavior, change the protocol/API, or include the ESP32 OTA/custom-server work from PR #525. The wired environments set ENABLE_WIFI=false and ENABLE_ETHERNET=true; the existing configuration also rejects simultaneous Wi-Fi and Ethernet. WIFI_SSID and WIFI_PASSWORD are not used for Ethernet.

The official Arduino Ethernet dependency requests DHCP when IP_ADDRESS is omitted but hard-codes its DHCP hostname option. ETHERNET_HOSTNAME is applied to DCC-EX mDNS/native STM32 naming and reported at startup; a custom W5500 DHCP hostname requires a dependency API/library update: https://github.com/arduino-libraries/Ethernet/blob/master/src/Dhcp.cpp

References

Authoritative issues:

Superseded or incomplete PRs:

Validation evidence

Host audit

  • Clean checkout on branch codex/commandstation-ex-commandstation-esp32-ethernet; origin is BanjoR/CommandStation-EX, upstream is DCC-EX/CommandStation-EX, and upstream/master is 0ad3080.
  • PR head is 687a8c2, with upstream/master as its ancestor.
  • Worktree, index, untracked files, and ignored generated outputs were clean after validation; the public PR file list is exactly the five files above.
  • git diff --check upstream/master...HEAD: PASS.
  • Focused static assertions for diagnostics, configurable SPI/CS/reset, Wi-Fi exclusion, PlatformIO environments/flags, DHCP/hostname limitation, and bench documentation: PASS.
  • Repository CI-equivalent generated-config build, python -m platformio run for mega2560: PASS. RAM 19.0% (1560/8192); Flash 38.3% (97226/253952).
  • Focused W5500 Mega build, python -m platformio run -e mega2560-eth: PASS. RAM 27.5% (2251/8192); Flash 42.1% (106848/253952).
  • Embedded Ztest.cpp compiled in both Mega builds. The repository has no standalone host/unit-test target, and no runtime test was executed.
  • PASS - Exact default python -m platformio run in a clean task checkout with an isolated PlatformIO core completed for all five configured environments: mega2560, ESP32, Nucleo-F411RE, Nucleo-F446RE, and Nucleo-F429ZI.
  • PASS - Focused python -m platformio run -e ESP32-Ethernet after the ESP32 Server API compatibility adapter: 22.15 seconds; RAM 27,304/327,680 (8.3%); Flash 497,301/1,310,720 (37.9%).
  • No standalone CMake/C++ compiler or formatter was available outside PlatformIO; git diff --check was the available whitespace/format gate.

GitHub Actions and required checks

  • PR #541 is OPEN and ready for review, based on master at 0ad3080 and head 687a8c2.
  • The upstream PR status-check rollup remains empty because the repository firmware workflow is push-triggered; the successful fork run below is the available exact-head firmware CI evidence.
  • The upstream CI workflow is configured as on: [push], installs PlatformIO, copies config.example.h to config.h, and runs python -m platformio run; it does not declare a pull_request trigger, so no firmware CI check is attached to this cross-repository PR.
  • Exact-head fork CI: PASS - CI run 31995620650 completed successfully for head 687a8c2, including the Compile Command Station (AVR) job.
  • Upstream PR status remains empty because the repository firmware workflow is push-triggered; the fork run above is the available exact-head firmware CI evidence. Ancillary Docs and Label sponsors runs are not used as firmware evidence.

Hardware validation

Hardware validation: Not run—no hardware available

Maintainer bench procedure:

  1. Use a Mega2560 or ESP32 with a W5500 module. Connect power and ground, SPI SCK/MISO/MOSI, the configured CS pin, and the optional ESP32 reset pin according to the module’s electrical requirements; connect the RJ45 to a DHCP-enabled LAN.
  2. Build mega2560-eth or ESP32-Ethernet with a generated config.h. Exercise both the documented default and a non-default CS setting (ETHERNET_CS on Mega or ETHERNET_CS_PIN on ESP32), adjusting the SPI/reset pins when required by the wiring.
  3. Capture startup diagnostics and require W5500 hardware detection, the expected CS/SPI/reset values, link ON, DHCP request/success, hostname reporting, and a non-zero IP address.
  4. Connect a client to IP_PORT (default 2560) and verify a DCC-EX command/reply round trip.
  5. Disconnect and reconnect the Ethernet cable. Require link/DHCP failure diagnostics while disconnected and successful link/IP recovery after reconnection.

@BanjoR
BanjoR marked this pull request as ready for review August 17, 2026 09:37
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 this pull request may close these issues.

Bug Report: ethernet hostname not set [Feature Request]: setting of eth cs

1 participant