Time sensitive networking [TSN] on NX

That’s strange. You have one scope probe on TX1 and another in RX1 right? Are the probe grounds connected well and are the scope inputs in DC mode?


got it working on /dev/ttyTHS0

����������~�������������������������������������~8�~8���~8?��~88����������������~������������������������������������������������������������������~8���������p~8����������~8���������������~~88���������������������������������������~8���������������~����~�~88���������������������~����������������������������~���������������p~�����������������p~����������������p~88������������~����������������������������������������~~8���^C

OK so now the baud rates seem to not match.

after setting the baudrate ntp got GPS0 something
not pps mentioned in ntp though as far as I can see, but GPS0 should be symlink to pps probably

 0.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 3.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
*GPS_NMEA(0)     .GPS0.           1 l    3    8    1    0.000    0.177   0.000

Well, that’s progress!

trying to add the outputs of the ntp into linuxptp

timedatectl set-ntp true
phc_ctl /dev/ptp0 set
phc_ctl /dev/ptp0 get
ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -m

does it look like a correct sequence?

ptp4l[1466.840]: selected /dev/ptp0 as PTP clock
ptp4l[1466.876]: port 1: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[1466.876]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[1466.876]: port 1: link down
ptp4l[1466.876]: port 1: LISTENING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
ptp4l[1466.908]: selected local clock 48b02d.fffe.05a771 as best master
ptp4l[1466.908]: port 1: assuming the grand master role
ptp4l[1466.908]: port 1: master state recommended in slave only mode
ptp4l[1466.908]: port 1: defaultDS.priority1 probably misconfigured

You don’t need to specify -p /dev/ptp0. ptp4l can get what it needs just by specifying -i eth0.
gPTP.cfg defaults to a Layer 2 transport so if that’s what you want, then that should work fine.

You’ll then need to run phc2sys -m -s CLOCK_REALTIME -c eth0 -w to keep the PHC in sync with the system clock (as set by ntpd)

Edit: This is all I run for ptp4l… ptp4l -i eth0 -m -H

in two terminals I am then getting something like the below

phc2sys[3991.116]: Waiting for ptp4l...
phc2sys[3992.117]: Waiting for ptp4l...
phc2sys[3993.118]: Waiting for ptp4l...
phc2sys[3994.120]: Waiting for ptp4l...

--------------------------------------
 ptp4l[3980.248]: selected local clock 48b02d.fffe.05a771 as best master
ptp4l[3987.980]: selected local clock 48b02d.fffe.05a771 as best master
ptp4l[3994.676]: selected local clock 48b02d.fffe.05a771 as best master
ptp4l[4002.237]: selected local clock 48b02d.fffe.05a771 as best master
ptp4l[4008.889]: selected local clock 48b02d.fffe.05a771 as best master

does it look as a working state?

cat /sys/class/ptp/ptp0/pps_available 
0

pps_available is controlled by the eqos driver so you can disregard that.
Run the following command to see the current PHC status:

$ phc_ctl eth0 get cmp
phc_ctl[28596.190]: clock time is 1593636215.461996018 or Wed Jul  1 14:43:35 2020
phc_ctl[28596.190]: offset from CLOCK_REALTIME is -37000000008ns

If you want to observe it over time, run…

$ watch -n5 '(ntpq -p ; echo "" ; ntptime ; echo "" ; phc_ctl eth0 get cmp)'
Every 5.0s: (ntpq -p ; echo "" ; ntptime ; echo "" ; phc_ctl eth0 get cmp) 

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
oGPS_NMEA(0)     .GPP0.           1 l    2    8  377    0.000   +0.001   0.002
*time-d-b.nist.g .NIST.           1 u   38   64  377   10.751   +2.109   0.446

ntp_gettime() returns code 0 (OK)
  time e2a77473.5d017db0  Wed, Jul  1 2020 14:45:39.363, (.363304958),
  maximum error 2000 us, estimated error 7 us, TAI offset 0
ntp_adjtime() returns code 0 (OK)
  modes 0x0 (),
  offset 0.491 us, frequency 5.540 ppm, interval 1 s,
  maximum error 2000 us, estimated error 7 us,
  status 0x2001 (PLL,NANO),
  time constant 3, precision 0.001 us, tolerance 500 ppm,

phc_ctl[28757.094]: clock time is 1593636376.365505506 or Wed Jul  1 14:46:16 2020

phc_ctl[28757.094]: offset from CLOCK_REALTIME is -37000000006ns

TThanks; got it;
On another round of implementing of the example below identically it wouldnt synchronize between two nxes by now;
IwWill try next time to incorporate ntp pps to get two devices using the template below

