THIS ARTICLE HAS BEEN DEPRECIATED AND INSTRUCTIONS CONTAINED BELOW NO LONGER WORK WITH LATEST RASPBIAN. HOWEVER GOOD NEWS – ITS MUCH EASIER NOW SEE HERE:
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.
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).
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
@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
@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.
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?
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
@Joel: it’s a matter of the way the text is formatted. the single dash is actually — (minusminus)
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?
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.
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:
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?
https://www.dropbox.com/s/eaycedsmb2o9kn0/gpsControl.c?dl=0
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.
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.
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….!!!
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….!!!
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….
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
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.
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 RTCs, as a redundant backup to the GPS system as the new PIs dont 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 dont 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 .(dont 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. Doesnt #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.
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:
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:
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:
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:
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:
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.
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!
@ 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:pi@piClock:~$ 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):
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.
@xycmu
I ran that command and this is what I got:
I don’t know how good the numbers should be, but these don’t look too bad.
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:
pi@pi-ntp:~$ 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
pi@pi-ntp:~$ </code.
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.
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.
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:
Did somebody had tried kernel mode pps with ntpsec?
My kernel-config:
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 : 😐
https://pastebin.com/YTc9Nd3D <- Code for GPS Control.
Sorry Dropbox broke all my links.
@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?
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
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?
That sounds like you’ve not got NTP installed ?
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).
After following the above recipe I used the command dmesg | grep pps I get this output below
pi@stratum1:~ $ 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
pi@stratum1:~ $
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
pi@stratum1:~ $ 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
@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.
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.
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.
I think it is working.
However I cannot get your program to work.
pi@timekeeper:~ $ 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
https://www.ntpsec.org/white-papers/stratum-1-microserver-howto/
here is a link for getting a HAB GPS Board to work with Stretch. An excellent and simple guide. only a few commands to execute with the help of clockmaker script.
use
./clockmaker –config
to start and follow the rest with the page’s instructions.
Question: If you setup the RPi as a stand alone source using the NMEA config as Anthony suggested, does cpgs -s stop working?
I’m running into a minor (maybe) issue with setting my RPi up as a fully functioning and disconnected NTP source/server. I followed all of the build instructions and am using ntp p11 and all appears to be somewhat functioning. The symptom that I see is that ntpq -pcrv sometimes shows:
and then later it changes to
So it seems to work and then goes to unreliable status for both the NMEA and PPS sources. But, the output still shows it using the PPS(0) as the reference source and when I look at barney, he says he is getting a reliable – at least most of the time, time sync from .210 which is the RPi:
Also, as I asked before, when you setup the system to use NMEA and create the symlinks, does that stop gpsmon and cgps from functioning? If so, is there a way to keep those or to at least use them? Maybe a different device ID or switch?
Thanks!!
When entering “sudo cp /usr/local/bin/ntp* /usr/bin/ && sudo cp /usr/local/sbin/ntp* /usr/sbin/” I am getting the error: “cp: cannot stat /usr/local/bin/ntp*: No such file or directory”. Please help.
Just in case anybody is interested, ran into a bit of a snag on my Pi 3 running NTPSEC. It seems that when they updated the kernel to 3.14 they took the option for kernel synced time keeping out of the menuconfig menu. I had previously used the 4.5 kernel via git that was at the top of this blog, but when I tried to use it (with everything else updated to new software) it hung when trying to start up USB. I futzed about with it and finally started trying different kernels. 4.9 (stable) doesn’t have the option, but 4.7 does. It compiled fine and doesn’t seem to have the usb hang issue I had previously. Not sure if it keeps time any differently, but in case you’re trying to build an ntp server with new software, thought you might like to know.
Has anyone got updated step by step instructions because I just cant get this damn thing to work, almost feel like giving up and throwing this Raspberry in the bin
https://ava.upuaut.net/?p=951