# ETH: PHY autonegotiation timeout after 5000ms

- **ID:** `embedded/eth-phy-autonegotiation-timeout`
- **Domain:** embedded
- **Category:** communication_error
- **Error Code:** `ETH_ERR_AUTONEG_TIMEOUT`
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

PHY device failed to complete autonegotiation within the configured timeout due to incompatible link partner or faulty cable.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| STM32H7 ETH driver v2.0.1 | active | — | — |
| LWIP v2.1.3 | active | — | — |
| PHY LAN8742A | active | — | — |

## Workarounds

1. **Force the PHY to a specific speed/duplex (e.g., 100Mbps Full Duplex) using: `phy_write(PHY_CTRL_REG, MII_CR_SPEED_100 | MII_CR_FULL_DUPLEX | MII_CR_RESTART_AUTONEG)`** (80% success)
   ```
   Force the PHY to a specific speed/duplex (e.g., 100Mbps Full Duplex) using: `phy_write(PHY_CTRL_REG, MII_CR_SPEED_100 | MII_CR_FULL_DUPLEX | MII_CR_RESTART_AUTONEG)`
   ```
2. **Check and replace the Ethernet cable, then reset the PHY: `phy_reset(phy_dev); HAL_Delay(100); phy_autonegotiate(phy_dev);`** (70% success)
   ```
   Check and replace the Ethernet cable, then reset the PHY: `phy_reset(phy_dev); HAL_Delay(100); phy_autonegotiate(phy_dev);`
   ```

## Dead Ends

- **** — If the root cause is link partner incompatibility or cable fault, increasing timeout only delays the failure; autonegotiation will still fail. (60% fail)
- **** — Looping without fixing the underlying issue can cause an infinite retry loop, blocking other tasks and consuming CPU cycles. (90% fail)
