ntp gps setup
This process has been complicated and messy, because of the combination of 1) I don't know what I'm doing, and 2) the resources on this are good but complicated. Almost everything I've figured out has come from these three pages:
I had to fill in a few holes here and there, so I am going to try and get a comprehensive guide in place here, because I will forget.
- dc7900 running ubu server 14.04
- Garmin 18x LVC to ttyS0 on above, spliced in USB conn for power
- Install and update ubuntu server on machine. Desktop works but server is lighter. This guide will also probably work for debian but I am writing it for ubu now because that's what I have working.
- Disable apparmor. This is a single purpose server. Apparmor is garbage and gets in the way of everything. Do so by:
sudo service apparmor stop
sudo update-rc.d -f apparmor remove
- Prepare to build ntp with pps support (get all the bits)
# apt-get build-dep ntp
# apt-get install pps-tools ubuntu-dev-tools
# apt-get source ntp
# cd ntp*
- Attempt to build. THIS WILL FAIL! Whatever. If not, who knows.
# dpkg-buildpackage -uc -us -nc
- It failed. Fix it by editing:
- Go to line 904. Comment it out as such
/* fprintf(stdout, buffer); */(yes this commenting could be done before the attempted build, but if it works before hand, you save a step. Compiling again after the failure is very fast anyway)
- Compile again
# dpkg-buildpackage -uc -us -nc
# dpkg -i *.deb(the deb will be up a level)
- Configure udev rules to properly configure the devices at boot.
# 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"For some reason, the ldattach bit never works for me and I have to run it manually after rebooting. This is a huge pain and I don't know how to fix it yet.
- Add user ntp to the dialout group
sudo gpasswd -a ntp dialout
- Configure /etc/ntp.conf as such:
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help driftfile /var/lib/ntp/ntp.drift # Enable this if you want statistics to be logged. statsdir /var/log/ntpstats/ statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable # Specify one or more NTP servers. # local mess 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 # Use time-a and b ntp servers as a fallback. server time-a.nist.gov server time-b.nist.gov # By default, exchange time with everybody, but don't allow configuration. restrict -4 default kod notrap nomodify nopeer noquery restrict -6 default kod notrap nomodify nopeer noquery # Local users may interrogate the ntp server more closely. restrict 127.0.0.1 restrict ::1 # Clients from this subnet have unlimited access, but only if # cryptographically authenticated. restrict 10.0.0.0 mask 255.0.0.0 notrustTweak as necessary. I don't know all the fudge flags yet. This can be improved.
- Restart ntp service
sudo service ntp restart
- Check ntpq -p output. If everything went well, you should see something like this:
john@dc7900:~$ ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== oGPS_NMEA(0) .GPS. 0 l 6 16 377 0.000 0.623 0.072 *time-a.nist.gov .ACTS. 1 u 25 64 373 91.647 36.162 4.774 +time-b.nist.gov .ACTS. 1 u 18 64 165 96.251 41.469 2.220If anything failed, check journalctl -xe to see if there are any hints. There almost always are.
- Just for funsies, ntpq -pcrv output:
john@dc7900:~$ ntpq -pcrv remote refid st t when poll reach delay offset jitter ============================================================================== oGPS_NMEA(0) .GPS. 0 l 15 16 377 0.000 0.492 0.044 +time-a.nist.gov .ACTS. 1 u 26 64 337 91.647 36.162 4.632 *time-b.nist.gov .ACTS. 1 u 23 64 257 92.135 38.865 4.538 associd=0 status=041d leap_none, sync_uhf_radio, 1 event, kern, version="ntpd firstname.lastname@example.org Fri Feb 26 13:56:57 UTC 2016 (1)", processor="x86_64", system="Linux/4.2.0-16-generic", leap=00, stratum=1, precision=-21, rootdelay=0.000, rootdisp=0.979, refid=GPS, reftime=da7ae733.9e1ec802 Fri, Feb 26 2016 10:01:07.617, clock=da7ae742.600f0f00 Fri, Feb 26 2016 10:01:22.375, peer=45935, tc=4, mintc=3, offset=0.492, frequency=22.723, sys_jitter=0.044, clk_jitter=0.000, clk_wander=0.145
To D0 & Thoughts
Right now my offset and jitter can be improved. This can be done by:
- Disable all but GPGGA
- Push pulse width to 200ms
- Some people don't like, and have trouble with, the 18x LVC:
- Similar to above:
- I think it's worth noting that my jitter is WAY lower than being reported there. One guy is setting 5-10ms jitter while I am seeing <0.024ms jitter. Either that guy has a bad unit and is being a negative nancy, or firmware updates have made them notably better.
- Get serial pass-through working on the TS140. This will take some tinkering but should be doable. Latency is my only concern.