Fix Ethernet - #460
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tested on ESP32-S3-Box-3 with MIKROE ETH WIZ Click (W5500).