ifconfig eth0 down
ifconfig eth0 up
ifconfig eth0 0.0.0.0
ip addr add 10.0.0.1/24 dev eth0
ip link set dev eth0 up
timedatectl set-ntp false
date 010100002018
phc_ctl /dev/ptp0 set
phc_ctl /dev/ptp0 get
ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -m

DUT side
ifconfig eth0 down
ifconfig eth0 up
ifconfig eth0 0.0.0.0
ip addr add 10.0.0.2/24 dev eth0
ip link set dev eth0 up
timedatectl set-ntp false
phc_ctl /dev/ptp0 get
ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -s -m

server side:

timedatectl set-ntp true
 phc_ctl /dev/ptp0 set
phc_ctl[59699.663]: set clock time to 1593697583.328753958 or Thu Jul  2 09:46:23 2020

phc_ctl /dev/ptp0 get
phc_ctl[59702.564]: clock time is 1593697586.147153638 or Thu Jul  2 09:46:26 2020

ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -m
ptp4l[59732.670]: selected /dev/ptp0 as PTP clock
ptp4l[59732.712]: port 1: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[59732.712]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[59738.715]: port 1: LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES
ptp4l[59738.715]: selected local clock 48b02d.fffe.05a771 as best master
ptp4l[59738.715]: port 1: assuming the grand master role

server side another terminal

 phc2sys -m -s CLOCK_REALTIME -c eth0 -w
phc2sys[61775.234]: Waiting for ptp4l...
phc2sys[61776.236]: Waiting for ptp4l...
phc2sys[61777.237]: Waiting for ptp4l...

server side third terminal

Every 5.0s: (ntpq -p ; echo "" ; ntptime ; echo "" ; phc_ctl eth0 get cmp)                                                           nx2-desktop: Thu Jul  2 10:22:51 2020


ntpq: read: Connection refused

ntp_gettime() returns code 0 (OK)
  time e2a86c13.c980c000  Thu, Jul  2 2020 10:22:11.787, (.787121),
  maximum error 321000 us, estimated error 0 us, TAI offset 0
ntp_adjtime() returns code 0 (OK)
  modes 0x0 (),
  offset -4005.000 us, frequency -4.896 ppm, interval 1 s,
  maximum error 321000 us, estimated error 0 us,
  status 0x0 (),
  time constant 6, precision 1.000 us, tolerance 500 ppm,

phc_ctl[61848.123]: clock time is 1593699731.728004521 or Thu Jul  2 10:22:11 2020

phc_ctl[61848.124]: offset from CLOCK_REALTIME is 60709525ns

client side

inuxptp# ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -s -m
ptp4l[16688.781]: selected /dev/ptp0 as PTP clock
ptp4l[16688.816]: port 1: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[16688.816]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[16696.068]: selected local clock 48b02d.fffe.05a79e as best master
ptp4l[16702.343]: selected local clock 48b02d.fffe.05a79e as best master

question 1: shall I run phc to sys clock?
question 2: does it apear to sync with the master via the network? To me it seems as if local ptp clock is selected as master clock.

@carolyuu
may I know if these steps were tested for a direct lan cable connection between devices or with intermediate switch/router?
Thanks

Attempt #n
server side
[nx device that have wifi and lan interfaces]

ifconfig eth0 down
ifconfig eth0 up
ifconfig eth0 0.0.0.0
ip addr add 10.0.0.1/24 dev eth0
ip link set dev eth0 up
timedatectl set-ntp false
date 010100002020
phc_ctl /dev/ptp0 set
phc_ctl /dev/ptp0 get
ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -m

output server

 ifconfig eth0 down
linuxptp# ifconfig eth0 up
linuxptp# ifconfig eth0 0.0.0.0
linuxptp# ip addr add 10.0.0.1/24 dev eth0
linuxptp# ip link set dev eth0 up
linuxptp# timedatectl set-ntp false
---/linuxptp# date 010100002020
Wed Jan  1 00:00:00 EST 2020
root@---linuxptp# phc_ctl /dev/ptp0 set
phc_ctl[161.914]: set clock time to 1577854800.003010505 or Wed Jan  1 00:00:00 2020

root@---linuxptp# phc_ctl /dev/ptp0 get
phc_ctl[161.918]: clock time is 1577854800.003010505 or Wed Jan  1 00:00:00 2020

root@---linuxptp# ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -m
ptp4l[170.087]: selected /dev/ptp0 as PTP clock
ptp4l[170.129]: port 1: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[170.133]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[176.309]: port 1: LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES
ptp4l[176.310]: selected local clock 48b02d.fffe.05a771 as best master
ptp4l[176.311]: port 1: assuming the grand master role

