Hi everyone,
I am trying to use the NanoPi R5C as a PTP device as its NIC Realtek RTL8125 has PTP support with hardware timestamping but I found a problem.
But first let me put you in context: enabling PTP in the NanoPi R5C is something not intuitive and probably somebody will find this useful.
  1. The driver which allows PTP hardware timestamping is the r8125 driver, a driver that you can install as a simple kernel module. But to enable PTP support you need to modify the Makefile and change the flags:
    ENABLE_PTP_SUPPORT =
    ENABLE_PTP_MASTER_MODE =
    If you want NanoPi as a master, put both to "y", if you want it as a PTP client, just the first one. I made some experiments and the driver can't work as master/client at the same time, so please choose one.
  2. Compile and install the module on the kernel. I would recommend to rebuild the entire kernel and create a personal Debian/Ubuntu img with the driver already installed.
  3. Check the correct version of the driver is running (modinfo), it has a ____-PTP on its name. Try:

    Code: Select all

    $ sudo ethtool -T eth0
    This will show if your ethernet interfaces have hardware timestamping support. If you have HW timestamping you can start to execute ptp4l as a client for example, but you will find something atypical: Path delay is negative.

In PTP the path delay SHOULDN'T BE NEGATIVE. Therefore, I checked the clock from the NIC, I mean: the oscillator (25MHz) that is connected to the Realtek RTL8125 and I tried to get the time from the clock. With phc_ctl you can check the time that is running on a registred clock of the system:

Code: Select all

$ sudo phc_ctl /dev/ptp0 get
The result of this is the Unix time 0. The clock of the RTL8125 registered in the system is not running and the maths that PTP does goes wrong because of this. You can set a time with phc_ctl but immediately after, it will be restarted to 0.

This is something very unusual in PTP and the RTL8125 is quite often used in PTP devices like PC NICs, so I think that is something from the board firmware? Or something from the kernel that I am not doing well? I don't know, I would need some help.
Thank you!