Skip to content

[eth, eth_phy, stm32h5_eth, lan8742a] Implement ethernet and phy abstraction. Add eth and phy driver#21

Merged
AlexLanzano merged 1 commit intowolfSSL:mainfrom
AlexLanzano:eth
Mar 31, 2026
Merged

[eth, eth_phy, stm32h5_eth, lan8742a] Implement ethernet and phy abstraction. Add eth and phy driver#21
AlexLanzano merged 1 commit intowolfSSL:mainfrom
AlexLanzano:eth

Conversation

@AlexLanzano
Copy link
Copy Markdown
Member

No description provided.

@AlexLanzano AlexLanzano self-assigned this Mar 30, 2026
Copilot AI review requested due to automatic review settings March 30, 2026 16:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and whal_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 eth tests 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.

Comment on lines +51 to +60
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)
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@AlexLanzano AlexLanzano merged commit ca2a01c into wolfSSL:main Mar 31, 2026
10 checks passed
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.

2 participants