client

ifconfig eth0 down
ifconfig eth0 up
ifconfig eth0 0.0.0.0
ip addr add 10.0.0.2/24 dev eth0
ip link set dev eth0 up
timedatectl set-ntp false
phc_ctl /dev/ptp0 get
ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -s -m

output

 cd linuxptp/
linuxptp# ifconfig eth0 down
/inuxptp# ifconfig eth0 up
linuxptp# ifconfig eth0 0.0.0.0
linuxptp# ip addr add 10.0.0.2/24 dev eth0
linuxptp# ip link set dev eth0 up
/linuxptp# timedatectl set-ntp false
/linuxptp# phc_ctl /dev/ptp0 get
phc_ctl[392.650]: clock time is 0.000000000 or Wed Dec 31 19:00:00 1969

linuxptp# ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -s -m
ptp4l[394.067]: selected /dev/ptp0 as PTP clock
ptp4l[394.112]: port 1: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[394.112]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[394.112]: port 1: link down
ptp4l[394.112]: port 1: LISTENING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
ptp4l[394.144]: selected local clock 48b02d.fffe.05a79e as best master
ptp4l[394.144]: port 1: assuming the grand master role
ptp4l[394.144]: port 1: master state recommended in slave only mode
ptp4l[394.144]: port 1: defaultDS.priority1 probably misconfigured
ptp4l[395.507]: port 1: link up
ptp4l[395.545]: port 1: FAULTY to LISTENING on INIT_COMPLETE
ptp4l[402.177]: selected local clock 48b02d.fffe.05a79e as best master

it seems to fail

On the master, things need to run in this sequence…

  • Start the watch in a terminal.
  • Start ntpd and make sure that the watch terminal shows a good time sync.
  • Start ptp4l with the following command line (NO config and NO -p)
    ptp4l -i eth0 -m -H
  • Make sure that the watch terminal shows the PHC clock incrementing (it may still be bad).
  • Wait for ptp4l to show assuming the grand master role
  • Start phc2sys (it’s really operating as sys2phc) with the following command line (NO config and NO -p)
    phc2sys -m -s CLOCK_REALTIME -c eth0 -w
  • Make sure the watch terminal shows
    offset from CLOCK_REALTIME is -37000000000ns or about that.

Once you have that we can move on to the client.
I’m running everything on the same LAN segment but I can test across segments.
What transport do you intend to use? Layer2 or Layer3?
Are you going to use unicast or multicast?

I’d suggest getting a basic installation going before doing any customization.

is it a good time sync?
I can see at least two errors listed

Every 5.0s: (ntpq -p ; echo "" ; ntptime ; echo "" ; sudo phc_ctl eth0 get cmp)                                                     comp@comp : Thu Jul  2 13:21:02 2020

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 3.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
xGPS_NMEA(0)     .GPS0.           1 l    1    8  377    0.000    0.713   1.270
 SHM(0)          .NMEA.           0 l    -   16    0    0.000    0.000   0.000
 SHM(1)          .PPS.            0 l    -   16    0    0.000    0.000   0.000
+linode.ibendit. 64.250.105.237   2 u   42   64    3   47.640  365.727   4.623
+fry.gwi.net     192.168.32.8     2 u    6   64    3   11.494  370.744   4.323
+voipmonitor.wci 216.218.254.202  2 u   43   64    3   74.754  363.542   4.628
+srv-a.oocobol.n 209.51.161.238   2 u   44   64    3   47.223  370.376   4.949
*ntp5.doctor.com 50.205.244.27    2 u   43   64    3   28.506  368.111   4.504
+F-Current.sjela 216.218.254.202  2 u   41   64    3   77.682  367.480   4.608
+time.cloudflare 10.106.8.5       3 u   44   64    3    3.289  367.663   4.708
+ntp.vistacomput 204.123.2.5      2 u   44   64    3   76.822  367.008   4.584
+251.228.185.35. 169.254.169.254  3 u   45   64    3   76.685  363.605   4.395
+europa.ellipse. 216.218.192.202  2 u   47   64    3   37.089  366.949   4.387
+laika.paina.net 117.102.177.135  3 u   47   64    3   77.106  366.394   4.548
+time1-inapsales 66.79.142.245    2 u   44   64    3   77.631  367.849   4.417
 chilipepper.can 145.238.203.14   2 u   48   64    3   76.108  368.104   4.359

