FreeBSD 14 USB 6M - BYO-NTP/recipes GitHub Wiki

date server os gnss daemon 🎯 🗣️
2025-06 Chuwi Larkbox X
Raspberry Pi 4
Raspberry Pi 5
FreeBSD
14
u-blox NEO-6M chrony
NTPsec
ntp
19 µs link

1. Install OS

FreeBSD install instructions for Pi4, Pi 5, or Larkbox

There's also a Bill of Materials and assembly instructions below.

2. Program the NEO-6M

Connect the serial pins to a USB adapter (see photo) and connect to a Windows computer that has u-blox u-center installed. Configure your device per recommendations on the gnss page.

3. Configure USB

Plug the USB adapter into the FreeBSD server and a few lines of text should emit to the console, dmesg, and /var/log/messages:

dmesg | grep -i ftdi
ugen1.7: <FTDI FT232R USB UART> at usbus1
uftdi0 on uhub2
uftdi0: <FTDI FT232R USB UART, class 0/0, rev 2.00/6.00, addr 6> on usbus1

FreeBSD has recognized the USB adapter and ucom has connected the serial port to the system.

Get some data from it (Control-C to disconnect):

stty -f /dev/cuaU0 raw 115200 cs8 clocal -cstopb
cat /dev/cuaU0
$GPRMC,145934.00,A,4746.15234,N,12219.54351,W,0.056,,050625,,*09
$GPZDA,145934.00,05,06,2025,00,00*6E
$GPRMC,145935.00,A,4746.15237,N,12219.54346,W,0.056,,050625,,*0D
$GPZDA,145935.00,05,06,2025,00,00*6F
$GPRMC,145936.00,A,4746.15241,N,12219.54341,W,0.058,,050625,,*06
$GPZDA,145936.00,05,06,2025,00,00*6C
^C

It works!

The NTP daemons look to /dev/gps0 by default, so link gps0 to the serial port using devfs:

test -L /dev/gps0 && rm /dev/gps0
grep -q gps0 /etc/devfs.conf && sed -i '' -e 's/^link.*gps0$//g' /etc/devfs.conf
echo 'link	cuaU0	gps0' >> /etc/devfs.conf
service devfs restart

4. Configure PPS

Enable PPS on the UART CTS pin (to match the wiring, see ucom for details):

sysctl hw.usb.ucom.pps_mode=1
sysrc -f /boot/loader.conf hw.usb.ucom.pps_mode=1

Create /dev/pps0 for the NTP daemons using devfs links:

grep -q pps0 /etc/devfs.conf && sed -i '' -e 's/^link.*pps0$//g' /etc/devfs.conf
cat >> /etc/devfs.conf <<EOL
link	cuaU0	pps0
link	cuaU0	gpspps0
EOL
service devfs restart

5. Install a NTP daemon

Each section heading is a link with many more details about installing, configuring, and verifying that particular NTP daemon.

export NTP_REFCLOCKS=$(cat <<EO_CHRONY
refclock SHM 0         refid NMEA precision 0.02 poll 4 offset 0.074 trust
refclock PPS /dev/pps0 refid PPS  precision 4e-7 poll 2 offset 0.1 lock NMEA
EO_CHRONY
)
curl -sS https://byo-ntp.github.io/tools/chrony/install.sh | sh

NTPsec's NMEA+PPS has a pathological case when the GPS fix is lost and PPS drops. The accuracy then is worse than using only the NMEA source. Increasing the poll frequency as shown improves it but the gpsd driver handles that case much better.

NTPsec gpsd, pi5

export NTP_REFCLOCKS=$(cat <<EO_NTPSEC
refclock gpsd unit 0   refid NMEA minpoll 3 maxpoll 4 time2 0.068
refclock gpsd unit 128 refid PPS  minpoll 1 maxpoll 2 time1 0.000004 flag1 1 prefer
EO_NTPSEC
)
curl -sS https://byo-ntp.github.io/tools/ntpsec/install.sh | sh

NTPsec gpsd, Larkbox

export NTP_REFCLOCKS=$(cat <<EO_NTPSEC
refclock gpsd minpoll 1 maxpoll 3 time2 0.061 mode 1 prefer
EO_NTPSEC
)
curl -sS https://byo-ntp.github.io/tools/ntpsec/install.sh | sh

NTPsec nmea

export NTP_REFCLOCKS=$(cat <<EO_NTPSEC
refclock nmea refid NMEA minpoll 4 maxpoll 5 time2 0.073 prefer mode 8 baud 115200
refclock pps  refid PPS  minpoll 3 maxpoll 5 time1 0.1   prefer
EO_NTPSEC
)
curl -sS https://byo-ntp.github.io/tools/ntpsec/install.sh | sh
export NTP_REFCLOCKS=$(cat <<EO_NTP
server 127.127.20.0 minpoll 4 maxpoll 5 mode 88 prefer
fudge  127.127.20.0 refid NMEA time2 0.073 minjitter 0.03

server 127.127.22.0 minpoll 3 maxpoll 5
fudge  127.127.22.0 refid PPS time1 0.1 minjitter 0.005
EO_NTP
)
curl -sS https://byo-ntp.github.io/tools/ntp/install.sh | sh

Observe

  • watch the status in near real time (requires installing gnu-watch):
    • printf '\e[8;9;80t'; ssh -t pi5 gnu-watch -n2 chronyc sources
    • printf '\e[8;9;80t'; ssh -t pi5 gnu-watch -n2 ntpq -c peer
  • Measure the offset
  • Gather statistics with telegraf + influxdb + grafana or similar.

References

Bill of Materials

Item Vendor(s) Cost
USB NEO 6M module AliExpress $6
USB to TTL Serial adapter Amzn $12
Active GPS Antenna Amzn $11
F-F Breadboard Jumper wires Amzn $7
Total $36

Assembly

Since modern mini PCs have no serial ports, add one with a USB to TTL serial adapter.

There's a flood of the USB to TTL serial adapters available for ~ $15. Most will work with FreeBSD if they have a FTDI or Silicon Labs USB chip. See the wiki page in the references section above for more. Sadly, they are all USB 2.0. A USB 3.0 chip could decrease the USB latency.

NEO-6M-assembly

Performance

Chrony

NTPsec

ntp

⚠️ **GitHub.com Fallback** ⚠️