This is old and crusty. You have been warned!

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


  1. 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.
  2. 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
  3. 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*
  4. Attempt to build. THIS WILL FAIL! Whatever. If not, who knows.
    # dpkg-buildpackage -uc -us -nc
  5. It failed. Fix it by editing:
    nano ntpd/refclock_jupiter.c
  6. 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)

  7. Compile again
    # dpkg-buildpackage -uc -us -nc
  8. Install!
    # dpkg -i *.deb

    (the deb will be up a level)

  9. 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.

  10. Add user ntp to the dialout group
    sudo gpasswd -a ntp dialout
  11. 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 mode 18 minpoll 4 iburst prefer true
    fudge 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 ::1
    # Clients from this subnet have unlimited access, but only if
    # cryptographically authenticated.
    restrict mask notrust

    Tweak as necessary. I don't know all the fudge flags yet. This can be improved.

  12. Restart ntp service
    sudo service ntp restart
  13. 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.220

    If anything failed, check journalctl -xe to see if there are any hints. There almost always are.

  14. 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 4.2.6p5@1.2349-o 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:

ntpgps.txt · Last modified: 2021/02/21 18:57 by john
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0