Discussion:
[chrony-users] Chrony does not select PPS source
Simon Haines
2017-09-11 03:01:13 UTC
Permalink
I am configuring chrony (3.1 from buildroot) for an isolated system with an
attached GPS+PPS and trying to get it to set the system time as quickly as
possible. The device does not have a battery-backed RTC and will never have
access to a network. It boots with the system time of 1970-01-01T00:00:00.

The PPS is attached to /dev/pps0 and I have confirmed it is working:
# ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 3196.416134924, sequence: 3137 - clear 0.000000000,
sequence: 0
source 0 - assert 3197.416137528, sequence: 3138 - clear 0.000000000,
sequence: 0
source 0 - assert 3198.416140809, sequence: 3139 - clear 0.000000000,
sequence: 0
source 0 - assert 3199.416151381, sequence: 3140 - clear 0.000000000,
sequence: 0

The GPS is connected through gpsd using the SHM driver, and I've confirmed
it is working (refclock log is below). Here is my chrony.conf:
# cat /etc/chrony.conf
refclock PPS /dev/pps0 lock NMEA
refclock SHM 0 offset 0.5 delay 0.2 refid NMEA noselect
log refclocks
logdir /var/log

Starting chronyd with debugging information suggests that chrony is aware
of the PPS clock:
# chronyd -d -d
1970-01-01T01:03:32Z main.c:473:(main) chronyd version 3.1 starting
(+CMDMON +NTP +REFCLOCK +RTC -PRIVDROP -SCFILTER -SECHASH -SIGND +ASYNCDNS
+IPV6 +DEBUG)
1970-01-01T01:03:32Z conf.c:406:(CNF_ReadFile) Reading /etc/chrony.conf
1970-01-01T01:03:32Z local.c:149:(calculate_sys_precision) Clock precision
0.000000260 (-22)
1970-01-01T01:03:32Z sys_linux.c:317:(get_version_specific_details) Linux
kernel major=4 minor=9 patch=45
1970-01-01T01:03:32Z sys_linux.c:338:(get_version_specific_details) hz=100
nominal_tick=10000 max_tick_bias=1000
1970-01-01T01:03:32Z local.c:663:(lcl_RegisterSystemDrivers) Local
freq=0.000ppm
1970-01-01T01:03:32Z refclock.c:274:(RCL_AddRefclock) refclock PPS
refid=PPS0 poll=4 dpoll=0 filter=16
1970-01-01T01:03:32Z refclock.c:274:(RCL_AddRefclock) refclock SHM
refid=NMEA poll=4 dpoll=0 filter=16
1970-01-01T01:03:32Z refclock.c:442:(RCL_AddPulse) refclock pulse ignored
no ref sample
1970-01-01T01:03:32Z refclock.c:723:(filter_add_sample) filter sample 0
t=3812.539035837 offset=1505092242.960964203 dispersion=0.000001000
1970-01-01T01:03:33Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored
offdiff=0.379203081 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:33Z refclock.c:723:(filter_add_sample) filter sample 1
t=3813.537794586 offset=1505092242.962205410 dispersion=0.000001000
1970-01-01T01:03:34Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored
offdiff=0.380447388 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:34Z refclock.c:723:(filter_add_sample) filter sample 2
t=3814.536533857 offset=1505092242.963466167 dispersion=0.000001000
1970-01-01T01:03:35Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored
offdiff=0.381711483 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:35Z refclock.c:723:(filter_add_sample) filter sample 3
t=3815.537782398 offset=1505092242.962217569 dispersion=0.000001000
1970-01-01T01:03:36Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored
offdiff=0.380466461 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:36Z refclock.c:723:(filter_add_sample) filter sample 4
t=3816.537785262 offset=1505092242.962214708 dispersion=0.000001000
1970-01-01T01:03:37Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored
offdiff=0.380466938 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:37Z refclock.c:723:(filter_add_sample) filter sample 5
t=3817.537906252 offset=1505092242.962093830 dispersion=0.000001000
1970-01-01T01:03:38Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored
offdiff=0.380349398 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:38Z refclock.c:723:(filter_add_sample) filter sample 6
t=3818.536778178 offset=1505092242.963221788 dispersion=0.000001000

