Not quite 5 minute guide to making an NTP Server

THIS ARTICLE HAS BEEN DEPRECIATED AND INSTRUCTIONS CONTAINED BELOW NO LONGER WORK WITH LATEST RASPBIAN. HOWEVER GOOD NEWS – ITS MUCH EASIER NOW SEE HERE:

https://ava.upuaut.net/?p=951

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.

pi@hypatia:~ $ 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 ?

196 Comments.

  1. Eric Dittman

    The only deviations I had from the original article and first comment were using Jessy Lite, ntp-4.2.8p4, and altering the udev rule, all mentioned in my first comment, then changing back to using NMEA and PPS separately with flag3 set to 1.

  2. Richard Tector

    Hi – the SHM(0) entry is pulling from gpsd.

    The clock is disciplined to PPS – it’s just reliably ~3.2 msec out.

    
    driftfile /var/lib/ntp/ntp.drift
    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
    
    server 127.127.28.0 minpoll 4 maxpoll 4 prefer
    fudge 127.127.28.0 time1 +0.105 flag1 1 refid GPS stratum 14
    
    server 127.127.22.0 minpoll 4 maxpoll 4
    fudge 127.127.22.0  flag3 1  refid PPS
    

  3. Hi Richard,

    The time via serial is going to be a little out and shouild be fudged, possibly by more than the 0.105s you have. See http://satsignal.eu/ntp/Raspberry-Pi-NTP.html the section :

    Converting from USB to native serial – software changes

    Take out the :

    server 127.127.28.0 minpoll 4 maxpoll 4 prefer
    fudge 127.127.28.0 time1 +0.105 flag1 1 refid GPS stratum 14

    Bit entirely as a test. I think its something to do with the whole serial data delaying the time.

    Cheers

  4. Eric Dittman

    My microSD card got corrupted and I couldn’t recover so I had to start from scratch. After completing the new install the RPi 2 completely died. Fortunately when it died it didn’t take the new build with it.

    I didn’t have my configuration saved so I’m going through the process to find out what offset to use.

  5. Hi folks,
    great experience here- Anthony does a magnificient job. Got my gps board today and started fiddling with it right when I got home. Can confirm that Raspbian Jessie Light works perfectly. Jessie does no longer need the sudo rpi-update directive, and it does not accept it. The latest (as of Jan 28 2016) ntp-4.2.8p6 works as intended. I encountered the same problem as Eric – /dev/gps0 showed up only after I dropped the KERNELS==”dev:f1″ parameter from my udev file.
    Now enjoying stratum 0,
    /|/|artin

  6. System ran uninterrupted for more than a day now. I feel better after I issued the sudo apt-mark hold ntp command – I compiled ntp myself, it is now my own obligation to take care of its updates.
    I’m a bit suprised by the nptq readings:

    
    user@raspi-gps:~ $ ntpq -4pw
         remote         refid      st t when poll reach   delay   offset  jitter
    ============================================================================
    *GPS_NMEA(0)     .GPS.          0 l    8   16  377    0.000    5.271   7.615
    +ptbtime1.ptb.de .PTB.          1 u    2   64  377   35.080   -5.292   2.306
    -net2.uni-paderborn.de
                     .DCF.          1 u   38   64  377   35.917   -4.364   1.197
    -zeit.fu-berlin.de
                     .PPS.          1 u   34   64  377   37.617   -6.016   2.592
    +ntp2.tp.pl      .ATOM.         1 u   36   64  377   62.102   -1.844   2.281
    -public.streikt.net
                     192.53.103.104 2 u   64   64  377   32.987   -4.544   1.494
    -net1.uni-paderborn.de
                     131.234.137.64 2 u   28   64  377   36.281   -5.933   2.242
    

    What bugs me is the fact that the local gps offset is at >5 msec, while all other time sources report an offset around -5 msec. Other systems in my network don’t accept this system as their primary time source, even at being stratum 1. Can I do anything about this? Where do I start? I don’t even know how to search for a solution …

  7. GPS via NMEA will always be out due to the latency in the serial connection. You can fudge it. I notice you’re not using local PPS via the board. Can you post a link to your ntpd.conf ? (Upload it to pastebin then paste the link here). I suspect if you have only the GPS_NMEA and then discipline it (set prefer in ntpd.conf) with the PPS your local machines will then use this. I.e remove the internet ones.

    Cheers,

    Anthonyt

  8. Sorry, the intended link was my ntp.conf
    I’m still learning …

  9. If you’re using internet time servers and just using PPS to dicipline those just remove the GPS clock part. Oddly the GPS clock isn’t that accurate.

    However you’re not using PPS at all as far as I can tell. Add the following:

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

  10. Ok, removed GPS clock reference and annded yout two (original) lines. It works, refid is .PPS. now.
    Did I get this right: If my internet connection is lost, my ntpd stops working? That would not be the setup I’m trying to achieve…

  11. Eric Dittman

    Has anyone figured out how to compile ntp 4.2.8p6 and have it work with pps?

  12. Very helpful information, thank you for sharing!

    I did run in to one issue with automatically creating soft links via the suggested rules file.

    SUBSYSTEM==”tty”, KERNEL==”ttyAMA0″, KERNELS==”dev:f1″,
    SYMLINK+=”gps0″

    That didn’t work for me, but after changing to the following everything is OK

    55-ntp-gps.rules, with contents like:

    SUBSYSTEM==”tty”, KERNEL==”ttyAMA0″, SYMLINK+=”gps0″

    Not sure why, but at least it’s working now.

    Thanks!

  13. Hi Eric,

    I’m working on some instructions I have to do it. I’ll document this shortly.

    Anthony

  14. How do you send commands to the GPS eg to tell it that it is stationary etc?

  15. Download this to the Pi : gpsControl.c

    Compile + link:

    gcc -o gpsControl gpsControl.c

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

    May take a few goes to set it.

    pi@hypatia:~ $ ./gpsControl -s -d /dev/ttyAMA0
    Set GPS for stationary mode
    Configuring device /dev/ttyAMA0
    >>>>>>>>>>>>>>>>>>>>> SENDING >>>>>>>>>>>>>>>
    >>>>>>>>>>>>>>>>>>>>> SENDING >>>>>>>>>>>>>>>
    GPS mode set OK

  16. I found that I had to make the following mondifications to get gpsd to work on my B+ running Jessie:

    sudo nano /etc/default/gpsd

    START_DAEMON=”true”
    GPSD_OPTIONS=”n”
    DEVICES=”/dev/ttyAMA0″
    USBAUTO=”false”
    GPSD_SOCET=”/var/run/gpsd.sock”

    without these changes it would fault.

  17. gpsControl links to gpsControl.c on the dropbox.
    I’m not sharp enough to figure out where to look for the zip file, but i think some stuff I need to compile is missing.

  18. Typo it was the .c file. Just get this and then compile it with gcc -o gpsControl gpsControl.c

  19. Anthony, Does gpsControl need to be run each time the system does a cold boot or is it a one time thing?

  20. Bob Geddes

    I have just updated my RPi 2B to the 2016-02-29 version of Jessie Lite with ntpd 4.2.8p6 – both Atom/PSS and NMEA are running well.
    I resolved my issues with dhcpcd interfering with my /etc/network/interfaces by adding the following to start of /etc/dhcpcd.conf

    I have never had any luck with udev and posted a work around earlier I have now resolved this with

  21. Bob Geddes

    I have just updated my RPi 2B to the 2016-02-29 version of Jessie Lite with ntpd 4.2.8p6 – both Atom/PSS and NMEA are running well.

    I resolved my issues with dhcpcd interfering with my /etc/network/interfaces by adding the following to start of /etc/dhcpcd.conf

    denyinterfaces * # stop dhcpcd interfereing with (static) config in /etc/network/interfaces
    timeout 1 # remove long reboot delay as dhcpcd searches for interfaces (introduced by above line)

    I have never had any luck with udev and posted a work around earlier, I have at last resolved this with:

    sudo nano /etc/udev/rules.d/55-ntp-gps.rules
    and add to the new file:
    KERNEL==”ttyAMA0″, SYMLINK+=”gps0″, GROUP=”dialout”

  22. It needs to be run each cold boot.

  23. From David Taylor :

    Both the “non-starting gpsd” on Jessie, and the “serial I/O broken” on the Raspberry Pi 3 are resolved, and details are on this page:
    http://www.satsignal.eu/ntp/Raspberry-Pi-quickstart.html#stand-alone

  24. David Rawling

    This guide covered almost everything, but I had to make one further change to the procedure to make it work on my specific build (RPi3 and HAB-GPSPI-NAN module v3.2b).

    gpsd attempts to negotiate and set the baud rate for communications. However, gpsd’s hunt loop throws the HAB-GPSPI-NAN module into a mode where the GPS (standalone) timestamps aren’t received – in fact, no NMEA sentences were.

    To fix this I added the “-b” parameter to the GPSD_OPTIONS configuration item in /etc/default/gpsd like so:

    # Other options you want to pass to gpsd
    GPSD_OPTIONS=”-n -b”

    This prevents gpsd attempting to set the baud rate and seems to permit the GPS to talk at 9600-8-N-1 as expected. It has now worked across multiple restarts, though I am yet to fully test cold starts.

  25. Eric Dittman

    Anthony, did you ever get a chance to write up the instructions to compile newer version of ntp that work with pps?

  26. Yep all updated to latest Jessie and Raspberry Pi 3.

  27. Eric Dittman

    When I recompile 4.2.8p6 it doesn’t work with pps. Can you share your binary?

  28. Hi Eric,

    I’ve tested this and it seems to work fine. Its hard to share the binaries (I think there are quite a few ?) and I want to avoid doing this anyway. Sure you didn’t miss a step ?

    Cheers

  29. Eric Dittman

    Anthony,

    I recompiled again following your instructions and I still have the error:

    29 Apr 22:51:33 ntpd[27889]: refclock_params: time_pps_kcbind: Operation not supported

    I do see the PPS clock but based on the above error I don’t think it’s working correctly:

    root@pi1:/var/log# ntpq -p
    remote refid st t when poll reach delay offset jitter
    ==============================================================================
    *GPS_NMEA(0) .GPS. 0 l 15 16 377 0.000 -10.168 1.866
    oPPS(0) .PPS. 0 l 14 16 377 0.000 0.101 0.379

  30. Eric Dittman

    Here’s what shows after a short time:

    root@pi1:/var/log# ntpq -p
    remote refid st t when poll reach delay offset jitter
    ==============================================================================
    xGPS_NMEA(0) .GPS. 0 l 2 16 377 0.000 -13.611 2.897
    xPPS(0) .PPS. 0 l 1 16 377 0.000 -2.730 2.341

  31. Whats the output of PPS test Eric ?

  32. Eric Dittman

    root@pi1:~# 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 1463112595.999976547, sequence: 1126392 – clear 0.000000000, sequence: 0
    source 0 – assert 1463112596.999976701, sequence: 1126393 – clear 0.000000000, sequence: 0
    source 0 – assert 1463112597.999975442, sequence: 1126394 – clear 0.000000000, sequence: 0
    source 0 – assert 1463112598.999974387, sequence: 1126395 – clear 0.000000000, sequence: 0
    source 0 – assert 1463112599.999976242, sequence: 1126396 – clear 0.000000000, sequence: 0

  33. So its just the NTP thats not compiled correctly or something. Can you start afresh and follow the instructions again as I tried it here and had no issues.

    Cheers

  34. Eric Dittman

    I have another NTP module on the way from you. When it arrives I’ll set it all up from scratch and see.

  35. First of all, please bear with me for my little understanding of the NTP, PPS/ATOM and GPS on Raspberry Pi 3 Model B with the HAB-GPSPI-NAN GPS module.

    If I may ask, what are the advantages and disadvantages of PPS/ATOM vs Standalone in using HAB-GPSPI-NAN GPS module on top of the Raspberry Pi 3 Model B?

    What will happen if the Raspberry Pi 3 Model B gets disconnected from the network if it is configured with PPS/ATOM?

    What is the stationary mode for?

    My objective is to have a NTP server that can provide an accurate time to all my devices from different VLANs.

    Below are output from BASH:

    # uname -r
    4.4.10-v7+

    # ntpd –version
    ntpd 4.2.6p5

    # dmesg | grep -i pps
    [ 2.800308] pps_core: LinuxPPS API ver. 1 registered
    [ 2.800311] pps_core: Software ver. 5.3.6 – Copyright 2005-2007 Rodolfo Giometti
    [ 2.825057] pps pps0: new PPS source pps.-1
    [ 2.827667] pps pps0: Registered IRQ 184 as PPS source
    [ 8.507759] pps_ldisc: PPS line discipline registered
    [ 8.509354] pps pps1: new PPS source ttyAMA0
    [ 8.509437] pps pps1: source “/dev/ttyAMA0” added

    # ntpq -p
    remote refid st t when poll reach delay offset jitter
    ==============================================================================
    xPPS(0) .PPS. 0 l 16 16 377 0.000 17.844 0.588
    x103-11-143-248. 179.43.76.147 2 u 67 64 377 1.668 20.580 1.091

    # ntpq -p
    remote refid st t when poll reach delay offset jitter
    ==============================================================================
    xPPS(0) .PPS. 0 l 10 16 377 0.000 -28.173 2.420
    x103-11-143-248. 179.43.76.147 2 u 30 64 377 1.684 -18.284 7.017

    # 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 1463720074.981791555, sequence: 3232 – clear 0.000000000, sequence: 0
    source 0 – assert 1463720075.981781524, sequence: 3233 – clear 0.000000000, sequence: 0
    source 0 – assert 1463720076.981772900, sequence: 3234 – clear 0.000000000, sequence: 0

    # cat /etc/ntp.conf

    driftfile /var/lib/ntp/ntp.drift
    server 127.127.22.0 minpoll 4 maxpoll 4
    fudge 127.127.22.0 flag3 1 refid PPS
    server 0.asia.pool.ntp.org iburst prefer
    restrict 127.0.0.1
    restrict ::1
    restrict 192.168.1.0 mask 255.255.255.0
    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

    # tail -n 3 /boot/config.txt
    enable_uart=0
    dtoverlay=pps-gpio,gpiopin=18,pi3-disable-bt
    force_turbo=1

    # tail -n 1 /etc/modules
    pps-gpio

    # cat /etc/modprobe.d/blacklist.conf
    blacklist brcmfmac
    blacklist brcmutil
    blacklist btbcm
    blacklist hci_uart

    # lsmod | grep -i pps
    pps_ldisc 1972 2
    pps_gpio 2655 1
    pps_core 6779 4 pps_ldisc,pps_gpio

    # grep -i gps /var/log/messages
    May 20 11:01:32 clock gpsd[624]: gpsd:ERROR: /dev/ttyAMA0 already opened by another process
    May 20 11:01:32 clock gpsd[624]: gpsd:ERROR: initial GPS device /dev/ttyAMA0 open failed

    # cgps -s
    ┌───────────────────────────────────────────┐┌─────────────────────────────────┐
    │ Time: n/a ││PRN: Elev: Azim: SNR: Used: │
    │ Latitude: n/a ││ │
    │ Longitude: n/a ││ │
    │ Altitude: n/a ││ │
    │ Speed: n/a ││ │
    │ Heading: n/a ││ │
    │ Climb: n/a ││ │
    │ Status: NO FIX (0 secs) ││ │
    │ Longitude Err: n/a ││ │
    │ Latitude Err: n/a ││ │
    │ Altitude Err: n/a ││ │
    │ Course Err: n/a ││ │
    │ Speed Err: n/a ││ │
    │ Time offset: n/a ││ │
    │ Grid Square: n/a ││ │
    └───────────────────────────────────────────┘└─────────────────────────────────┘

    What am I missing here to have a working NTP server having a near accurate timing?

    Thank you very much in advance!

  36. Chris Bussey

    Hi and thanks for the brilliant write-up.

    I have found two tiny bugs in the instructions………

    On an RPI3 the /boot/config.txt should be :-

    # Allow the normal UART pins to work
    dtoverlay=pi3-disable-bt

    not :-

    # Allow the normal UART pins to work
    dtoverlay=pi3-disable-bt-overlay

    Or at least that seems to be the case as of 19/05/16.

    Secondly, following the instructions to the letter (cut and paste everything), there is no /etc/ntpd.conf file, it is /etc/ntp.conf.

    To be fair I only found these as I am a total newbie so any deviation from the instructions stumps me.

    Cheers

  37. Greg Siemon

    Eric Dittman,

    You’ll see this error:

    refclock_params: time_pps_kcbind: Operation not supported

    when you try to tell ntp to use kernel mode by setting ‘flag3 1’ in your ntp.conf file. The standard Raspbian kernel doesn’t have pps support built in and needs to be recompiled to support it. If you set ‘flag3 0’ instead you won’t get that error anymore and ntp will happily work in user mode.

    Chris Bussey,

    In the past either of the dtoverlay statements would work. As of the latest Raspbian update (12 May or so) with kernel 4.4 only this works:

    dtoverlay=pi3-disable-bt

    Any overlay statements in /boot/config.txt must omit the -overlay at the end for the modules to load correctly.

    On some systems ntp installs as ntpd. On Raspbian the correct file is ntp.conf. That’s just a typo. Well done figuring it out.

  38. Eric Dittman

    Greg Siemon, I only get that error when I try to use a newer version of ntp.

  39. Eric Dittman

    Greg, I also think these steps are supposed to allow kernel mode PPS:

    sudo nano /boot/config.txt – Add dtoverlay=pps-gpio,gpiopin=18 on a new line. Save and Quit Nano.
    sudo nano /etc/modules – Add pps-gpio on a new line. Save and Quit Nano.

    Anthony, can you verify?

  40. I am working through the instructions again to verify they work (They don’t). The PPS bit works but the standalone config is currently not working. I’m liaising with people to work out a set of instructions that are known to work. It seems you don’t need pps-gpio in /etc/modules any more.

  41. Greg Siemon

    Eric,

    Sorry I should have been clearer. The standard kernel supports pps in user mode but not kernel mode. flag3 1 tries to turn on the kernel mode pps support. Since it isn’t baked into the kernel it spits out that error. I found this several months ago. If you set flag3 0 then you no longer get the error.

    Greg

  42. Now it’s getting worst. Previously, I was not seeing any NMEA data with the “cgps -s” command. Now, I am getting already an error with the “ppstest /dev/pps0” command.

    # uname -r
    4.4.11-v7+

    # dmesg | grep -i pps
    [ 3.169568] pps_core: LinuxPPS API ver. 1 registered
    [ 3.169573] pps_core: Software ver. 5.3.6 – Copyright 2005-2007 Rodolfo Giometti
    [ 3.179166] pps pps0: new PPS source pps.-1
    [ 3.181138] pps pps0: Registered IRQ 184 as PPS source
    [ 10.515992] pps_ldisc: PPS line discipline registered
    [ 10.516715] pps pps1: new PPS source ttyAMA0
    [ 10.516809] pps pps1: source “/dev/ttyAMA0” added

    # lsmod | grep -i pps
    pps_ldisc 1972 2
    pps_gpio 2655 1
    pps_core 6779 4 pps_ldisc,pps_gpio

    # ppstest /dev/pps0
    trying PPS source “/dev/pps0”
    found PPS source “/dev/pps0”
    ok, found 1 source(s), now start fetching data…
    time_pps_fetch() error -1 (Connection timed out)
    time_pps_fetch() error -1 (Connection timed out)

    # ntpd –version
    ntpd [email protected]-o Mon May 23 16:25:33 UTC 2016 (1)

    # grep -v ^# /boot/config.txt
    gpu_mem=4
    enable_uart=0
    dtoverlay=pps-gpio,gpiopin=18

    # grep -v ^# /etc/ntp.conf
    driftfile /var/lib/ntp/ntp.drift
    server ntpmon.dcs1.biz iburst prefer
    server 127.127.22.0 minpoll 4 maxpoll 4
    fudge 127.127.22.0 flag3 0 refid PPS
    server 127.127.28.0 minpoll 4 maxpoll 4 iburst prefer
    fudge 127.127.28.0 time1 +0.105 flag1 1 refid GPS stratum 1
    restrict 127.0.0.1
    restrict 10.80.0.0 mask 255.255.240.0
    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

  43. I’m able to get PPS for an internet time server, but my rPi doesn’t have a /dev/ttyAMA0 so I can’t do a standalone server which is what I am needing. I have followed the instructions to the letter and cannot figure out where I have done wrong.

    This is for a Raspberry Pi 2 B+, latest raspbian freshly installed.

    Anyone have any suggestions where to start looking.

  44. Latest update broke it. Working on fixes now…

  45. 
    sudo raspi-config
    Advanced Options -> Serial -> Would you like a login shell to be accessible over serial? -> Yes
    
    sudo nano /boot/config.txt
    Add at the bottom :
    # Allow the normal UART pins to work
    dtoverlay=pi3-miniuart-bt
    
    sudo systemctl disable hciuart
    sudo systemctl mask [email protected]
    Reboot
    

    That fixes serial port. Working on the NTP part now.

  46. Eric Dittman

    Greg, so what you are saying is pps_core and pps_gpio are user mode drivers. I was under the impression they were kernel mode drivers. Any idea why the ntpd compiled by John doesn’t give this error with flag3 set to 1?

  47. Eric Dittman

    On this website:

    https://support.ntp.org/bin/view/Sandbox/HowtoPpsOnRaspberryPi

    there’s mention that compiling the kernel with CONFIG_NO_HZ set to off improves accuracy. Has anyone tried it?

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.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Trackbacks and Pingbacks: