Perhaps an elementary question, but maybe someone knows. The goal is to
have getnstimeofday() return a synchronized time value for 2 systems in a
kernel module. To do this, I would expect a simple "date" call from each
system to be pretty close, but it is not.
Using 2 x Jetson TX2 boards running Ubuntu 16.04 + ptp4l on Device 1 we set
an arbitrary date.
ptp4l is running as a service on both:
/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf -i eth0
set an arbitrary date on Device1:
nvidia@jetson-randy1:~$ sudo date -s "Dec 1 2015 04:00:00"
Tue Dec 1 04:00:00 UTC 2015
nvidia@jetson-randy1:~$ timedatectl
Local time: Tue 2015-12-01 04:00:01 UTC
Universal time: Tue 2015-12-01 04:00:01 UTC
RTC time: Wed 2017-03-01 12:12:00
Time zone: Etc/UTC (UTC, +0000)
Network time on: no
NTP synchronized: no
RTC in local TZ: no
on Device2 we set a different arbitrary date:
nvidia@jetson-randy2:~$ sudo date -s "Mar 10 2018 12:00:00"
Sat Mar 10 12:00:00 UTC 2018
nvidia@jetson-randy2:~$ timedatectl
Local time: Sat 2018-03-10 12:00:01 UTC
Universal time: Sat 2018-03-10 12:00:01 UTC
RTC time: Sat 2018-12-01 13:11:21
Time zone: Etc/UTC (UTC, +0000)
Network time on: no
NTP synchronized: no
RTC in local TZ: no
Now we start ptp4l and phc2sys on each device.
Device 1:
Dec 1 04:02:06 jetson-randy1 systemd[1]: Started Precision Time Protocol
(PTP) service.
Dec 1 04:02:06 jetson-randy1 ptp4l: [83945.116] selected /dev/ptp0 as PTP
clock
Dec 1 04:02:06 jetson-randy1 ptp4l: [83945.117] port 1: INITIALIZING to
LISTENING on INITIALIZE
Dec 1 04:02:06 jetson-randy1 ptp4l: [83945.117] port 0: INITIALIZING to
LISTENING on INITIALIZE
Dec 1 04:02:08 jetson-randy1 ptp4l: [83946.193] port 1: new foreign master
00044b.fffe.c56e7b-1
Dec 1 04:02:12 jetson-randy1 ptp4l: [83950.194] selected best master clock
00044b.fffe.c56e7b
Dec 1 04:02:12 jetson-randy1 ptp4l: [83950.195] assuming the grand master
role
Dec 1 04:02:12 jetson-randy1 ptp4l: [83950.195] port 1: LISTENING to
GRAND_MASTER on RS_GRAND_MASTER
and
nvidia@jetson-randy1:~$ sudo phc2sys -a -r -m
phc2sys[83977.835]: reconfiguring after port state change
phc2sys[83977.839]: selecting eth0 for synchronization
phc2sys[83977.840]: nothing to synchronize
Device 2:
Mar 10 12:03:02 jetson-randy2 systemd[1]: Started Precision Time Protocol
(PTP) service.
Mar 10 12:03:02 jetson-randy2 ptp4l: [75310.117] selected /dev/ptp0 as PTP
clock
Mar 10 12:03:02 jetson-randy2 ptp4l: [75310.118] port 1: INITIALIZING to
LISTENING on INITIALIZE
Mar 10 12:03:02 jetson-randy2 ptp4l: [75310.118] port 0: INITIALIZING to
LISTENING on INITIALIZE
Mar 10 12:03:04 jetson-randy2 ptp4l: [75312.065] port 1: new foreign master
00044b.fffe.c4cf6f-1
Mar 10 12:03:08 jetson-randy2 ptp4l: [75316.066] selected best master clock
00044b.fffe.c4cf6f
Mar 10 12:03:08 jetson-randy2 ptp4l: [75316.067] port 1: LISTENING to
UNCALIBRATED on RS_SLAVE
Mar 10 12:03:09 jetson-randy2 ptp4l: [75317.066] master offset
71740766475479566 s0 freq +62500000 path delay 0
Mar 10 12:03:10 jetson-randy2 ptp4l: [75318.066] master offset
71740766475512626 s1 freq +62500000 path delay -4004
Mar 10 12:03:12 jetson-randy2 ptp4l: [75320.068] master offset -124949356
s2 freq -62449356 path delay -1768
Mar 10 12:03:12 jetson-randy2 ptp4l: [75320.068] port 1: UNCALIBRATED to
SLAVE on MASTER_CLOCK_SELECTED
Mar 10 12:03:13 jetson-randy2 ptp4l: [75321.067] master offset -62730032
s2 freq -37714839 path delay -4004
Mar 10 12:03:14 jetson-randy2 ptp4l: [75322.068] master offset -24937060
s2 freq -18740876 path delay -6240
Mar 10 12:03:15 jetson-randy2 ptp4l: [75323.067] master offset -1649428
s2 freq -2934362 path delay -4492000
and
nvidia@jetson-randy2:~$ sudo phc2sys -a -r -m
phc2sys[75361.130]: reconfiguring after port state change
phc2sys[75361.133]: selecting CLOCK_REALTIME for synchronization
phc2sys[75361.133]: selecting eth0 as the master clock
phc2sys[75361.133]: CLOCK_REALTIME phc offset 71740802475284240 s0 freq
+30393 delay 5600
phc2sys[75362.134]: CLOCK_REALTIME phc offset 71740802475284367 s1 freq
+30520 delay 5664
phc2sys[75363.134]: CLOCK_REALTIME phc offset -400 s2 freq +30120
delay 3136
phc2sys[75364.135]: CLOCK_REALTIME phc offset 17 s2 freq +30417
delay 3168
phc2sys[75365.135]: CLOCK_REALTIME phc offset 502 s2 freq +30907
delay 5664
phc2sys[75366.136]: CLOCK_REALTIME phc offset 100 s2 freq +30656
delay 5632
phc2sys[75367.137]: CLOCK_REALTIME phc offset -117 s2 freq +30469
delay 5664
phc2sys[75368.137]: CLOCK_REALTIME phc offset -114 s2 freq +30437
delay 5663
phc2sys[75369.138]: CLOCK_REALTIME phc offset -174 s2 freq +30342
delay 5568
yet if we run these commands quickly:
nvidia@jetson-randy1:~$ date
Tue Dec 1 04:05:21 UTC 2015
nvidia@jetson-randy2:~$ date
Tue Dec 1 04:04:45 UTC 2015
we notice that the times are off by about 40 seconds.
Thoughts?
Randy
_______________________________________________
Linuxptp-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-users