Friday, October 24, 2014

linux - How can I check whether my NTP daemon has PPS support?


I have already read about compiling NTP with timepps.h provided to get PPS support. Is there an easy way to check the already precompiled or rather installed version of an repository (Ubuntu 14.04.1, Kernel 3.13.0-37) for PPS support?


EDIT some googles later...


I inserted this in my /etc/ntp.conf and restartet ntpd. Seems this configuration to be correct? I'm using this GPS breakout board on /dev/ttyS0. According to documentation this should satisfy GPS with PPS. Baudrate is 9600.


server 127.127.20.0 mode 18 minpoll 4 iburst prefer true
fudge 127.127.20.0 flag1 1 flag2 0 flag3 1 flag4 1

I spent some time to get it work because apparmor blocked ntpd open the serial port. I figured that out from the syslos. Therefore I added this line to /etc/apparmor.d/tunables/ntpd. Then it worked.


@{NTPD_DEVICE}="/dev/ttyS0"

The permissions on the devices are


$ ll /dev/ttyS0 /dev/pps* /dev/gps*
lrwxrwxrwx 1 root root 5 Okt 18 23:00 /dev/gps0 -> ttyS0
lrwxrwxrwx 1 root root 4 Okt 18 23:00 /dev/gpspps0 -> pps0
crw-rw-rw- 1 root dialout 251, 0 Okt 18 23:00 /dev/pps0
crw-rw-rw- 1 root dialout 4, 64 Okt 18 23:09 /dev/ttyS0
$ id ntp
uid=106(ntp) gid=113(ntp) Gruppen=113(ntp),20(dialout)

To achieve this permanently I created some udev rules. Whereas the setserial command seems not to take effect if I check the port with setserial -a /dev/ttyS0 after system boot.


$ cat /etc/udev/rules.d/09-pps.rules
# Provide a symlink to /dev/ttyS0 and set low_latency for latency improvement
KERNEL=="ttyS0", SYMLINK+="gps0", MODE="0666"
KERNEL=="ttyS0", RUN+="/bin/setserial /dev/%k low_latency"
KERNEL=="ttyS0", RUN+="/usr/sbin/ldattach pps /dev/%k"
# Symlink /dev/pps0 to /dev/gpspps0
KERNEL=="pps0", SUBSYSTEM=="pps", DRIVER=="", SYMLINK+="gpspps0"
KERNEL=="pps0", GROUP="dialout"
KERNEL=="pps0", MODE="0666"

After that I had to delete /var/lib/ntp/ntp.conf.dhcp once. Because it is derived from /etc/ntp.conf at any DHCP event or just reboot. So it will generate a new one on startup.


Do I still need 127.127.22.* entry (ATOM PPS driver)? Because as stated in the documentation if I use flag1=1 PPS will be used implicitly? No, it works just with GPS NMEA (127.127.20.u).


My output of ntpq -p is now


     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
-fritz.box 185.31.136.34 3 u 36 64 177 0.298 4.496 0.076
*arcticfox.dorid 192.53.103.104 2 u 43 64 177 14.125 2.041 1.307
+monitman.com 158.43.128.33 2 u 44 64 177 25.325 4.703 0.314
+spacys.de 212.82.32.15 2 u 43 64 177 24.156 -1.503 2.094
-cse-server.com 122.227.206.195 3 u 38 64 177 24.372 -3.421 0.618
oGPS_NMEA(0) .GPS. 0 l 1 16 377 0.000 -0.270 0.024

For ATOM clock support I have to compile ntp with enabled ATOM clock support.


Answer



Why not make it easy on yourself and try to use the PPS functionality. Edit your config file and to include the relevant PPS flag and start ntpd. This seems so obvious I am not sure if I am missing a constraint.


It is not clear to me what you mean by "installed version of an repository"? Do you mean linux distribution? If you do the answer is yes but it depends on what distribution you are using. But just attempting to make use of PPS seems like the best test.


Once you verify that you have the gps device configured corectly you can rebuild ntp with pps support by:


 # apt-get build-dep ntp
# apt-get install pps-tools ubuntu-dev-tools
# apt-get source ntp
# cd
# dpkg-buildpackage -uc -us -nc
# dpkg -i ../ntp*.deb

To avoid that apt doesn't install a new version, again without ATOM clock support, use


 # echo ntp hold  | dpkg --set-selections

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...