Skip to content

Fix Ethernet - #460

Merged
stintel merged 8 commits into
mainfrom
fix/ethernet
Jul 23, 2026
Merged

Fix Ethernet#460
stintel merged 8 commits into
mainfrom
fix/ethernet

Conversation

@stintel

@stintel stintel commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Tested on ESP32-S3-Box-3 with MIKROE ETH WIZ Click (W5500).

stintel added 8 commits July 23, 2026 09:05
Add esp_eth as an unconditional private component requirement so
ESP-IDF loads its Kconfig before evaluating Willow's Ethernet
option. Without it, ETH_SPI_ETHERNET_W5500 is undefined and
CONFIG_WILLOW_ETHERNET cannot be enabled.

ESP-IDF expands component dependencies before loading configuration.
The esp_eth component remains configuration-only when
CONFIG_ETH_ENABLED is disabled, so Wi-Fi builds do not compile the
Ethernet driver.
init_system() creates the default ESP-IDF event loop before network
initialization. Creating it again in init_ethernet() returns
ESP_ERR_INVALID_STATE and makes ESP_ERROR_CHECK abort Ethernet startup.

Reuse the system-owned event loop, matching the Wi-Fi path and keeping
Ethernet initialization focused on its driver and event handlers.
Always declare hdl_nvs regardless of Ethernet or Wi-Fi, as we need it to
read the WAS URL if we use Ethernet.

Fixes the following error when CONFIG_WILLOW_ETHERNET is enabled:

/willow/main/main.c: In function 'app_main':
/willow/main/main.c:125:42: error: 'hdl_nvs' undeclared (first use in this function)
  125 |     err = nvs_open("WAS", NVS_READONLY, &hdl_nvs);
      |                                          ^~~~~~~
Similar to the previous commit, we need to always declare the sz
variable, as we need it to get the WAS URL from NVS.
ESP-IDF changed ETH_W5500_DEFAULT_CONFIG() to accept the SPI host
and device configuration. The W5500 driver now allocates the SPI
device internally.

Stop creating the SPI device explicitly and pass the host and device
configuration directly to the W5500 configuration macro. This fixes
the Ethernet build with the current ESP-IDF version.
The W5500 has no burned factory MAC address, so assigning a fixed test
address makes every Willow Ethernet interface collide on the same LAN.

Read ESP_MAC_ETH from ESP-IDF and assign that derived address to the
W5500 driver. Remove the unused fake address left in network.c.
Pass the concrete esp-netif handle to the shared hostname helper instead
of selecting the first registered interface. This preserves Wi-Fi
behavior and lets Ethernet set its MAC-derived hostname before DHCP
starts.

Store the Ethernet interface in hdl_netif so the remaining WAS code can
read the configured hostname.
The Ethernet path skipped the shared SNTP lifecycle, so it neither
applied the configured timezone nor synchronized the system clock.

Expose the helpers and initialize SNTP before bringing up the W5500
interface. Start it after the existing connection wait. The shared
configuration already selects the Ethernet IP event.
@stintel
stintel merged commit 489e8de into main Jul 23, 2026
9 checks passed
@stintel
stintel deleted the fix/ethernet branch July 23, 2026 10:21
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.

1 participant