in Misc, Sysadmin

Stratum 1 NTP server with FreeBSD on Raspberry Pi.


Raspberry Pi 2 Model B
Adafruit Raspberry Pi Case
Adafruit Ultimate GPS Breakout
Adafruit Perma-Proto HAT
External antenna

Basic setup

# svnlite diff
Index: rpi2.dts
--- rpi2.dts	(revision 309114)
+++ rpi2.dts	(working copy)
@@ -337,6 +337,13 @@
 		broadcom,depth = ;		/* Set by VideoCore */
+ 	pps@0  {
+		compatible = "pps-gpio";
+		gpios = <&gpio 17 0>;
+		status = "okay";
+	};
 	leds {
 		compatible = "gpio-leds";

and then rebuilt the tree

# cd /usr/src/sys/tools/fdt
# setenv MACHINE arm
# cp rpi2.dtb /boot/msdos




gpiopps0:  on ofwbus0
gpiopps0: PPS input on gpio0 pin 17

Physical setup

Soldered proto hard

Soldered proto hard

GPS soldered to the proto hat

GPS soldered to the proto hat

Finished product:

NTP server

GPS configuration




NTP configuration









Please refer to the driver documentation for more settings:

# Allow traffic to external servers
restrict mask nomodify notrap noquery
restrict mask nomodify notrap noquery
restrict mask nomodify notrap noquery
restrict mask nomodify notrap noquery
restrict mask nomodify notrap noquery
restrict mask nomodify notrap noquery
restrict mask nomodify notrap noquery
restrict mask nomodify notrap noquery

# Allow traffic to internal servers
restrict mask nomodify notrap noquery
restrict mask nomodify notrap noquery

server flag3 0

server mode 17
fudge time2 +0.767

# Servers
server iburst  prefer
server iburst
server iburst
server iburst
server iburst
server iburst
server iburst
server iburst

driftfile /var/db/ntp.drift

# save ntp performance stats
statistics loopstats
statsdir /var/log/ntp/
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
filegen clockstats file clockstats type day enable

Running ntpd

root@ntp:/dev # ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter


Write a Comment


  1. Hi,
    thank you for this hack.I use a raspberry3 with FreeBSD 12.0. The basic setup is OK.
    and the modul gpiopps.ko is loaded. But I have no device gpiopps or boot messages about.

    with regards

      • I found my mistake in the rpi2.dts. The line with ” broadcom,depth = ; /* Set by VideoCore */ must be unchanged as”broadcom,depth = ; /* Set by VideoCore */”.

  2. Hey there, just a heads up – I’ve been running a Raspi NTP server for a couple of years, and after setting up ntpviz graphs recently, it became plainly clear how sensitive the gps clock crystal is to temperature variations. I use the already-built-out Adafruit GPS hat, which has the chip on the top of the HAT, rather than the bottom as you have. I’ve switched to a case that insulates the whole device, and I added a thin foam insulating pad to the bottom of the GPS board to slow the temp variations. You might consider doing that as well, depending upon how ‘OCD’ you are about having the most accurate time 🙂

    The case I used is the case that’s specifically designed for the adafruit gps hat, and the pads I got on amazon. I don’t like linking out to specific stuff, seems spammy, so to find the ones I got, search on “4in4in1/16in 20Pcs Foam Rubber Mats, Self Stick Weather Strip Non-slip Furniture Pads Black Neoprene Rubber Insulation 4 Inch Long X 4 Inch Wide X 1/16 Thickness “.

    Instead of roughly 8 to 10 deg C variation during the course of 24 hours, it now fluctuates only about 2 deg C.

    I’d link to my ntpviz graphs, but they look like crap due to all the changes i’ve been making over the last couple of days. Maybe I’ll post the link in a few days. 🙂

    • Hi! Thanks for your comments and suggestions.

      I have also noticed that its very sensitive to temperature changes and I have thought about a few things to fix it. One of the more invasive ones being to switch out the actual crystal on the chip: Switch out the X1 Oscillator on a RPI 2/3.

      Now I have basically just given up, its still a lot better than using npt servers on the internet.

      But thans for the tip with the rubber mats, I will definitely look into that.

      • Yeah, since I don’t have an external temperature sensor for the actual GPS hat board, I don’t really know for sure how much the rubber mat helps – but I have to assume that a closed-cell rubber foam would provide good insulation. At worst, it’ll smooth out the temperature spikes.

        By the way, have you considered running NTPsec?