The refclock log never shows any output for PPS0:
# cat /var/log/refclocks.log
===============================================================================
Date (UTC) Time Refid DP L P Raw offset Cooked offset
Disp.
===============================================================================
1970-01-01 01:03:32.539035 NMEA 0 N 0 1.505092e+09 1.505092e+09
1.000e-06
1970-01-01 01:03:33.537794 NMEA 1 N 0 1.505092e+09 1.505092e+09
1.000e-06
1970-01-01 01:03:34.536533 NMEA 2 N 0 1.505092e+09 1.505092e+09
1.000e-06
1970-01-01 01:03:35.537782 NMEA 3 N 0 1.505092e+09 1.505092e+09
1.000e-06
1970-01-01 01:03:36.537785 NMEA 4 N 0 1.505092e+09 1.505092e+09
1.000e-06
1970-01-01 01:03:37.537906 NMEA 5 N 0 1.505092e+09 1.505092e+09
1.000e-06

The sources report shows:
# chronyc sources
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample

===============================================================================
#? PPS0 0 4 0 - +0ns[ +0ns] +/-
0ns
#? NMEA 0 4 377 22 -17420d[-17420d] +/-
101ms

Further help with synchronising to the PPS would be appreciated, as would
any configuration advice for an isolated system with a large time delta at
boot (I am considering 'makestep 0.1 300' assuming 5 minutes for the GPS to
acquire lock).
Simon.
Denny Page
2017-09-11 05:39:04 UTC
Permalink
A few things come to mind:

- You didn’t include any information about your gpsd configuration.

- With the approach you are taking, you have to start gpsd before you start chronyd. Are you?

- Are you sure you are looking at the right PPS device? There may be PPS devices for other PPS sources such as network interface cards.

- Have you considered using socket communication between gpsd and chronyd instead?

refclock SOCK /var/run/chrony.ttyUSB0.sock refid PPS precision 1e-03

Note that if you are using socket communication, gpsd must be started after chronyd rather than before.

