daniel-p-carvalho opened a new pull request, #20209: URL: https://github.com/apache/nuttx/pull/20209
## Summary The STM32H7 Ethernet driver waits for the PHY to bring the link up, and then for auto-negotiation to complete, in two loops of `PHY_RETRY_TIMEOUT` iterations (`0x1998`), each one sleeping with `nxsched_usleep(100)`. The time that the PHY gets therefore depends on the period of the system tick: the sleep lasts at least one tick. - With the usual 10 ms tick, the wait is about 65 s, long enough for any PHY. - With `CONFIG_SCHED_TICKLESS` the tick is 100 us (`CONFIG_USEC_PER_TICK` defaults to it), so the wait is about 0.65 s. That is shorter than the auto-negotiation of the PHY on the board that I use (a DP83848 over RMII, which needed about 1.7 s to bring the link up after a reset), and `ifup` fails with `Timed out waiting for link status` even though the link comes up a moment later. This PR makes the wait independent of the tick. The PHY is polled every 10 ms (`PHY_POLL_MS`) and gets up to 5 s (`PHY_LINK_TIMEOUT_MS`), both for the link and for auto-negotiation to complete, and `PHY_RETRY_TIMEOUT` is derived from them. ## Impact Only `arch/arm/src/stm32h7/stm32_ethernet.c` changes, and only in how long the driver waits for the PHY. - Boards that use the usual tick (the STM32H7 boards in the tree with Ethernet that I checked do not use tickless) wait for up to 5 s instead of up to about 65 s in the worst case, when there is no link. When the link comes up, the interface is ready as soon as it does, as before. - Boards that use `CONFIG_SCHED_TICKLESS` can now bring the interface up when the PHY needs more than about 0.65 s. ## Testing On a custom board with an STM32H743, a DP83848 PHY over RMII and `CONFIG_SCHED_TICKLESS=y` with a 100 us tick, against a Fast Ethernet switch: - Before the change, `ifup eth0` failed on every boot with `Timed out waiting for link status`, while the PHY registers read over MDIO showed the link up and auto-negotiation complete a moment later. I measured about 1.7 s from a PHY reset to the link being up. - After the change, the link comes up (`link full-duplex 100 Mbps`), `eth0` is `RUNNING` and `ping` to a host on the switch and to another board has no loss. The interface came up correctly in 6 out of 6 consecutive resets of the board. The default tick (10 ms) was not run on hardware. `./tools/checkpatch.sh` passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
