Whitham D. Reeve 1. Introduction This document describes the installation and operation of the GpsNtp-Pi time server using the Raspberry Pi computer platform, a GPS receiver and the Network Time Protocol (NTP). An accompanying document, GPS Network Time Server on Raspberry Pi: GpsNtp-Pi {GpsNtp-Pi}, provides a general description. The system may operate as a standalone time server or in conjunction with external time servers and is used to synchronize PC real-time clocks to Coordinated Universal Time (figure 1).
2. Hardware Assembly This project was developed on an unmodified Raspberry Pi model B+. It most likely will work on the model B but has not been tested. The RPi is operated “headless”; that is, it is used without a directly connected keyboard, mouse or monitor.
Page 5
Preliminary assembly: Prior to attaching the GPS daughterboard to the RPi board: Do not insert the battery until instructed Adafruit GPS board: Solder the 20x2 connector to the bottom of the PCB. Test fit the connector and when soldering, make sure the connector is flush to the board ...
Page 6
Power Supply: Before connecting a 5 V power supply, read this first: DO NOT attempt to power GpsNtp-Pi using a USB port on a desktop or laptop PC or handheld device. Power measurements of GpsNtp-Pi on the RPi model B+ showed < 1.5 W average dc load. However, when the RPi is booting and depending on connected peripherals, the measured load current can be >...
3. Operating System Installation The system uses the Raspbian distribution, which is a version of Linux. It is necessary to download and install the distribution image and install it on a memory card in a format that is compatible with the RPi. It is not possible to simply copy the distribution image from a Windows PC to a memory card;...
Page 10
At this time you will be returned to the Win32 Disk Imager user interface. Click the Write button. After a moment the Progress bar will show the Write operation, which requires several minutes. Be patient. When the Write process finishes, a Success window will pop up. Eject the memory card by right-clicking the drive letter in My Computer or Explorer and selecting Eject.
Page 11
{WLAN}. However, it is expected that the jitter performance will be much worse when the time server is operated over a wireless connection. This caution would apply both when the GpsNtp-Pi uses a server pool for synchronization and when an NTP client on a PC accesses the GpsNtp-Pi for synchronization.
You can determine the RPi’s IP address from your router LAN status screen or by using a program like Netscan {Netscan}. Enter a name for the session (example, GpsNtp-Pi) in the Saved Sessions field. You also can customize the user interface by clicking on the various entries in the Category window but you can do this later. Click the Save button to save the session settings.
Page 13
In the next section, you will change the default password. You will need the new password to log into RPi for all setup and provisioning activities. Note: If it becomes necessary to remove power from the RPi, the RPi must be properly shutdown before removing power (just like a Windows PC).
(current) UNIX password: Enter the current (default) password (the default Raspberry Pi password is “raspberry” without quotes). No characters will be displayed. Enter the new password (the default GpsNtp-Pi password is “GpsNtp-Pi” without quotes) and confirm it when RPi responds with:...
Page 15
Enter the following command at the prompt. After a moment a window will appear with a list of settings. Use the arrow keys to select the desired option, press Tab to Select and then Enter: sudo raspi-config Select Option 1. Expand filesystem ...
Page 16
After initial setup: sudo reboot Now it is necessary to update the software and operating system. These steps may require several minutes: sudo apt-get update sudo apt-get dist-upgrade sudo rpi-update sudo reboot See last page for copyright and document info, File: Reeve_GpsNtp-Pi_Setup.doc, Page 14...
6. Install and Verify Pulse Per Second ~ PPS Install software to support PPS: sudo apt-get install pps-tools sudo apt-get install libcap-dev Configure the RPi to use the general purpose input/output (GPIO) for the PPS input from the GPS receiver: sudo nano /boot/config.txt Add a new line as shown below.
Page 18
Type CTRL-X (Exit), Y (yes), Enter to save and close the editor, and then reboot: sudo reboot After reboot, log into the RPi and check that the module is loaded: lsmod | grep pps The output should be similar to: pps_gpio 2529 1 pps_core 7943 2 pps_gpio To determine if PPS is working, first ensure the GPS receiver is in the satellite tracking mode.
Page 19
Also, check: sudo ppstest /dev/pps0 If the PPS software module is working, output should be similar to shown below with the source 0 lines scrolling 1 line/s. Press CTRL-C to quit: See last page for copyright and document info, File: Reeve_GpsNtp-Pi_Setup.doc, Page 17...
7. Install GPS Daemon and Associated Tools Install GPSD and GPSD-Clients: sudo apt-get install gpsd gpsd-clients After installation, configure GPSD: Sudo dpkg-reconfigure gpsd Follow the prompts to: Start gpsd automatically: Automatically handle USB devices: Assign GPS device: /dev/ttyAMA0 (trailing zero not “O”) ...
Page 21
After GPSD has been configured, reboot: sudo reboot See last page for copyright and document info, File: Reeve_GpsNtp-Pi_Setup.doc, Page 19...
Page 22
Log into the RPi and test the GPS receiver time and position data output. Before running the next command, set the PuTTY window to 80 columns x 30 rows (in PuTTY Change Settings... – Window). To quit the GPS monitor, press CTRL-C: gpsmon The upper part of the console display will remain fixed while the enclosed data updates automatically.
8. Enable PPS Support in NTP Daemon The NTP daemon supplied with the Raspbian distribution for the RPi does not natively support PPS so it needs to be recompiled. To recompile ntp, first check http://archive.ntp.org/ntp4/ for the latest production version of NTP. If different than shown below, modify the strings accordingly.
Page 24
Next, scroll down to the list of four servers labeled server 0.debian..., server 1.debian... and so on. Delete the four servers (or comment them out with the # character). Now, enter the NTP server pool closest to your country; see {NTPPool}. The United States NTP server pool is shown here.
Page 25
Restart the NTP service: sudo service ntp restart After a few minutes run NTP Query (all query command options are defined in {NTPQ}: ntpq –p The * in the first column of the first line indicates the shared memory GPSD reference clock is being used. The o in the first column of the second line indicates the kernel-mode PPS source is selected and being used.
Page 26
/var/log/ntpstats/ This directory includes two log files, loopstats and peerstats. Right-click the file and select Open. For a description of the log data go to {NTPLog}. Driver fudge factors in ntp.conf: The following provides additional information on a few fudge factors. The fudge factor for the shared memory driver (.28) discussed above uses the flag1 and time1 parameters.
Page 27
It should not be necessary to reconfigure the NTP configuration file, ntp.conf, but the file should be checked anyway. Be sure to backup the memory card before updating and upgrading. Using NTP v4.2.8p9 and later may not work with the Raspbian Wheezy operating system on the RPi B+ but additional experimentation is necessary.
9. Leap seconds Download the most recent leap-second file from one of the following sources and place it on your Desktop. These files have an expiration date so always download the latest one. The filename will be of the form leap- seconds.3629404800, where the number string will vary.
Page 29
See last page for copyright and document info, File: Reeve_GpsNtp-Pi_Setup.doc, Page 27...
10. Final Adjustments and Checks The convergence time constant of the RPi NTP server is about 1 h. Thus, assuming the GPS receiver has a fix, the server achieves close to 0 ms offset of the PPS reference clock in a couple hours. The offset can be followed as it changes by repeatedly using the ntpq commands described above.
Page 31
After installation, setup the NTP client to use the IP address of the RPi NTP server. For example, the SymmTime setup is shown below for a GpsNtp-Pi lab system with IP address 10.0.0.32. In this case, I clicked Add Server in the Sync Servers window (left), specified the lab system IP address and then removed all other servers from the upper frame with the down-arrow between the frames.
(peering is beyond the scope of this project but information can be found at {NTPOrg}). A pool of external servers is accessed by the GpsNtp-Pi NTP server through an internet connection and access to them is enabled by uncommenting the pool statement in the ntp.conf file: pool us.pool.ntp.org iburst minpoll 6 prefer...
Page 33
Note: If you plan to add your RPi NTP server to the pool, you should not use the *.pool.ntp.org alias in the NTP configuration as described above. Instead, time servers should be hand-picked from good nearby (network- wise) servers. See {NTPJoin} for additional information. See last page for copyright and document info, File: Reeve_GpsNtp-Pi_Setup.doc, Page 31...
Need help?
Do you have a question about the GpsNtp-Pi and is the answer not in the manual?
Questions and answers