BeagleBone Black as a NTP server using GPS as a time source.
This project is to share my experience using a BeagleBone Black to obtain time from a GPS and then sharing time with other computers on a local network. There are many stale posts about this topic, so here is a fresh take to throw on the pile. I am writing this during May, 2022 for the BeagleBone Black (Revision C) using AM3358 Debian 10.3 2020-04-06 4GB SD IoT
The deployment domain is a network of single board computers in a mobile application. Little computers have terrible clock drift, so an external source was a priority. I also needed location (because, mobile) so a GPS was mandatory.
- Purchase a GPS receiver w/PPS output (probably not a USB device)
- Flash a BeagleBone Black w/a fresh image
- Install software packages
- Configure GPS and PPS
- Configure time server
Implementation follows, there is certainly room for substitution.
I purchased several inexpensive USB GPS receivers via Amazon, which all delivered location data but would not drive ntpd(8), because they lacked a PPS output.
This GPS Receiver was my solution (w/a powered antenna).
I used a Digilent Digital Discovery to verify the GPS receiver was healthy.
- apt-get install gps
- apt-get install gpsd-clients
- apt-get install pps-tools
- apt-get install ntp
The GPS receiver will write ASCII messages to BeagleBone UART1, and send a sync pulse to GPIO_60. gpsd(8) will readily accept the UART messages, but the pps driver will require some extra work.
Header | Pin | Name | Description |
---|---|---|---|
P9 | 1 | DGND | Ground |
P9 | 7 | SYS_5V | GPS VIN |
P9 | 12 | GPIO_60 | GPS PPP |
P9 | 24 | UART1_TXD | GPS RX |
P9 | 26 | UART1_RXD | GPS TX |
-
Copy gpsd.default to /etc/default/gpsd
-
Start gpsd(8) by invoking
systemctl restart gpsd.service
- For reasons, pps will require you to install a device overlay.
- git clone https://github.com/RobertCNelson/bb.org-overlays.git
- Copy BB-UART1-GPS-00A0.dts to bb.org-overlays/src/arm
- Install the overlays by invoking bb.org-overlays/install.sh
- Update /boot/uEnv.txt to reference the new overlay
- Reboot
- Test for PPS success
- gpsmon(1) will demonstrate you have pps working
- ntpshmmon(1) will also verify gpsd using PPS
For my application, there are not internet connected time servers to consult. I want time exclusively from the GPS receiver.
- Copy ntpd.conf to /etc/default/ntpd.conf
- Restart ntpd(8) by invoking
systemctl restart ntpd.service
- Verify ntpd(8) by invoking
systemctl status ntpd.service
- Verify ntpd(8) is reading via shared memory/PPS
- Remove external network connectivity
- Disable gpsd via systemctl
systemctl stop gpsd.service
- Set a bogus date
date 042708002020
- Restart gpsd
systemctl restart gpsd.service
- Observe the time eventually become current