Not quite 5 minute guide to making an NTP Server

This is an article on making a network attached Stratum 1 NTP Server using a Raspberry Pi+ Model 2 or 3 and the Uputronics Raspberry Pi+ GPS Expansion Board. If you need a standalone ready to go solution or need more performance please consider the LeoNTP Networked Time server unit which is available here.

As of May 2016 this was heavily reworked due to a new version of Raspbian which did all sorts of wonderful things like disabling the serial ports etc. This guide assumes Raspbian Jessie Lite June 2017 2017-06-21. No other version or distribution is supported.

I’ve also removed the off grid/standalone instructions as NTP isn’t designed to work off grid using just the NMEA derived time and PPS to discipline it.

HAB Supplies Raspberry Pi+ GPS Expansion Board

Uputronics Raspberry Pi+ GPS Expansion Board

Ideally rather than supplying a premade image I would have a set of concise instructions on making your own install from scratch so you could use the latest versions of the software. With assistance from David Taylor who did lots of background work on this here I present the following instructions on making a cheap PPS disciplined NTP Time server using one of the Raspberry Pi+ GPS boards sold on Uputronics.

The guide assumes you have a cursory knowledge of Linux, enough to install Raspbian and login should do.

You will need a Raspberry Pi 2 or 3 B+, the Uputronics Raspberry Pi+ GPS Expansion Board and a suitable GPS antenna.