Denny
I am configuring chrony (3.1 from buildroot) for an isolated system with an attached GPS+PPS and trying to get it to set the system time as quickly as possible. The device does not have a battery-backed RTC and will never have access to a network. It boots with the system time of 1970-01-01T00:00:00.
# ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 3196.416134924, sequence: 3137 - clear 0.000000000, sequence: 0
source 0 - assert 3197.416137528, sequence: 3138 - clear 0.000000000, sequence: 0
source 0 - assert 3198.416140809, sequence: 3139 - clear 0.000000000, sequence: 0
source 0 - assert 3199.416151381, sequence: 3140 - clear 0.000000000, sequence: 0
# cat /etc/chrony.conf
refclock PPS /dev/pps0 lock NMEA
refclock SHM 0 offset 0.5 delay 0.2 refid NMEA noselect
log refclocks
logdir /var/log
# chronyd -d -d
1970-01-01T01:03:32Z main.c:473:(main) chronyd version 3.1 starting (+CMDMON +NTP +REFCLOCK +RTC -PRIVDROP -SCFILTER -SECHASH -SIGND +ASYNCDNS +IPV6 +DEBUG)
1970-01-01T01:03:32Z conf.c:406:(CNF_ReadFile) Reading /etc/chrony.conf
1970-01-01T01:03:32Z local.c:149:(calculate_sys_precision) Clock precision 0.000000260 (-22)
1970-01-01T01:03:32Z sys_linux.c:317:(get_version_specific_details) Linux kernel major=4 minor=9 patch=45
1970-01-01T01:03:32Z sys_linux.c:338:(get_version_specific_details) hz=100 nominal_tick=10000 max_tick_bias=1000
1970-01-01T01:03:32Z local.c:663:(lcl_RegisterSystemDrivers) Local freq=0.000ppm
1970-01-01T01:03:32Z refclock.c:274:(RCL_AddRefclock) refclock PPS refid=PPS0 poll=4 dpoll=0 filter=16
1970-01-01T01:03:32Z refclock.c:274:(RCL_AddRefclock) refclock SHM refid=NMEA poll=4 dpoll=0 filter=16
1970-01-01T01:03:32Z refclock.c:442:(RCL_AddPulse) refclock pulse ignored no ref sample
1970-01-01T01:03:32Z refclock.c:723:(filter_add_sample) filter sample 0 t=3812.539035837 offset=1505092242.960964203 dispersion=0.000001000
1970-01-01T01:03:33Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored offdiff=0.379203081 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:33Z refclock.c:723:(filter_add_sample) filter sample 1 t=3813.537794586 offset=1505092242.962205410 dispersion=0.000001000
1970-01-01T01:03:34Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored offdiff=0.380447388 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:34Z refclock.c:723:(filter_add_sample) filter sample 2 t=3814.536533857 offset=1505092242.963466167 dispersion=0.000001000
1970-01-01T01:03:35Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored offdiff=0.381711483 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:35Z refclock.c:723:(filter_add_sample) filter sample 3 t=3815.537782398 offset=1505092242.962217569 dispersion=0.000001000
1970-01-01T01:03:36Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored offdiff=0.380466461 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:36Z refclock.c:723:(filter_add_sample) filter sample 4 t=3816.537785262 offset=1505092242.962214708 dispersion=0.000001000
1970-01-01T01:03:37Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored offdiff=0.380466938 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:37Z refclock.c:723:(filter_add_sample) filter sample 5 t=3817.537906252 offset=1505092242.962093830 dispersion=0.000001000
1970-01-01T01:03:38Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored offdiff=0.380349398 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:38Z refclock.c:723:(filter_add_sample) filter sample 6 t=3818.536778178 offset=1505092242.963221788 dispersion=0.000001000
# cat /var/log/refclocks.log
===============================================================================
Date (UTC) Time Refid DP L P Raw offset Cooked offset Disp.
===============================================================================
1970-01-01 01:03:32.539035 NMEA 0 N 0 1.505092e+09 1.505092e+09 1.000e-06
1970-01-01 01:03:33.537794 NMEA 1 N 0 1.505092e+09 1.505092e+09 1.000e-06
1970-01-01 01:03:34.536533 NMEA 2 N 0 1.505092e+09 1.505092e+09 1.000e-06
1970-01-01 01:03:35.537782 NMEA 3 N 0 1.505092e+09 1.505092e+09 1.000e-06
1970-01-01 01:03:36.537785 NMEA 4 N 0 1.505092e+09 1.505092e+09 1.000e-06
1970-01-01 01:03:37.537906 NMEA 5 N 0 1.505092e+09 1.505092e+09 1.000e-06
# chronyc sources
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
#? PPS0 0 4 0 - +0ns[ +0ns] +/- 0ns
#? NMEA 0 4 377 22 -17420d[-17420d] +/- 101ms
Further help with synchronising to the PPS would be appreciated, as would any configuration advice for an isolated system with a large time delta at boot (I am considering 'makestep 0.1 300' assuming 5 minutes for the GPS to acquire lock).
Simon.
--
To unsubscribe email chrony-users-***@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-***@chrony.tuxfamily.org
with "help" in the subject.
Trouble? Email ***@chrony.tuxfamily.org.
Simon Haines
2017-09-11 07:45:29 UTC
Permalink
Thanks Denny,
- You didn’t include any information about your gpsd configuration.
The GPS device is a UBlox LEA 6S connected via a CP210X UART-to-USB bridge
to a USB port and is mounted as /dev/ttyUSB0. The daemon starts with 'gpsd
/dev/ttyUSB0 -n' (the -n flag starts decoding messages before a client
connects).

The PPS is wired into a GPIO pin and is mounted as /dev/pps0. When the GPS
is discovered by gpsd, it creates a second PPS source as /dev/pps1 (using
the line discipline driver), but because this source is backed by USB, it
never pulses. I have confirmed that /dev/pps0 is the correct source for the
GPIO pin, as the ppstest log shows, and that /dev/pps1 times out. It is
/dev/pps0 that is in the chrony.conf.

- With the approach you are taking, you have to start gpsd before you start
chronyd. Are you?
I've experimented with changing the order in which gpsd and chronyd start
with no success. If I remove the 'noselect' option from the NMEA refclock,
chrony will synchronise to the GPS time, but the PPS refclock is never
polled (reach = 0). I've let chrony synchronise the system time to NMEA,
killed the chronyd daemon, and then restarted it with the 'noselect' option
restored (to discard the possibility that the large time delta from
1970-01-01T00:00:00 may be confusing chrony), but no success.
- Are you sure you are looking at the right PPS device? There may be PPS
devices for other PPS sources such as network interface cards.
I can see the PPS working as expected with ppstest and have ensured both
gpsd and chronyd are configured with the right devices.

