docwilco/w6100
W6100 ESP-IDF component driver for ESP32: MACRAW Ethernet frames into esp_eth/esp_netif, with IRQ/poll RX task, stable 16-bit reads, and PHY link handling.
Cover image generated by Gemini.
W6100 ESP-IDF Component Driver – Key Characteristics
When using the WIZnet W6100 with an ESP32, this project organizes the driver in a way that fits the ESP-IDF standard Ethernet flow (esp_eth / esp_netif). ESP-IDF provides a consistent model for Ethernet drivers (including external SPI-Ethernet modules) and a standard path to attach them to the TCP/IP stack through esp_netif/lwIP.
Repository:
1) Design direction visible in the project structure
(1) MAC/PHY separation aligned with ESP-IDF Ethernet framework (esp_eth)
The project follows ESP-IDF’s expected split between a MAC driver (esp_eth_mac_t) and a PHY driver (esp_eth_phy_t). With this structure, Ethernet can be integrated into an application using the same standard patterns as other ESP-IDF network interfaces.
(2) Receive path organized around MACRAW (frame-level processing)
In w6100_mac.c, the default setup configures SOCK0 in MACRAW mode and delivers received Ethernet frames upward. This approach matches well with using the ESP-IDF networking stack (esp_netif/lwIP) on the ESP32 side.
(3) Both interrupt-driven and polling-driven operation are considered
Some boards cannot easily use an INT pin. The project supports both interrupt mode and polling mode (via esp_timer), while keeping the actual frame processing consolidated in a dedicated RX task.
2) A convenience initialization API (w6100_init.c, w6100.h)
w6100_init() performs SPI bus initialization → MAC/PHY creation → Ethernet driver install in one place. It also validates configuration values, which helps reduce common integration mistakes.
- Required GPIO checks and ISR service setup
- SPI bus configuration + MAC/PHY creation + driver install
- Optional MAC address configuration
In ESP-IDF, attaching the Ethernet driver to the TCP/IP stack is a separate step and is typically done using
esp_netifglue in the standard Ethernet examples.
3) MACRAW default configuration is explicit (w6100_mac.c)
The default setup makes the following decisions clear:
- Only SOCK0 is used for MACRAW
- TX/RX buffers (16KB each) are assigned to SOCK0
- Only the RECV interrupt is enabled for SOCK0
- Interrupt re-assert level is set to maximum (to reduce the chance of missing an interrupt)
- Global interrupts are enabled
4) RX processing: ISR/polling → RX task → stack_input() (w6100_mac.c)
(1) Interrupt mode: notify RX task from ISR
(2) Polling mode: notify RX task from esp_timer
(3) RX task: handle RECV event and pass frames to the upper stack
Core flow:
- Check
SIR_RECVon SOCK0 - Clear interrupt using IRCLR
- Allocate receive buffer → call
receive()to read the frame - Deliver to upper layers using
stack_input()
ESP-IDF Ethernet drivers typically deliver frames upward through
stack_input()as part of the standard Ethernet-to-TCP/IP stack integration path.
5) Stabilized reads for 16-bit size registers (w6100_mac.c)
RX/TX size registers can change while being read, producing inconsistent high/low bytes. The driver avoids this by reading twice until the values match.
6) PHY handling note: inverted bit semantics vs. W5500 (w6100_phy.c)
w6100_phy.c clearly documents PHY status bit semantics, including a common pitfall: Speed/Duplex bits are inverted compared to W5500.
Link changes and speed/duplex updates are also propagated upward via the ESP-IDF driver state mechanism (on_state_changed()).
7) When this project is useful
This project is best viewed as a driver/reference for integration rather than a “demo application”. It is particularly useful if you want to:
- Integrate W6100 as a standard ESP-IDF Ethernet interface on ESP32
- Keep RX processing organized around an RX task while supporting both interrupt and polling environments
- Handle PHY link state (speed/duplex included) at the driver level for robust operation
8) Minimal usage example (integration-level)
Below is a minimal example showing how w6100_init() can be called. Pin numbers and SPI host should be adjusted for your board.
ESP-IDF’s standard Ethernet examples show the complete sequence: driver install → esp_netif attach → DHCP.
Summary
In short, this project provides a structured way to integrate W6100 with ESP32 in an ESP-IDF-friendly form. From the code itself, the following are notable implementation points:
w6100_init()consolidates SPI/MAC/PHY/driver install into a single entry point- Clear MACRAW-centric default configuration (buffer allocation, interrupts, interrupt re-assert level)
- RX processing converges on an RX task, while supporting both interrupt and polling wake-up methods
- Stabilized double-read for 16-bit size registers
- Explicit PHY status semantics (inverted vs. W5500) and link-state prop