This guide is assuming you’re using Raspbian Jessie Lite installed from the June 2017 image. Download and write this to an SD card (See http://www.raspberrypi.org/documentation/installation/installing-images/README.md). Other distributions may work but these instructions are known to work with Raspbian Jessie Lite.

Attach the Uputronics Raspberry Pi+ GPS Expansion Board to the Pi, insert the SD card, connect the antenna and network cable and boot the Pi up. Either connect locally or via SSH to the Pi. Follow the instructions carefully if you miss steps things won’t work.

Text in italics is what you type.
Text in red indicates editing inside a file.

Prerequisite Settings

sudo raspi-config
5 Interfacing Options
P2 SSH -> Would you like the SSH server to be enabled – YES (Recommended)
P6 Serial -> Login Shell (no) Hardware (yes)
Quit but no need to reboot at this point.

sudo nano /boot/config.txt
Add at the bottom :
# Allow the normal UART pins to work
dtoverlay=pi3-miniuart-bt
dtoverlay=pps-gpio,gpiopin=18
Save and Quit Nano.

sudo apt-get update
sudo apt-get dist-upgrade

sudo systemctl disable hciuart
sudo systemctl mask [email protected]

sudo apt-get install pps-tools
sudo apt-get install libcap-dev
sudo reboot

Verifying PPS Is Working

Ensure the GPS has a lock and the Green PPS LED on the Uputronics Pi+ GPS Expansion Board is blinking once a second.

dmesg | grep pps

Output should be similar to :

[ 2.443494] pps_core: LinuxPPS API ver. 1 registered
[ 2.446699] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
[ 2.471796] pps pps0: new PPS source pps.-1
[ 2.471886] pps pps0: Registered IRQ 498 as PPS source
[ 6.965166] pps_ldisc: PPS line discipline registered
[ 6.966569] pps pps1: new PPS source ttyAMA0
[ 6.966664] pps pps1: source "/dev/ttyAMA0" added

sudo ppstest /dev/pps0

Output should be similar to:

 trying PPS source "/dev/pps0"
 found PPS source "/dev/pps0"
 ok, found 1 source(s), now start fetching data...
 source 0 - assert 1418933982.998042450, sequence: 970 - clear  0.000000000, sequence: 0
 source 0 - assert 1418933983.998045441, sequence: 971 - clear  0.000000000, sequence: 0

(Press CTRL+C to quit). This indicates the PPS Module is loaded (top example) and is working (bottom).

GPS board mounted in Geaux Robot Dog Bone Case for Raspberry Pi B+ also available from HAB Supplies

GPS board mounted in Geaux Robot Dog Bone Case for Raspberry Pi B+ also available from Uputronics

Enabling PPS/ATOM Support in NTPD

The supplied version of NTPD on the Raspberry Pi doesn’t support PPS so we need to recompile it (Please note that some of these steps may take up to 30 minutes).

wget https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p10.tar.gz
tar zxvf ntp-4.2.8p10.tar.gz
cd ntp-4.2.8p10
./configure  –enable-lcap
make -j4
sudo make install
sudo service ntp stop
sudo cp /usr/local/bin/ntp* /usr/bin/ && sudo cp /usr/local/sbin/ntp* /usr/sbin/
sudo nano /etc/ntp.conf

Add
server 127.127.22.0 minpoll 4 maxpoll 4
fudge 127.127.22.0  flag3 1  refid PPS

Amend

server 0.debian.pool.ntp.org iburst prefer

You may also want to add your local lan to so you can query the NTP Server by adding:
restrict 192.168.1.0 mask 255.255.255.0

Note You MUST add a preferred server or PPS doesn’t work. Its worth at this point seeing if you’re ISP has its own NTP server you can use and adding that but for the purposes of this exercise adding prefer to the Debian pool one will do.

Save and close nano.

sudo nano /etc/init.d/ntp
Find the line NTPD_OPTS=”$NTPD_OPTS -u $UGID”
Amend it to say NTPD_OPTS=”$NTPD_OPTS”

sudo systemctl daemon-reload

sudo service ntp restart

After a few minutes run

ntpq –p

if you get oPPS(0) this indicates source selected, Pulse Per Second (PPS) used and everything is working.

If you aren’t seeing the settings its possible the NTP server is picking up the NTP information via DHCP which is over riding your settings above. Do this :

rm /etc/dhcp/dhclient-exit-hooks.d/ntp
rm /var/lib/ntp/ntp.conf.dhcp

At this point you have a NTP server which will use an external time source and use your local PPS to discipline it.

Setting Stationary Mode

Grab this small program code here : https://pastebin.com/YTc9Nd3D
Compile + link:

gcc -o gpsControl gpsControl.c

sudo ./gpsControl -p -d /dev/ttyAMA0 = Portable Mode
sudo ./gpsControl -s -d /dev/ttyAMA0 = Stationary Mode

May take a few goes to set it.

[email protected]:~ $ sudo ./gpsControl -s -d /dev/ttyAMA0
Set GPS for stationary mode
Configuring device /dev/ttyAMA0
>>>>>>>>>>>>>>>>>>>>> SENDING >>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> SENDING >>>>>>>>>>>>>>>
GPS mode set OK

Static IP + Hostname

If you want to fix your LAN IP you do it by amending /etc/dhcpcd.conf adding the following lines:

interface eth0
static ip_address=192.168.1.7/24
static routers=192.168.1.254
static domain_name_servers=8.8.8.8 8.8.4.4

Amend your hostname by editing /etc/hostname and then adding this to /etc/hosts as well. I.e if you call your machine ‘eleanor’ add this after localhost in /etc/hosts:

127.0.0.1 localhost eleanor

Further Reading

David Taylor’s website here http://satsignal.eu/ntp/Raspberry-Pi-NTP.html goes into much further detail about the process above and covers graphing, remote access monitoring etc and I highly recommend you read it.

References from this draft document by Eric S. Raymond https://www.ntpsec.org/white-papers/stratum-1-microserver-howto/

Hope this helps, let me know how you get on with these instructions and I’ll try keep them up to date.

Thanks to:

David Taylor
Dave Akerman
Chris Stenton for the new kernel fix.
Tris Mabbs for the DHCP issue heads up.
Michiel Kanis for testing DHCP fix.
Phil Heron for the GPSD Autostart fix.

Updated : 27/06/17 Fixed for new June 2017 Raspbian. Updated links to ntp-4.2.8p10.
Updated : 25/05/16 Fixed for Pi3/May Raspbian. Removed Standalone mode (NTP isn’t designed for this)
Updated : 22/03/16 Added Pi3/Standalone etc
Updated : 24/02/16 Added Code to set stationary mode.
Checked : 29/09/15 Works with Raspian Jessie – Thx Ciaran!
Updated : 03/07/15 NTP version and location amended – Thx Greg!
Checked : 13/06/15 Works with 2015-05-05-raspbian-wheezy.img
Updated : 13/04/15 ntp-4.2.8p2.tar.gz links updated.
Updated : 23/02/15 Verified these instructions are good with 2015-02-16-raspbian-wheezy.img as a base
Updated : 20/02/15 ntp-4.2.8p1.tar.gz links updated.
Updated : 28/01/15 DHCP Client can pick up NTP from DHCP server and override all your good work. See below.
Updated : 27/01/15 New kernel breaks previous instructions. Updated.
Updated : 26/12/14 Updated NTP to 4.2.8 and tested with Raspbian 2014-12-14

Leave a comment ?

188 Comments.

  1. @Claudio, of course has also the kernel 4.9 PPS support.

    Linux jumper 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux
    grep PPS linux/.config
    # PPS support
    CONFIG_PPS=m
    # CONFIG_PPS_DEBUG is not set
    # PPS clients support
    # CONFIG_PPS_CLIENT_KTIMER is not set
    CONFIG_PPS_CLIENT_LDISC=m
    CONFIG_PPS_CLIENT_GPIO=m
    # PPS generators support

  2. Greg Siemon

    @Spacerat Yes the kernel supports PPS but Claudio was asking about “kernel mode”. My previous post had instructions to enable it (by recompiling the kernel) for Kernel 4.4. Kernel 4.9 has changed a couple of things and I have now worked out how to enable “kernel mode”.

    @Claudio
    My earlier instructions are still correct but one more things needs to be done in the Timer subsystem when running “make menuconfig”. There is a section under General Setup – Timers Subsystem called Time tick handling (Idle dynticks system (tickless idle)). Periodic timer ticks (constant rate, no dynticks) needs to be selected to be able to see and enable PPS Kernel Consumer Support.

  3. Just started this yesterday, downloaded the rasbian jessie form June, and get the following errors while following the guide:

    ./configure –enable-lcap
    configure: WARNING: you should use –build, –host, –target
    configure: WARNING: invalid host type: –enable-lcap
    checking for a BSD-compatible install… /usr/bin/install -c
    checking whether build environment is sane… yes
    checking for a thread-safe mkdir -p… /bin/mkdir -p
    checking for gawk… no
    checking for mawk… mawk
    checking whether make sets $(MAKE)… yes
    checking whether make supports nested variables… yes
    checking whether make supports nested variables… (cached) yes
    checking build system type… Invalid configuration `–enable-lcap’: machine `–enable’ not recognized
    configure: error: /bin/bash sntp/libevent/build-aux/config.sub –enable-lcap failed

    If I switch it to “./configure -enable-linuxcaps” configure seems to run through, but on make it locks up the pi.

    Any thoughts?

  4. Running the configure as specified in the ntp readme got it working and compiling

    http://www.linuxfromscratch.org/blfs/view/cvs/basicnet/ntp.html

    ./configure CFLAGS=”-O2 -g -fPIC” \
    –prefix=/usr \
    –bindir=/usr/sbin \
    –sysconfdir=/etc \
    –enable-linuxcaps \
    –with-lineeditlibs=readline \
    –docdir=/usr/share/doc/ntp-4.2.8p10 &&
    make

  5. Frank de Graaf

    @Joel: it’s a matter of the way the text is formatted. the single dash is actually — (minusminus)

  6. Hi Greg and Eric,
    While compiling the Kernel, is there have any issue with the Pi version (Rpi-2,Rpi-3) or with the version of Raspbian (Jessie Lite, Jessie Desktop), please?
    Previously i successfully compiled the kernel with Rpi-3, Jessie Desktop. But while I am switching to Rpi-2 with Jessie Lite, I am getting Make Error:2.

    The overall make output is here:

    https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=189742

    Any suggestion, please?

  7. Dustin Marquess

    I agree with Steve Moorby’s comment. Use the NMEA driver and NOT another NTP server (although I’d add another NTP server and flag it with “noselect” just to monitor things). No recompiling needing, and only one server/fudge line is needed.

  8. Dana Dawson

    Just as an FYI for other who may be curious, I was just successful in getting NTP working on a RPi 3 with the recent Stretch Lite version of Raspian (“2017-08-16-raspbian-stretch-lite”) by following these instructions almost exactly. I did have to do a “sudo apt-get install ntp” on my Pi, since Stretch Lite didn’t seem to include it and my first attempt didn’t work. I then modified my install according to instructions by Mark Martinec (first comment post by Anthony) and got the stand-alone NMEA one-driver mode working. The only issue I have yet to resolve is that the udev mod to create the symlinks in /dev doesn’t work, so I have to create them manually after a reboot. Here are my stats after about 17 hours of uptime:

    
    [email protected]:~$ 
    [email protected]:~$ ntpq -p
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    oGPS_NMEA(0)     .GPS.            0 l    1   16  377    0.000    0.000   0.001
    [email protected]:~$ 
    [email protected]:~$ 
    [email protected]:~$ ntpq -c rv
    associd=0 status=0418 leap_none, sync_uhf_radio, 1 event, no_sys_peer,
    version="ntpd [email protected] Sat Aug 26 00:08:54 UTC 2017 (1)",
    processor="armv7l", system="Linux/4.9.41-v7+", leap=00, stratum=1,
    precision=-20, rootdelay=0.000, rootdisp=1.090, refid=GPS,
    reftime=dd4c6fac.1f74d035  Sat, Aug 26 2017 17:07:40.122,
    clock=dd4c6fb2.1fae9b55  Sat, Aug 26 2017 17:07:46.123, peer=9998, tc=4,
    mintc=3, offset=-0.000291, frequency=-4.345, sys_jitter=0.001215,
    clk_jitter=0.002, clk_wander=0.000
    [email protected]:~$ 
    

  9. Thanks for this! I followed the instructions and I’m up and running.

    However, Dropbox gives a file not found error for the gpsControl.c file listed in the stationary mode section. Is the file available elsewhere?

  10. Dana Dawson

    UPDATE: MY problem with the udev mod to automatically create the symlinks in /dev for the gps devices was caused by smart quotes in the text file instead of the basic ASCII double-quote character. Fixing that fixed the udev issue.

    I’m now having trouble getting ntpd to sync to the GPS clock source, but I’m still looking into that issue.

  11. Dana Dawson

    I’m now getting the same “leap_alarm” status as Alex is/was seeing, and I’ve not been able to find anything that might explain the cause. Also, the “gpsmon” utility has stopped working, though the output from “ppstest” still looks good. I’ll keep digging, but for now I think I’m stuck and I’m tempted to wipe the Pi and just start completely over.

  12. Dana I’m about to embark on the same journey you are on.

    I have a specific deadline and a specific event that I need my project for complete and operational, so I will be following you and will do what I can to help you and hopefully you helping me at the same time.

    I don’t yet know how to leave my email address for you but as soon as I figure that out I will, as well as posting my results here as this is where the original inspiration for my project came from….

    Thanks to you Anthony and the other contributors here….!!!

  13. Anthony I reread your earlier response to my question, and am starting over again with the newest Raspbian (Stretch), and I am also adding a RTC module:

    https://www.newegg.com/Product/Product.aspx?Item=9SIA7BF34D9011&cm_re=10pcs_DS3231_Precision_RTC_Module_Memory_Module_for_Raspberry_Pi_Arduino-_-9SIA7BF34D9011-_-Product

    IF POSSIBLE to have a redundant backup, the new GPS module seen here:

    https://v3.airspy.us/product/upu-ublox-m8q3a-sma/

    I am not sure how to go about integrating the two or if it is even possible but 10 of those RTC’s came out to be only a little over $1 each USD. so no harm if not usable. But any advise you can add would be greatly appreciated indeed….!!!

  14. The Project Director email address on the contact page of our website will get you directly in-touch with me….you can click on my name above to reach our website….thank you all….

  15. Have I made some type of comment blunder that has resulted in my comments/questions being removed, if so please advise so that I may address any issues. I have a very serious project that I am embarking on that will be displayed in front of some very important and significant persons in the world of motor-sports. and I would like to be successful.

    I am hoping with the help of everyone here that I can be.

    Please do not ban me.

    Alan Scott

  16. Chill 🙂 Comments are moderated and i’ve been out all day 🙂 I know someone who has used an RTC module in combination with my board. They use I2C so should happily work with the GPS board.

  17. I am following this recipe for building the GPS – 1PPS disciplined time server:
    http://ava.upuaut.net/?p=726

    I am using an RPI 3 B+ and the latest Kasparian (Stretch) distro

    This GPS Board:
    https://v3.airspy.us/product-tag/gps/page/2/

    I also have purchased a bunch (10 actually) of these RTC’s, as a redundant backup to the GPS system as the new PI’s don’t have an internal RTC
    https://www.newegg.com/Product/Product.aspx?Item=2A7-00BD-00B48

    Additionally, I have a differential pressure switch that detects the puff of air when the car drives over the air hose that needs to be connected.

    I actually have a couple questions now that I think about it:

    1. How to I incorporate the RTC OVER the GPS card, do I use super long pins
    (btw thank you for the ones you provided) but I have four (4) of these units to build
    so a trip to FRYS seems inevitable……LOL I don’t really want it to be a 3 layer PI.

    Or is adding the RTC using an elephant gun to kill a mosquito……?

    2. The differential pressure switch is in a separate housing so it will have just 2 wires to attach to the PI…….where & how…?

    3. Will I have to load some type of lib or something to make it work….(don’t have the exact sensor model with me right now)

    4. If my reading of the instructions for the time server are correct one of the first things
    you are instructed to do is kill all serial coms…for the GPS card.

    5. Doesn’t #4 above kind of kill all the rest after the GPS – PPS…….? There are 40 GPIO pins there do ALL of them really need to be
    Killed so 5 of them can run a GPS receiver….?

    6. Basically, how the hell do I put this damn thing together,

    I have all the parts, at least almost all of them…
    A semi firm grasp on Linux itself….
    OK, it could be better maybe but I pretty much get Linux at least…
    I have a decent soldering station at home.
    Paul is 3D Printing me custom PI cases with a recess in the lid for solar powered rechargeable battery pack….(new this week)
    The “debut” of the system is the first of NOV at the race in Mesquite NV.
    The time stamping recording and GUI software is 98% written and tested.

  18. Dana Dawson

    I’ve got things back working now. Here’s a summary of what I did:

    First, I grabbed the latest version of Raspian Stretch Lite, which was “2017-09-07-raspbian-stretch-lite.zip”, and installed it on my SD card. I also added an empty “ssh” file to the “/boot” directory of that SD card to enable immediate SSH access to the RPi on first boot. I then followed all the basic instructions as described in the main article, with the addition of doing a “sudo apt-get install ntp”, since Stretch Lite doesn’t seem to include it.

    When I got to the section on “Verifying PPS Is Working” my output was slightly different and didn’t mention the “/dev/ttyAMA0” device:

    
    [email protected]:~$ dmesg | egrep pps
    [    3.668512] pps_core: LinuxPPS API ver. 1 registered
    [    3.668530] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
    [    3.677134] pps pps0: new PPS source pps.-1
    [    3.677239] pps pps0: Registered IRQ 184 as PPS source
    [email protected]:~$ 
    

    The output of “sudo ppstest /dev/pps0” looked fine, though, so I continued on with the configuration process.

    In the “Enabling PPS/ATOM Support in NTPD” section, I downloaded the ntp source by simply prepending a “wget” in front of the URL, like this:
    wget https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p10.tar.gz

    which worked just fine. The “./configure” step, however, didn’t seem happy with any of the options I tried, so I just did a simple “./configure” with no options at all. All the other commands worked just fine.

    Since I knew I wanted to run this in standalone mode as described by Mark Martinec, I did not make the “Add” and “Amend” changes to “/etc/ntp.conf”, but instead added these lines as described by Mark:

    
    # NMEA /dev/gps0, /dev/gpspps0, RMC, 9600
    server 127.127.20.0 mode 17 minpoll 4 maxpoll 4 prefer
    fudge 127.127.20.0 flag1 1 flag3 0 time2 0.115
    

    I also commented out all the “pool.ntp.org” lines, and added a “restrict” line for my local LAN just to be explicit (I don’t think I needed that, since the existing restrict lines are probably fine). Here’s the line I added in case anyone’s curious:

    restrict 172.31.254.0 mask 255.255.255.0 nomodify notrap

    At this point I was still following the instructions in Mark’s first post, and I created a new “/etc/udev/rules.d/55-ntp-gps.rules” file with these two lines:

    
    SUBSYSTEM=="tty", KERNEL=="ttyAMA0", SYMLINK+="gps0"
    SUBSYSTEM=="pps", KERNEL=="pps0", SYMLINK+="gpspps0"
    

    As I mentioned previously, the reason this didn’t work before was that I copy/pasted the lines from the web page, but that changed the basic ASCII straight double-quotes to some sort of smart quotes, which the udev process didn’t like. From my digging into the details of how udev works, I simplified the lines in Mark’s post to those shown above and they seem to be working fine.

    I was now back to the main instructions, and I made the specified changes to “/etc/init.d/ntp” along with the subsequent two “sudo” command to reload/restart things.

    After several minutes my “ntpq -p” output looked like this, which seemed positive:

    
    [email protected]:~$  ntpq -p
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    oGPS_NMEA(0)     .GPS.            0 l    2   16  377    0.000    0.000   0.002
    [email protected]:~$ 
    

    At some point in this process I also modified “/etc/dhcpcd.conf” and “/etc/hosts” as described to configure a static IP address, which also worked just fine, though I did notice that with the newer version of Stretch Lite the interface name is back to being simply “eth0” instead of the previous name that included the hardware MAC address of the interface. I did not bother with the steps under “Setting Stationary Mode”, since I was trying to minimize the changes I made.

    So, things seem to be working fine now, and my “ntpq -crv” output currently looks like this:

    
    [email protected]:~$ ntpq -crv
    associd=0 status=0415 leap_none, sync_uhf_radio, 1 event, clock_sync,
    version="ntpd [email protected] Wed Sep 27 21:55:30 UTC 2017 (1)",
    processor="armv7l", system="Linux/4.9.41-v7+", leap=00, stratum=1,
    precision=-20, rootdelay=0.000, rootdisp=1.075, refid=GPS,
    reftime=dd77e908.59d8dc4d  Thu, Sep 28 2017 16:32:56.350,
    clock=dd77e90d.ef0d3dfe  Thu, Sep 28 2017 16:33:01.933, peer=16811, tc=4,
    mintc=3, offset=-0.000116, frequency=-4.392, sys_jitter=0.000954,
    clk_jitter=0.001, clk_wander=0.000
    [email protected]:~$ 
    

    I’m going to resist any urges that might come over me to do any software updates in the hope that it’ll stay reliably available, but I guess I’ll find out. I’ll try to follow up here with any updates that seem useful, or to check for any questions anyone might have.

  19. Tom Dilatush

    I had some trouble with the code suggested here for setting stationary mode, I think related to the fact that my setup is on a Raspberry Pi 3 running Jessie. I fixed the problem by writing my own slightly more specialized program to set the GPS in stationary mode and to save the configuration. I made no attempt to generalize the code – it assumes the serial port settings, and that the serial port is “serial0”. Anyone else who might be having trouble with the stationary mode setting, please feel free to download the code, compile it, and hopefully it will reward you with successfully setting stationary mode and saving the resulting configuration!

  20. @ Dana Dawson

    Although your NEMA source appears stabilized with low jitter and offset, I question if your source is giving you the correct time. Check it against other public time servers for verification by either adding pool us.pool.ntp.org noselect or checking your system time against a manual query: [email protected]:~$ ntpdate -q us.pool.ntp.org.

    I suspect that you have sync’d your system time to your NEMA source which is off by at least 500ms to more than 1000ms.

    Here is my attempt at your setup (I am not using kernel mode PPS):

    
    [email protected]:~ $ sudo ntpq -pw
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    oGPS_NMEA(0)     .GPS.            0 l   12   16  377    0.000    0.000   0.004
    
    [email protected]:~ $ ntpdate -qv us.pool.ntp.org
    24 Oct 21:59:10 ntpdate[32706]: ntpdate [email protected] Sun Oct 22 17:46:33 UTC 2017 (2)
    server 66.85.74.226, stratum 2, offset 1.001754, delay 0.08554
    server 45.79.109.111, stratum 2, offset 1.002203, delay 0.06090
    server 69.61.82.106, stratum 2, offset 0.999959, delay 0.11128
    server 45.79.111.114, stratum 2, offset 1.001766, delay 0.04811
    24 Oct 21:59:16 ntpdate[32706]: step time server 45.79.111.114 offset 1.001766 sec
    

    I think for this reason, some may suggest not using the NEMA Type 20 driver, but rely on PPS Type 22 along with other public servers instead. Or I’ve seen the case for manually offsetting the NEMA source by a large amount by adjusting time2 by a larger amount.

  21. Dana Dawson

    @xycmu

    I ran that command and this is what I got:

    
    [email protected]:~$ ntpdate -qv us.pool.ntp.org
     1 Nov 18:21:30 ntpdate[24996]: ntpdate [email protected] Wed Sep 27 21:55:35 UTC 2017 (1)
    server 204.11.201.12, stratum 2, offset -0.002582, delay 0.07967
    server 108.59.2.24, stratum 2, offset 0.006258, delay 0.06361
    server 108.61.73.244, stratum 2, offset -0.001094, delay 0.05481
    server 208.88.126.235, stratum 2, offset -0.005778, delay 0.07410
     1 Nov 18:21:37 ntpdate[24996]: adjust time server 108.61.73.244 offset -0.001094 sec
    [email protected]:~$ 
    

    I don’t know how good the numbers should be, but these don’t look too bad.

  22. Dana Dawson

    I’ve been checking the results of the “ntpdate -q” command periodically over the past couple days and my results are always in line with those in my previous post. Here are my latest, to a larger number of ntp.org servers:

    [email protected]:~$ for n in `seq 0 3`; do ntpdate -q $n.pool.ntp.org; ntpdate -q $n.us.pool.ntp.org; done | egrep ntpdate
    3 Nov 12:59:21 ntpdate[20585]: adjust time server 97.127.8.173 offset -0.000182 sec
    3 Nov 12:59:28 ntpdate[20597]: adjust time server 23.92.29.245 offset -0.000914 sec
    3 Nov 12:59:35 ntpdate[20598]: adjust time server 192.111.144.114 offset 0.002325 sec
    3 Nov 12:59:41 ntpdate[20599]: adjust time server 69.89.207.99 offset -0.000152 sec
    3 Nov 12:59:49 ntpdate[20600]: adjust time server 4.53.160.75 offset -0.002405 sec
    3 Nov 12:59:56 ntpdate[20611]: adjust time server 204.9.54.119 offset -0.000196 sec
    3 Nov 13:00:03 ntpdate[20612]: adjust time server 38.229.71.1 offset -0.000576 sec
    3 Nov 13:00:10 ntpdate[20613]: adjust time server 152.2.133.54 offset 0.001285 sec
    [email protected]:~$ </code.

  23. Tom Dilatush

    I’ve made a much better program for configuring the U-Blox GPS. I’ve made it publicly available in source form, on GitHub. I was able to use it to complete all the recommended configurations to maximize time accuracy (they’re fairly complicated). You can find the code here.

  24. Hi Tom,
    How exactly your development works? There are no installation/use guide. A step by step guide is essential otherwise there are too many files to deal with.

  25. Hi,
    i had just two small questions … to put my gps-hat to stationary-mode, i’ve used the source code from https://gist.github.com/LebedevRI/20019255686c7cb1b578 (the original dropbox-link isn’t working anymore).

    Should i put the gps-hat to stationary mode every reboot?

    After compiling the kernel with “PPS Kernel Consumer Support“, i’ve recompiled ntpsec and i’ve only got:

    
    status=0115 leap_none, sync_pps, 1 event, clock_sync,
    version="ntpd ntpsec-1.0.1+201 2017-12-29T08:23:09Z", processor="armv7l", system="Linux/4.9.73-v7+", leap=00, stratum=1, precision=-19, rootdelay=0.0,
    rootdisp=1.135, refid=KPPS, reftime=ddf8d6f9.4da23cba 2018-01-04T16:38:17.303Z, clock=ddf8d703.2befe5c9 2018-01-04T16:38:27.171Z, peer=54759, tc=4, mintc=0,
    offset=0.02635, frequency=-2.636063, sys_jitter=0.008864, clk_jitter=0.89201, clk_wander=0.006121, tai=37, leapsec="2017-01-01T00:00Z",
    expire="2018-06-28T00:00Z“
    

    Did somebody had tried kernel mode pps with ntpsec?

    My kernel-config:

    
    # PPS support
    CONFIG_PPS=m
    # CONFIG_PPS_DEBUG is not set
    CONFIG_NTP_PPS=y
    # PPS clients support
    # CONFIG_PPS_CLIENT_KTIMER is not set
    CONFIG_PPS_CLIENT_LDISC=m
    CONFIG_PPS_CLIENT_GPIO=m
    # PPS generators support
    
    CONFIG_HZ_PERIODIC=y
    # CONFIG_NO_HZ_IDLE is not set
    # CONFIG_NO_HZ_FULL is not set
    CONFIG_NO_HZ=y
    CONFIG_HZ_FIXED=0
    CONFIG_HZ_100=y
    # CONFIG_HZ_200 is not set
    # CONFIG_HZ_250 is not set
    # CONFIG_HZ_300 is not set
    # CONFIG_HZ_500 is not set
    # CONFIG_HZ_1000 is not set
    CONFIG_HZ=100
    

  26. Hi – for a second time (sorry ;-),

    the question about the kernel and kernel-mode-pps could be ignored. It’s working now – i’ve just forgotten „flag3 1“ in my ntp.conf.

    But after reading a lot of documents from ntpd and ntpsec, i’ve found two different opinions about this mode. To shorten up … on http://www.ntp.org/ntpfaq/NTP-s-algo-kernel.htm#AEN2266 you can read, that there is no reason not to use it. On the ntpsec-homepage https://docs.ntpsec.org/latest/driver_pps.html you can read, “As the result, performance with minpoll configured at 4 (16s) is generally better than the kernel PPS discipline.“. 😕

    Should i really use it or not – i’m not really sure : 😐

  27. https://pastebin.com/YTc9Nd3D <- Code for GPS Control.
    Sorry Dropbox broke all my links.

  28. Charles Muggen

    @Scott Alan Terner
    You say “I am using an RPI 3 B+ and the latest Kasparian (Stretch) distro.”
    What the hell is Kasparian?
    Any luck getting this thing to work?

  29. When I get to the step
    dmesg | grep pps

    I get the following results which don’t quite match the results you posted.
    Did I miss a step?
    Or is it okay to proceed?

    [ 4.252195] pps_core: LinuxPPS API ver. 1 registered
    [ 4.252210] pps_core: Software ver. 5.3.6 – Copyright 2005-2007 Rodolfo Giometti
    [ 4.278132] pps pps0: new PPS source pps.-1
    [ 4.278260] pps pps0: Registered IRQ 184 as PPS source

    Results for pptest /dev/pps0 are listed below.

    trying PPS source “/dev/pps0”
    found PPS source “/dev/pps0”
    ok, found 1 source(s), now start fetching data…
    source 0 – assert 1516929908.001946554, sequence: 1014 – clear 0.000000000, sequence: 0
    source 0 – assert 1516929909.001941962, sequence: 1015 – clear 0.000000000, sequence: 0

  30. I downloaded Raspbian Stretch Lite onto a new micro SD card and got a fresh start on a new Raspberry Pi Model 3 B ver 1.2

    I got to page 6 of 19 on your NTP server procedure…

    I punched in the command:
    sudo service ntp restart

    and it said
    Failed to restart ntp.service: Unit ntp.service not found.

    I’m stuck.
    What to do next?

  31. That sounds like you’ve not got NTP installed ?

  32. The latest raspbian doesnt have ntp by default (it uses systemd-timesycd instead). If anyone is stuck, run the following three commands directly after “sudo systemctl mask [email protected]“.

    sudo systemctl disable systemd-timedated
    sudo systemctl mask systemd-timedated
    sudo apt-get -y install ntp

    Then continue with the rest of the instructions.

    Also there is a newer version of ntp available. Which is ntp-4.2.8p11 (instead of ntp-4.2.8p10 as used in the article). So in the “Enabling PPS/ATOM Support in NTPD” section, you can simply replace any mention of p10 with p11 in the first three commands (wget, tar, cd).

  33. Kevin Smith

    After following the above recipe I used the command dmesg | grep pps I get this output below

    [email protected]:~ $ dmesg | grep pps
    [ 2.605321] pps_core: LinuxPPS API ver. 1 registered
    [ 2.605334] pps_core: Software ver. 5.3.6 – Copyright 2005-2007 Rodolfo Giometti
    [ 2.614514] pps pps0: new PPS source pps.-1
    [ 2.614595] pps pps0: Registered IRQ 184 as PPS source
    [email protected]:~ $

    The lines below are missing. Should they be missing ????

    [ 6.965166] pps_ldisc: PPS line discipline registered
    [ 6.966569] pps pps1: new PPS source ttyAMA0
    [ 6.966664] pps pps1: source “/dev/ttyAMA0” added

    Also when the command ntpq -p is issued I get the following output below— I dont think this is correct advice wanted

    [email protected]:~ $ ntpq –p
    Name or service not known
    ntpq>

    there will be a few more question later as I work through the issues I have
    Kevin

  34. @kevin

    Did you follow my modifications to the original article, or just the original article?

    It seems ntp hasnt started on your system, or isnt installed. The “sudo apt-get -y install ntp” line I posted above shouldve installed it. Later in the original instuctions the “sudo service restart ntp restart” line shouldve started it at the appropriate time.

    Can you try the following two lines -:

    sudo systemctl enable ntpd.service
    sudo service ntp restart

    And see how you go. If it seems ntp isnt installed at this point. Do “sudo apt-get -y install ntp”. Then re-follow the instructions under the “Enabling PPS/ATOM Support in NTPD” section, right through to where it asks you to do “ntpq –p”.

    Let us know how you go, and if you have any further issues.

  35. Kipton Moravec

    Thank you for the instructions. Am a novice with Linux, I know enough to screw it up pretty bad.

    I started with the 2018-03-18-stretch-lite image.

    I followed the instructions line by line, and the “sudo apt-get install pps-tools” did not work. It could not find the package. So I did a “sudo apt-get update” and tried again and it worked, so I was able to continue.

    I had read that ntp was not in the latest version somewhere else. So when I got to the line “sudo service ntp stop” I knew that would not work, but it made me think it probably needs the other files like configuration files that are loaded when it is installed. So I installed it with “sudo apt-get install ntp” then continued with the stop.

    It was not until I was finished did I find the other things in the comments to do. So I did them last, like shutting down the other time service which is now the default for raspbian. You need to put those instructions in the main part of the webpage. I do not normally read the comments unless I have problems.

    Today I see there was a new release of raspbian 2018-04-18…

    I am a little confused about the “server 0.debian.pool.ntp.org iburst prefer” in mine it was “pool 0.debian.pool.ntp.org iburst prefer”

    Is that right or did I screw up? There are no server lines in the file.

    The ntpq -p is a little confusing. before I rebooted there were a number time servers besides the 0.debian.pool.n .POOL. but it looks like the pool ones are not connected as the delay and offset are 0 and jitter is 0.001.

    After rebooting the xbefore the PPS(0) went away.

    I think it is not working after reboot.

  36. Kipton Moravec

    Looking at the comment before my previous comment. I tried
    sudo systemctl enable ntpd.service

    And the message “Failed to enable unit: File ntpd.service: no such file or directory”

    so I tried “sudo apt-get -y install ntp” and it says I already have the latest version.

    now I am stuck. It looks like the pps is working.

    This appeared to be working until I rebooted.

    I made the mods to be a static IP address with the host name “kipstimeserver” and the router changed the IP address to the static one, but is still calling it “raspberrypi”.

    One last try before I go to bed. I went back to ntp.config removed the prefer from the pool command, and added
    server 0.us.pool.ntp.org iburst prefer
    server 1.us.pool.ntp.org iburst
    server 2.us.pool.ntp.org iburst
    server 3.us.pool.ntp.org iburst
    server 192.168.1.1 iburst

    The last one is my Verison/Frontier router which I think is also a time server.

    Looking at ntpq -p it looks like the pools got nothing.
    there is activity on the PPS(0) (but no x like when I first started.) And the us.pool.ntp.org servers are translated to four different names as expected. But it looks like no communication is with them. It calls my router a stratum 1 router. The pps(0) is a stratum 0, and the other 8 lines are all inactive and stratum 16.

    I do not know what is going on. I am about ready to scrap it and start from scratch with the newer release and newer ntp code. I had 10 like the documentation, and not 11 like in the comments.

  37. Kipton Moravec

    I think it is working.

    However I cannot get your program to work.

    [email protected]:~ $ sudo ./gpsControl -s -d /dev/ttyAMA0
    Set GPS for stationary mode
    Configuring device /dev/ttyAMA0
    >>>>>>>>>>>>>>>>>>>>> SENDING >>>>>>>>>>>>>>>

    And there it sits. the program looks like it should try 5 times, but it does not appear to try a second time. Even if I wait 35 minutes.

    I have tried it with NTP service running and with NTP service stopped.

    Your instructions say “May take a few goes to set it.” I do not have a clue what that means.

    Do I try it over and over and over again?
    How long should I wait?
    Why does it not try again?
    Does the NTP service have to be stopped or running?

    You are not giving me much to go on.

    Kip

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Human test : * Time limit is exhausted. Please reload CAPTCHA.