NTP Server using Raspberry Pi and VP Oncore GPS Module – Part 4

Devices and Device Links

As we shall see later the Reference Clock driver in NTP needs to see the Oncore Serial I/O and Oncore PPS signals on specific device names and these are not yet configured by the kernel we downloaded.  In particular the device /dev/ttyAMA0 is currently bound to the UART and the /dev/pps0 device is bound to a rising edge on GPIO Pin 18. (And the Rasberry console I/O has been inhibited so the UART is free for our exclusive use).

Creating symbolic links in /dev will work but they do not survive a reboot so the best approach is to create a udev rule file as follows…

root@ntpi:/# cat /etc/udev/rules.d/50-oncore.rules
KERNEL=="ttyAMA0",SYMLINK+="oncore.serial.0"
KERNEL=="pps0",OWNER="root",GROUP="tty",MODE="0777",SYMLINK+="oncore.pps.0"
root@ntpi:/#

And then restart the Raspberry PI with a reboot command. (Resist the temptation to cycle the power on the PI as this often ends in SD card corruption; use reboot and shutdown -h now where appropriate to avoid disaster).

Finally we should have…

root@ntpi:/# ls -1 /dev | grep oncore
oncore.pps.0
oncore.serial.0

Configure NTPd

The NTPd supplied with the kernel we downloaded from openchaos.org has been built including the Oncore reference clock so configuration is pretty easy now.

Configure the server in /etc/ntpd.conf to include the reference clock driver. (Note that the 127.127.x.y addresses are magic numbers to tell NTPd to use a reference clock… see the NTP documentation for details)

# VP Oncore
server 127.127.30.0 prefer

server ntp1.ptb.de prefer  # another stable preferred peer

server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst

Create a ONCORE specific configuration file /etc/ntp.oncore

root@ntpi:/# cat /etc/ntp.oncore
MODE 1

LAT 51.0
LONG -0.3
HTGPS 10.0 M

SHMEM /var/adm/ntpstats/ONCORE

(Create the directory /var/adm/ntpstats and make it world writable by ntp if using SHMEM status)

Get NTP running again by /etc/init.d/ntp restart

Wait for everything to settle (may take hours if the receiver has no Almanac), ensure good visibility for the GPS antenna to get a good timing solution and then check that all is working…

root@ntpi:/# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 GPS_ONCORE(0)   .GPS.            0 l    -   16    0    0.000    0.000   0.000
 ptbtime1.ptb.de .PTB.            1 u   30   64    3   36.530   -0.707   0.691
+stratum2-3.NTP. 129.70.130.71    2 u   25   64    3   35.616   -0.969   4.477
+stratum2-3.NTP. 129.70.130.70    2 u   26   64    3   34.654   -1.434   2.231
*clock2.infonet. .PPS.            1 u   23   64    3   58.767   -4.061   4.464
-ntp.univ-angers 145.238.203.14   2 u   26   64    3   46.173   -3.868   3.988
root@ntpi:/#

… you can track progress by watching /var/log/daemon.log (which is where the NTP log info ends up) and after a while….

pi@ntpi ~ $ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*GPS_ONCORE(0)   .GPS.            0 l    1   16  377    0.000   -0.001   0.003
+ptbtime1.ptb.de .PTB.            1 u   34   64  377   36.019   -1.340   6.205
+stratum2-3.NTP. 129.70.130.70    2 u   12   64  377   34.453   -1.166   1.222
+stratum2-3.NTP. 129.70.130.70    2 u   62   64  377   34.526   -1.193   0.178
-clock2.infonet. .PPS.            1 u   54   64  377   59.021   -4.390   2.726
-ntp.univ-angers 145.238.203.14   2 u   48   64  377   44.575   -7.638   0.406
pi@ntpi ~ $

We have a GPS Accurate NTP Server!

Part 5

Advertisements

About nivagswerdna

Professional Geek
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to NTP Server using Raspberry Pi and VP Oncore GPS Module – Part 4

  1. Pingback: NTP Server using Raspberry Pi and VP Oncore GPS Module – Part 3 | aardvarklabs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s