Building a GPS-disciplined PTP grandmaster from a Raspberry Pi CM4 and SR1723U10 GPS module. Part 1 of the homelab PTP series.
I work with industrial infrastructure that requires nanosecond-accurate time synchronization. The commercial GPS-disciplined PTP grandmaster clocks that solve this problem run from several thousand dollars on the low end, and considerably more with options and support. I had CM4s and CM4 IO boards already sitting in the lab. A TimeHAT with an OCP M.2 GNSS module would have been the cleaner path at around $400, but that is steep when the goal is learning how PTP actually works, not deploying production infrastructure. This build came in at around $103 in new parts.
This post documents what I built, what broke, what I had to fix, and the results I measured.
What is PTP and why does it matter#
Time precision is a spectrum:
Unit What it is Example Uses 1 second (s) The tick of a clock Human scheduling, cron jobs 1 millisecond (ms) 1 second split into 1,000 pieces Web browsing, video streaming, log timestamps 1 microsecond (µs) 1 second split into 1,000,000 pieces High-frequency trading, audio/video sync, distributed databases 1 nanosecond (ns) 1 second split into 1,000,000,000 pieces Aerospace instrumentation, industrial automation, scientific data acquisition, this build
NTP is good enough for web servers, databases, authentication systems, and anything where you need to know when something happened but don’t need to coordinate hardware events across machines. Over a LAN with a good reference, NTP can reach low microseconds. Over the WAN it typically lands in the low milliseconds. The ceiling is the network path jitter between client and server, every variable delay adds noise to the offset estimate.
PTP (Precision Time Protocol, IEEE 1588) handles the nanosecond tier. With hardware timestamping at the Ethernet PHY layer, PTP can synchronize clocks to within tens of nanoseconds on a local network. The grandmaster clock is the root time source. It takes GPS-disciplined time and distributes it to clients via the PTP protocol.
A nanosecond is the time it takes light to travel about 30 centimeters (roughly 1 foot). After this build, the clocks on my homelab nodes were off from GPS truth by the time it takes light to travel across a room.
Component Notes Cost Raspberry Pi CM4 (8GB/32GB eMMC) Already owned N/A CM4 IO Board Already owned N/A SR1723U10 GPS module u-blox M10 based ~$15 JEFA Tech U.FL to SMA pigtail For antenna connection ~$8 Bingfu GPS antenna Active, SMA ~$12 MOOKEERF SMA cables Various lengths ~$10 Waveshare CM4 IO Board case 1U aluminum ~$25 ELEGOO Dupont jumper wire kit For wiring ~$8 M2.5 standoff kit Mounting hardware ~$8 12V 2A power supply For IO board ~$12 CR2032 battery For onboard RTC ~$5 Total (new parts) ~$103
... continue reading