Are there any more debugging options I can invoke to get a better
understanding as to why chrony is ignoring the PPS pulses? Thanks.
Simon.
Miroslav Lichvar
2017-09-11 09:57:04 UTC
Permalink
Post by Simon Haines
The GPS is connected through gpsd using the SHM driver, and I've confirmed
# cat /etc/chrony.conf
refclock PPS /dev/pps0 lock NMEA
refclock SHM 0 offset 0.5 delay 0.2 refid NMEA noselect
Try changing the offset to 0.1. From the log below it looks like the
offset between the two refclocks is too large and prevents their
locking.
Post by Simon Haines
1970-01-01T01:03:34Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored
offdiff=0.380447388 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:34Z refclock.c:723:(filter_add_sample) filter sample 2
t=3814.536533857 offset=1505092242.963466167 dispersion=0.000001000
1970-01-01T01:03:35Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored
offdiff=0.381711483 refdisp=0.000001260 disp=0.000000001
Further help with synchronising to the PPS would be appreciated, as would
any configuration advice for an isolated system with a large time delta at
boot (I am considering 'makestep 0.1 300' assuming 5 minutes for the GPS to
Please note that the second argument of makestep is number of updates
and not seconds.
--
Miroslav Lichvar
--
To unsubscribe email chrony-users-***@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-***@chrony.tuxfamily.org
with "help" in the subject.
Trouble? Email ***@chrony.tuxfamily.org.
Bill Unruh
2017-09-11 15:16:33 UTC
Permalink
William G. Unruh __| Canadian Institute for|____ Tel: +1(604)822-3273
Physics&Astronomy _|___ Advanced Research _|____ Fax: +1(604)822-5324
UBC, Vancouver,BC _|_ Program in Cosmology |____ ***@physics.ubc.ca
Canada V6T 1Z1 ____|____ and Gravity ______|_ www.theory.physics.ubc.ca/
Post by Miroslav Lichvar
Post by Simon Haines
The GPS is connected through gpsd using the SHM driver, and I've confirmed
# cat /etc/chrony.conf
refclock PPS /dev/pps0 lock NMEA
refclock SHM 0 offset 0.5 delay 0.2 refid NMEA noselect
Try changing the offset to 0.1. From the log below it looks like the
offset between the two refclocks is too large and prevents their
locking.
shm 0 is noselect so it should not matter. Also PPS is the pluse which is the
clock's own time (in seconds) beeing fed back to it. (Ie, the nanoseconds are
correct UTC but the seconds are whatever the system clock says they are), so
it should not prevent a lock.
Post by Miroslav Lichvar
Post by Simon Haines
1970-01-01T01:03:34Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored
offdiff=0.380447388 refdisp=0.000001260 disp=0.000000001
1970-01-01T01:03:34Z refclock.c:723:(filter_add_sample) filter sample 2
t=3814.536533857 offset=1505092242.963466167 dispersion=0.000001000
1970-01-01T01:03:35Z refclock.c:465:(RCL_AddPulse) refclock pulse ignored
offdiff=0.381711483 refdisp=0.000001260 disp=0.000000001
Further help with synchronising to the PPS would be appreciated, as would
any configuration advice for an isolated system with a large time delta at
boot (I am considering 'makestep 0.1 300' assuming 5 minutes for the GPS to
Please note that the second argument of makestep is number of updates
and not seconds.
--
Miroslav Lichvar
--
with "unsubscribe" in the subject.
with "help" in the subject.
--
To unsubscribe email chrony-users-***@chrony.tuxfamily.org
with "unsubscribe" in the subject.
For help email chrony-users-***@chrony.tuxfamily.org
with "help" in the subject.
Trouble? Email ***@chrony.tuxfamily.org.
Simon Haines
2017-09-12 05:21:46 UTC
Permalink
Thanks Miroslav,
Post by Simon Haines
Post by Simon Haines
The GPS is connected through gpsd using the SHM driver, and I've
confirmed
Post by Simon Haines
# cat /etc/chrony.conf
refclock PPS /dev/pps0 lock NMEA
refclock SHM 0 offset 0.5 delay 0.2 refid NMEA noselect
Try changing the offset to 0.1. From the log below it looks like the
offset between the two refclocks is too large and prevents their
locking.
Yes, this now works as expected. I now see the log entries 'refclock pulse
ignored offdiff=0.38' and understand this relates to the delta between
locking clocks, and not the system time.

Please note that the second argument of makestep is number of updates
Post by Simon Haines
and not seconds.
OK, I had assumed one update per second from both refclocks. There is no
reason to restrict the number of updates in this way for my use case, and
I've extended the configuration to the default 1000 updates.

Many thanks for helping with this.
Simon.

Loading...