1

I have trouble syncing to Linux systems using PTP.

Setup:

Two PCBs with a BegleCore module and a DP83640 PHY are connected with each other over Ethernet. One board should act as the PTP master, the other as the slave. Debian 10, Kernel: 4.19.94 Driver for the Phy is loaded. Using linuxptp v3.1

On the master system I run the command:

sudo ptp4l -i eth0 -f linuxptp/configs/configMaster.cfg -m

On the client system I run:

sudo ptp4l -i eth0 -f linuxptp/configs/configslave.cfg -m

Content of configMaster.cfg:

[global]
serverOnly       1
BMCA             noop

Content of configSlave.cfg:

[global]
clientOnly      1
BMCA            noop
step_threshold  1

This results in the following output on the slave:

ptp4l[438753.396]: selected /dev/ptp0 as PTP clock
ptp4l[438753.409]: port 1 (eth0): INITIALIZING to SLAVE on INIT_COMPLETE
ptp4l[438753.414]: port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[438753.418]: port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[438754.075]: port 1 (eth0): new foreign master 304511.fffe.0ff048-1                                                                                       
ptp4l[438758.074]: selected best master clock 304511.fffe.0ff048
ptp4l[438762.072]: master offset 2426120726467 s0 freq -261066 path delay     15040
ptp4l[438762.074]: selected best master clock 304511.fffe.0ff048
ptp4l[438765.074]: master offset 2426120697575 s1 freq -270698 path delay     15156
ptp4l[438767.072]: master offset 2426120678191 s0 freq -270698 path delay     15156
ptp4l[438768.075]: master offset 2426120668273 s1 freq -280618 path delay     15830
ptp4l[438769.072]: master offset 2426120658469 s0 freq -280618 path delay     15830
ptp4l[438770.073]: master offset 2426120648789 s0 freq -280618 path delay     16022
ptp4l[438771.076]: master offset 2426120639057 s1 freq -290350 path delay     16022
...

The reported offset is approximatly 40 min. Before running ptp4l I had set the PTP clocks in the PHYs with testptp -s to the current system time. The PTP clocks were therefore actually within a few seconds of each other.

Each time ptp4l reports a "master offset s1 ..." it does step the PTP clock back by 40 min (checked with testptp -g). Yet the reported offset only changes by about 10 us.

I also looked into the network traffic with Wireshark and saw, that the Follow-Up messages from the master contain a timestamp that is by about 69 min of what the PTP clock in the PHY is set to. After adding debug outputs to ptp4l I saw, that on the slave, the timestamp it extrats from the cmsgs returned from the socket is offset by about -27 min from what the client PTP clock actually is.

The difference from the false timestamps (+69 min) send by the master and the falsely read timestamps (-27 min) by the client results in the 40 min of assumed offset between the master clock and the client clock.

11011100
  • 11
  • 3

1 Answers1

0

I solved the problem with: Disabling the CPTS support in the kernel options and to modify the file cpsw.c the following way:

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index fc8e3ed383a2..d4d70706e86c 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2490,15 +2490,22 @@ static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
struct cpsw_priv *priv = netdev_priv(dev);
struct cpsw_common *cpsw = priv->cpsw;
int slave_no = cpsw_slave_index(cpsw, priv);
+ int err = 0;

if (!netif_running(dev))
return -EINVAL;

switch (cmd) {
case SIOCSHWTSTAMP:
- return cpsw_hwtstamp_set(dev, req);
+ err = cpsw_hwtstamp_set(dev, req);
+ if(err != -EOPNOTSUPP)
+ return err;
+ break;
case SIOCGHWTSTAMP:
- return cpsw_hwtstamp_get(dev, req);
+ err = cpsw_hwtstamp_get(dev, req);
+ if(err != -EOPNOTSUPP)
+ return err;
+ break;
case SIOCSWITCHCONFIG:
return cpsw_switch_config_ioctl(dev, req, cmd);
}
11011100
  • 11
  • 3