ntp_gettime() returns code 5 (ERROR)
  time e2a895fe.7ef1348c  Thu, Jul  2 2020 13:21:02.495, (.495868244),
  maximum error 16000000 us, estimated error 16000000 us, TAI offset 37
ntp_adjtime() returns code 5 (ERROR)
  modes 0x0 (),
  offset 0.000 us, frequency 3.004 ppm, interval 1 s,
  maximum error 16000000 us, estimated error 16000000 us,
  status 0x2041 (PLL,UNSYNC,NANO),
  time constant 3, precision 0.001 us, tolerance 500 ppm,

phc_ctl[889.466]: clock time is 0.000000000 or Wed Dec 31 19:00:00 1969

phc_ctl[889.466]: offset from CLOCK_REALTIME is 1593710462516965283ns

Not yet.

The GPS receiver is not being used. I’d remove all of the other remote ntp time servers except
just one or two. It’ll make things easier to troubleshoot.

I should have added the following

  • Watch for ntptime to report just status 0x2001 (PLL,NANO) without the UNSYNC.

Also it doesn’t look like either ptp4l or phc2sys are running yet.
.

it took time to propagate;
without changes it shows by now

Every 5.0s: (ntpq -p ; echo "" ; ntptime ; echo "" ; sudo phc_ctl eth0 get cmp)                                                                                        

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 3.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
xGPS_NMEA(0)     .GPS0.           1 l    1    8  377    0.000  -370.15   0.694
 SHM(0)          .NMEA.           0 l    -   16    0    0.000    0.000   0.000
 SHM(1)          .PPS.            0 l    -   16    0    0.000    0.000   0.000
*ntp5.doctor.com 50.205.244.29    2 u  208  128  116   28.419   -1.815   0.834
+time.cloudflare 10.106.8.5       3 u   67  128  377    2.965   -1.081   0.399
+time1-inapsales 66.79.142.245    2 u  249  128  216   77.672   -1.867   0.533
+chilipepper.can 193.204.114.232  2 u  225  128   16   76.023   -1.779   0.657

ntp_gettime() returns code 0 (OK)
  time e2a8a62f.6b8d716c  Thu, Jul  2 2020 14:30:07.420, (.420127595),
  maximum error 477686 us, estimated error 499 us, TAI offset 37
ntp_adjtime() returns code 0 (OK)
  modes 0x0 (),
  offset -386.843 us, frequency 1.939 ppm, interval 1 s,
  maximum error 477686 us, estimated error 499 us,
  status 0x2001 (PLL,NANO),
  time constant 7, precision 0.001 us, tolerance 500 ppm,

phc_ctl[5034.017]: clock time is 0.000000000 or Wed Dec 31 19:00:00 1969

phc_ctl[5034.017]: offset from CLOCK_REALTIME is 1593714607434539884ns

So ntp looks OK although the gps receiver still isn’t being recognized. Still looks like ptp4l and/or phc2sys aren’t running.

I shall run them

Every 5.0s: (ntpq -p ; echo "" ; ntptime ; echo "" ; sudo phc_ctl eth0 get cmp)                                                                                      Thu Jul  2 15:31:49 2020

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 3.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
xGPS_NMEA(0)     .GPS0.           1 l    -    8  377    0.000  -334.52   1.515
 SHM(0)          .NMEA.           0 l    -   16    0    0.000    0.000   0.000
 SHM(1)          .PPS.            0 l    -   16    0    0.000    0.000   0.000
*ntp5.doctor.com 50.205.244.27    2 u  253  256  377   28.498   -0.405   0.227
+time.cloudflare 10.106.8.5       3 u  207  256  377    3.080   -0.385   0.192
+time1-inapsales 66.79.142.245    2 u  149  256  377   77.812   -0.670   0.165
+chilipepper.can 193.204.114.232  2 u  110  256  377   75.968   -0.716   0.627

ntp_gettime() returns code 0 (OK)
  time e2a8b4a5.e6109000  Thu, Jul  2 2020 15:31:49.898, (.898690),
  maximum error 307058 us, estimated error 388 us, TAI offset 37
ntp_adjtime() returns code 0 (OK)
  modes 0x0 (),
  offset -269.000 us, frequency 1.412 ppm, interval 1 s,
  maximum error 307058 us, estimated error 388 us,
  status 0x0 (),
  time constant 8, precision 1.000 us, tolerance 500 ppm,

phc_ctl[8736.496]: clock time is 1593718346.913954309 or Thu Jul  2 15:32:26 2020

phc_ctl[8736.497]: offset from CLOCK_REALTIME is -37000000301ns