[eth, eth_phy, stm32h5_eth, lan8742a] Implement ethernet and phy abstraction. Add eth and phy driver#21
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a generic Ethernet MAC + PHY abstraction to wolfHAL, along with an STM32H5 Ethernet MAC driver and a LAN8742A PHY driver, wiring them into the STM32H563ZI Nucleo board config and HW tests.
Changes:
- Introduce
whal_Eth(MAC) andwhal_EthPhy(PHY) driver interfaces plus dispatch wrappers. - Add STM32H5 Ethernet MAC (DWC) driver + LAN8742A PHY driver, and integrate them into
stm32h563zi_nucleo. - Add generic MDIO/PHY tests and an STM32H5 loopback test; enable
ethtests for the STM32H563ZI Nucleo target.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfHAL/wolfHAL.h | Exposes Ethernet MAC/PHY headers via the umbrella include. |
| wolfHAL/platform/st/stm32h563xx.h | Adds STM32H563 ETH device + clock gate macros (and SBS clock). |
| wolfHAL/eth/eth.h | Defines the generic Ethernet MAC API/vtable and direct-callback macros. |
| wolfHAL/eth/stm32h5_eth.h | Declares STM32H5 Ethernet MAC config, descriptors, and driver API. |
| wolfHAL/eth_phy/eth_phy.h | Defines the generic Ethernet PHY API/vtable and dispatch macros. |
| wolfHAL/eth_phy/lan8742a.h | Declares LAN8742A PHY driver API and config. |
| src/eth/eth.c | Implements generic MAC dispatch wrappers. |
| src/eth/stm32h5_eth.c | Implements STM32H5 Ethernet MAC + DMA/MDIO handling. |
| src/eth_phy/eth_phy.c | Implements generic PHY dispatch wrappers. |
| src/eth_phy/lan8742a.c | Implements LAN8742A PHY init/deinit/link-state via MDIO. |
| boards/stm32h563zi_nucleo/board.h | Adds Ethernet device/PHY externs, RMII pins, and PHY ID constants. |
| boards/stm32h563zi_nucleo/board.c | Configures RMII pins, clocks, SBS RMII mode, and initializes MAC/PHY. |
| boards/stm32h563zi_nucleo/Makefile.inc | Enables eth tests and adds ETH/PHY sources to the board build. |
| tests/main.c | Adds ETH test suite hooks behind WHAL_TEST_ENABLE_ETH. |
| tests/eth/test_eth.c | Adds generic MDIO PHY-ID read + PHY link-state test. |
| tests/eth/test_stm32h5_eth.c | Adds STM32H5 MAC-internal loopback send/recv test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return err; | ||
| } while (val & PHY_BCR_RESET); | ||
|
|
||
| /* Enable autonegotiation */ | ||
| err = whal_Eth_MdioRead(phyDev->eth, phyDev->addr, PHY_BCR, &val); | ||
| if (err) | ||
| return err; | ||
| val |= PHY_BCR_ANEN; | ||
| err = whal_Eth_MdioWrite(phyDev->eth, phyDev->addr, PHY_BCR, val); | ||
| if (err) |
There was a problem hiding this comment.
whal_Lan8742a_Init() currently only resets the PHY and sets the AN enable bit, then returns success. This doesn’t fulfill the eth_phy.h / lan8742a.h contract that Init waits for link/autonegotiation (and returns WHAL_ETIMEOUT if link doesn’t come up). Either implement autonegotiation restart + polling for ANEG_COMPLETE/link with the provided timeout, or update the API/docs to match the actual behavior.
…raction. Add eth and phy driver
No description provided.