daniel-p-carvalho opened a new pull request, #20213: URL: https://github.com/apache/nuttx/pull/20213
> **Depends on apache/nuttx#20148 and on apache/nuttx#20212. Please do not merge this PR before them.** > > The first five commits below are those of #20211, #20212 and the first commit of #20148, and are reviewed there. Until they are merged they show up in this diff; only the last commit is new here. This PR stays a draft until then, and I will rebase it onto `master` so that it is reduced to that commit. ## Summary The STM32H7 MAC can capture a timestamp for every transmitted frame, but the driver only timestamped received frames (#20212). A PTP daemon using the peer-to-peer delay mechanism needs the transmit time of its `Pdelay_Req` from the hardware. This PR adds `STM32_ETH_TIMESTAMP_TX` for the STM32H7, the option that #20148 defines for the legacy STM32 driver, delivered through the generic `SO_TIMESTAMPING` mechanism of the network stack (#20161): when a frame is flagged for timestamping, the driver keeps a copy of it, sets the timestamp enable bit in its descriptor and, when the transmission is done, reads the timestamp from the descriptor and loops the copy back to the `AF_PACKET` socket, where `recvmsg(..., MSG_ERRQUEUE)` returns it. The MAC writes the timestamp over the address of the buffer in the descriptor, so the driver keeps the buffer of these descriptors. ## Impact - Everything new is under `STM32_ETH_TIMESTAMP_TX` (default n, needs `STM32_ETH_PTP` and `NET_TIMESTAMP`), so boards that do not enable it are not affected. - The timestamps are raw values of the counter of the MAC, as for reception, so the consumer has to use `/dev/ptp0` as its clock. - The `apps` side, `ptpd` reading the transmit timestamp from the error queue, is apache/nuttx-apps#3791, which builds on apache/nuttx-apps#3782. ## Testing Built with `STM32_ETH_TIMESTAMP_TX` with and without `STM32_ETH_TIMESTAMP_RX`, without errors or warnings. `./tools/checkpatch.sh -g upstream/master..HEAD` passes. On hardware, with a custom STM32H753 board and a DP83848 PHY, against a GNSS-referenced `ptp4l` grandmaster using the IEC/IEEE 61850-9-3 profile, over `AF_PACKET`, with `ptpd -2 -s -H -p /dev/ptp0 -B -P -i eth0` from apache/nuttx-apps#3782 and the transmit timestamps of apache/nuttx-apps#3791: - The peer delay was 9.0 to 9.4 us in every measurement, the same as the STM32F4 driver of #20148 against the same grandmaster (9.27 us). - The clock followed the grandmaster: phase differences of tens to hundreds of nanoseconds and a drift of 18 ppm, corrected through `/dev/ptp0`. - The PPS outputs of the STM32H7 and of the STM32F4 board, measured on an oscilloscope against the same grandmaster, differed by about 20 us, consistently. The end-to-end mechanism, master mode and a long run were not tested. -- 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]
