What is after the first 1. 2. 3. 4. steps ?
567.dk

Guides Info Upgraded image GPS sync NTP server DCF77 sync NTP server --- Usefull linux commands. --- MRTG setup. NTP test tools.

This is a guide for GPS sync NTP server



Created: 2016-08-18, on Raspbian Pi, Model B Revision 2.0 512MB
2016-10-14 Raspberry Pi 3 Model B notes: please look at bottom of page

Start with the step:
Upgraded image or download a complete image in the bottom of this page.

Login with ssh to the ip address of the pi
With "pi > raspberry"

Run the following commands

sudo bash

apt-get install pps-tools ## Need it later when enable GPS then you dont have to recompile NTP
apt-get install libcap-dev ## Need by NTP
apt-get install libssl-dev ## Need by NTP

nano /boot/config.txt - Add dtoverlay=pps-gpio,gpiopin=18 ## be avare what gpio you using some bords use pin 18
nano /etc/modules – Add pps-gpio on a new line
reboot

Login with ssh to the ip address of the pi

sudo bash

## Install newest version of ntp
## Here a guide for 4.2.8p8
## The newes version http://www.ntp.org/downloads.html

wget http://archive.ntp.org/ntp4/ntp-4.2/ntp-4.2.8p8.tar.gz ## or wget http://www.ntp.567.dk/software/ntp-4.2.8p8.tar.gz
tar zxvf ntp-4.2.8p8.tar.gz
cd ntp-4.2.8p8
./configure --enable-linuxcaps
make
make install
service ntp stop
cp /usr/local/bin/ntp* /usr/bin/ && cp /usr/local/sbin/ntp* /usr/sbin/
nano /etc/ntp.conf

# Add under # Local users may interrogate the ntp server more closely.
# Use you own networks

restrict 10.0.0.0 mask 255.255.255.0
restrict 192.168.1.0 mask 255.255.255.0
restrict 192.168.2.0 mask 255.255.255.0
restrict 92.246.24.228


service ntp start

/etc/init.d/ntp restart

## Wait 2 min - and verify that NTP is running

ntpq -p
ntpq -c rv localhost
ntpq -c rv [ipaddress of the pi]

## reach will count up to 377







nano /boot/cmdline.txt #remove console=serial0,115200
apt-get install gpsd gpsd-clients python-gps
nano /etc/default/gpsd

START_DAEMON="true"
USBAUTO="false"
DEVICES="/dev/ttyAMA0"
GPSD_OPTIONS="-n"
GPSD_SOCKET="/var/run/gpsd.sock"


In editing /etc/ntp.conf, add these lines:


server 127.127.22.0 minpoll 4 maxpoll 4
fudge 127.127.22.0 refid kPPS
server 127.127.28.0 minpoll 4 maxpoll 4 iburst prefer
fudge 127.127.28.0 time1 +0.135 flag1 1 refid GPSD stratum 1
server ntpimage.567.dk iburst perfer
leapfile /home/pi/ntp.567.dk/leap-seconds.list # Add in V1.1 - Leap second support

ln -s /lib/systemd/system/gpsd.service /etc/systemd/system/multi-user.target.wants/

nano /etc/crontab # Add lines

22 3 * * 1 root update-leap # Add in V1.1 - Leap second support
22 3 * * 2 root update-leap -s ftp://tycho.usno.navy.mil/pub/ntp/leap-seconds.list # Add in V1.1 - Leap second support
22 3 * * 3 root update-leap -s ftp://utcnist.colorado.edu/pub/leap-seconds.list # Add in V1.1 - Leap second support

service cron restart # Add in V1.1 - Leap second support
update-leap -s ftp://tycho.usno.navy.mil/pub/ntp/leap-seconds.list # Add in V1.1 - Leap second support

reboot

Login with ssh to the ip address of the pi

sudo bash

ntpq -c rv localhost
ntpq -c rv [ip address]

output like this:
root@raspberrypi:/home/pi# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
oPPS(0) .kPPS. 0 l 2 16 377 0.000 -0.622 0.457
*SHM(0) .GPSD. 1 l 2 16 377 0.000 10.746 107.682


Ofset will scrink after some hours.

ntpq -crv

Verify that leapsec is pressent.
associd=0 status=0615 leap_none, sync_ntp, 1 event, clock_sync,
version="ntpd 4.2.8p8@1.3265 Sun Aug 14 23:21:08 UTC 2016 (2)",
processor="armv6l", system="Linux/4.4.13+", leap=00, stratum=2,
precision=-19, rootdelay=0.594, rootdisp=31.299, refid=192.168.1.186,
reftime=db8f4a0d.11819dcb Fri, Sep 23 2016 6:28:29.068,
clock=db8f4fa3.ec671531 Fri, Sep 23 2016 6:52:19.923, peer=35104, tc=8,
mintc=3, offset=0.022990, frequency=-38.090, sys_jitter=0.064390,
clk_jitter=0.303, clk_wander=0.067, tai=36, leapsec=201701010000,
expire=201706280000



debug commands


cat /dev/ttyAMA0
cgps -s
service gpsd restartRestart the gpsd service - if down due to debug

Or you can download my image. My gps image from my server.(2016-08-18)

My gps image V1.0 with smtp / mrtg support from my server.(2016-08-19)

My gps image V1.1 with leapseconds / smtp / mrtg support from my server.(2016-09-29)


You can now install MRTG support se Tap MRTG.
Pi 3 Model B notes:

nano /boot/config.txt

# Enable Serial support RPI3
enable_uart=1


nano /etc/default/gpsd
DEVICES="/dev/ttyS0"

reboot