# ETH：PHY自协商超时，持续5000毫秒后失败

- **ID:** `embedded/eth-phy-autonegotiation-timeout`
- **领域:** embedded
- **类别:** communication_error
- **错误码:** `ETH_ERR_AUTONEG_TIMEOUT`
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

PHY设备在配置的超时时间内未能完成自协商，原因可能是链路伙伴不兼容或网线故障。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| STM32H7 ETH driver v2.0.1 | active | — | — |
| LWIP v2.1.3 | active | — | — |
| PHY LAN8742A | active | — | — |

## 解决方案

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)`
   ```
2. ```
   Check and replace the Ethernet cable, then reset the PHY: `phy_reset(phy_dev); HAL_Delay(100); phy_autonegotiate(phy_dev);`
   ```

## 无效尝试

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