Pi OS 12 USB - BYO-NTP/recipes GitHub Wiki
date | server | os | gnss | daemon | 🎯 | 🗣️ |
---|---|---|---|---|---|---|
2025-05 | Raspberry Pi 4 Raspberry Pi 5 |
Pi OS 12 |
Stratux VK-162 u-blox 7M |
chrony NTPsec ntp |
1 ms 6 ms 6 ms |
discuss |
Connect the GNSS to a USB port of a Windows computer with u-blox u-center installed. Configure per the recommendations on the gnss page.
Then plug the USB plug into your NTP server.
The VK-162 presents itself to the system via the cdc_acm driver, so look for that:
dmesg | grep cdc_acm | grep tty
[ 4.708559] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device
And there is the GPS unit, at ttyACM0
.
If the GNSS module is connected via a FTDI USB to TTL adapter, we can find it with this command:
dmesg | grep -i ftdi
[ 32.674365] usb 1-1.3: Manufacturer: FTDI
[ 32.708816] usbcore: registered new interface driver ftdi_sio
[ 32.708853] usbserial: USB Serial support registered for FTDI USB Serial Device
[ 32.708962] ftdi_sio 1-1.3:1.0: FTDI USB Serial Device converter detected
[ 32.711350] ftdi_sio ttyUSB0: Unable to read latency timer: -32
[ 32.712929] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB0
Now that we've found the TTY, export it so all the subsequent commands can find it:
export GNSS_TTY_DEVICE="ttyUSB0"
- create the
/dev/gps0
sysmlink - configure the USB serial port for low latency
apt install -y setserial
/bin/setserial /dev/$GNSS_TTY_DEVICE low_latency
cat > /etc/udev/rules.d/10-gps.rules <<EOL
KERNEL=="$GNSS_TTY_DEVICE", SYMLINK+="gps0", GROUP="dialout", MODE="0660"
KERNEL=="$GNSS_TTY_DEVICE", RUN+="/bin/setserial /dev/$GNSS_TTY_DEVICE low_latency"
EOL
udevadm control --reload-rules
udevadm trigger
The latency of each GNSS requires a custom offset in milliseconds. Export the GNSS specific offset from the table that matches your GNSS:
host | gnss | nmea | pps | gpsd |
---|---|---|---|---|
pi5 | u7 | 0.1 | 0.05 | |
pi4 | 7M | 0.05 | 0.1 | 0.05 |
export GNSS_OFFSET_NMEA=""
Exports a refclock config and then installs (if needed) and configures the NTP daemon.
export NTP_REFCLOCKS=$(cat <<EO_CHRONY
refclock SHM 0 refid NMEA poll 3 precision 3e-2 offset $GNSS_OFFSET_NMEA prefer
refclock SHM 1 refid PPS poll 2 precision 5e-6 offset 0.9 lock NMEA trust
refclock PPS /dev/pps1 refid PPS precision 4e-7 poll 2 lock NMEA trust
EO_CHRONY
)
curl -sS https://byo-ntp.github.io/tools/chrony/install.sh | sh
export NTP_REFCLOCKS=$(cat <<EO_NTPSEC
refclock nmea minpoll 3 maxpoll 6 time2 $GNSS_OFFSET_NMEA baud 115200
EO_NTPSEC
)
curl -sS https://byo-ntp.github.io/tools/ntpsec/install.sh | sh
or via gpsd with the shm driver:
export NTP_REFCLOCKS=$(cat <<EO_NTPSEC_GPSD
refclock shm unit 0 refid NMEA minpoll 3 maxpoll 4 time1 $GNSS_OFFSET_NMEA
refclock shm unit 2 refid PPS minpoll 1 maxpoll 2 prefer
EO_NTPSEC_GPSD
)
curl -sS https://byo-ntp.github.io/tools/ntpsec/install.sh | sh
export NTP_REFCLOCKS=$(cat <<EO_NTP
server 127.127.20.0 minpoll 3 maxpoll 4 mode 80
fudge 127.127.20.0 refid NMEA time2 0.052 minjitter 0.1
# didn't get this working with the 7M + FTDI
server 127.127.22.1 minpoll 3 maxpoll 4
fudge 127.127.22.1 refid PPS
EO_NTP
)
curl -sS https://byo-ntp.github.io/tools/ntp/install.sh | sh