This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new f9bf7da2548 arch/arm/src/imxrt: imxrt_enet: keep autonegotiation on
when it times out
f9bf7da2548 is described below
commit f9bf7da2548ddccca47741b25a7dab6f0aeb9138
Author: Alan Carvalho de Assis <[email protected]>
AuthorDate: Thu Nov 5 09:48:40 2026 -0300
arch/arm/src/imxrt: imxrt_enet: keep autonegotiation on when it times out
When the PHY autonegotiation does not complete in imxrt_initphy(),
typically because the Ethernet cable is not connected at boot, the
driver stopped autonegotiation and forced 10Mbps half duplex. On the
ddcnc-ec300 board (LAN8720A) the link then never came up after the
cable was connected: the PHY LEDs stayed off and the NETINIT link
monitor, which waits for the PHY to report the link, never brought
the interface up.
With CONFIG_ARCH_PHY_INTERRUPT the link changes are reported
(SIOCMIINOTIFY) and the interface is brought up again when the link
appears, which configures the MAC for the negotiated link. In that
case leave autonegotiation on, as the TODO comment suggested. Without
it nothing would reconfigure the MAC later, so keep the old 10Mbps
fallback.
Tested on the ddcnc-ec300: boot with the cable disconnected, connect
it later; the link comes up and the board answers ping.
Signed-off-by: Alan Carvalho de Assis <[email protected]>
Assisted-by: Claude Opus 5.5
---
arch/arm/src/imxrt/imxrt_enet.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/arch/arm/src/imxrt/imxrt_enet.c b/arch/arm/src/imxrt/imxrt_enet.c
index 143f415cf3e..225f1f77c2b 100644
--- a/arch/arm/src/imxrt/imxrt_enet.c
+++ b/arch/arm/src/imxrt/imxrt_enet.c
@@ -2874,19 +2874,35 @@ static inline int imxrt_initphy(struct imxrt_driver_s
*priv, bool renogphy)
}
else
{
- /* TODO: Autonegotiation has right now failed. Maybe the Eth
- * cable is not connected. PHY chip have mechanisms to
- * configure link OK. We should leave autconf on, and find a
- * way to re-configure MCU whenever the link is ready.
+ /* Autonegotiation has failed. Maybe the Ethernet cable is
+ * not connected.
+ */
+
+#ifdef CONFIG_ARCH_PHY_INTERRUPT
+ /* Leave autonegotiation on, so the PHY brings the link up
+ * when the cable is connected. The link change is then
+ * reported (SIOCMIINOTIFY) and the interface brought up
+ * again, which configures the MAC for the negotiated link
+ * (e.g. by the NETINIT monitor). Forcing 10Mbps here
+ * can leave the link down for good: a LAN8720A forced to
+ * 10Mbps half duplex was seen to never link with an
+ * autonegotiating partner after the cable was connected.
*/
ninfo("%s: Autonegotiation failed [%d] (is cable plugged-in ?)"
- ", default to 10Mbs mode\n",
+ ", waiting for the link\n",
BOARD_PHY_NAME, retries);
+#else
+ /* Nothing will reconfigure the MAC when the link comes up
+ * later: stop autonegotiation and use 10Mbps.
+ */
- /* Stop auto negotiation */
+ ninfo("%s: Autonegotiation failed [%d] (is cable plugged-in ?)"
+ ", default to 10Mbs mode\n",
+ BOARD_PHY_NAME, retries);
imxrt_writemii(priv, phyaddr, MII_MCR, 0);
+#endif
}
# if defined(CONFIG_ETH0_PHY_MULTI)
}