|
Raspberry Pi 5 bookworm notes - April 2025My previous Raspberry Pi notes were getting a little date so I have prepared this update. You may need to refer to these quickstart notes or these earlier notes notes for more detail. The steps I took were: Installing NTP on the RPi Installing NTP on the RPiAs supplied, the bookworm OS comes with NTPsec rather than plain NTP.
As I'm not familiar with NTPsec, a simple "sudo apt install ntp" took
care of that. Modifying the ntp.conf file to suit my networkI needed to edit the configuration of NTP to suit my own network, where I have several NTP stratum 1 servers already installed, and I prefer to European pool servers. To be ready for adding a PPS source, I added the "prefer" qualifier to the local servers. I left the original "driftfile" although with it being in /var/lib/ntpsec/ I'm unsure whether it lasts over restarts? Note that the file location is now: /etc/ntpsec/ntp.conf
|
. . driftfile /var/lib/ntpsec/ntp.drift # Type 22 mode PPS server 127.127.22.0 minpoll 4 maxpoll 4 fudge 127.127.22.0 refid PPS . . |
Look for the line starting with an "o" tally code in the output of "ntpq -pn"
oPPS(0) .PPS. 0 l 7 16 377 0.0000 0.0021 0.0001
This is, perhaps, the most complicated part of the task!
NTP has a serial support - it's the type 20 driver. However, it looks
for device /dev/gps0.
You need to create a link do that gps0 points to your actual serial device -
ttyAMA0 here.
You can now add a couple of lines to the ntp.conf adding NMEA suport:
. . # Coarse time from serial GPS server 127.127.20.0 mode 81 minpoll 4 maxpoll 4 iburst prefer # 115,200 baud fudge 127.127.20.0 time2 +0.058 refid NMEA . . |
Now you should see both the PPS and the NMEA/GPS listed in an "ntpq -pn"
oPPS(0) .PPS. 0 l 7 16 377 0.0000 0.0021 0.0001
*NMEA(0) .NMEA. 0 l 6 16 377 0.0000 -0.5643 1.4402
But we're not done yet!
It seems that the link we made between ttyAMA0 and GPS0 won't persist over a
reboot - what a pain!
there are several ways you can work round this errror/bug. I chose to edit
/etc/rc.local which is run at
boot time to include a command to recreate the link, and restart the ntp service
in case it was already
running so that it can detect the GPS/NMEA source. I added before the
"exit 0" command:
sleep 1 sudo ln -sf /dev/ttyAMA0 /dev/gps0 sleep 1 sudo service ntp restart |
# /etc/ntpsec/ntp.conf, configuration for ntpd; see ntp.conf(5) for help driftfile /var/lib/ntpsec/ntp.drift # Kernel mode PPS server 127.127.22.0 minpoll 4 maxpoll 4 fudge 127.127.22.0 refid PPS # Coarse time from serial GPS server 127.127.20.0 mode 81 minpoll 4 maxpoll 4 iburst prefer # 115,200 baud fudge 127.127.20.0 time2 +0.058 refid NMEA # Use local NTP servers server 192.168.0.20 iburst maxpoll 5 prefer # LeoNTP server 192.168.0.3 iburst maxpoll 5 prefer # PC Pixie server 192.168.0.71 iburst maxpoll 5 prefer # RasPi-1, LAN # Use UK & NL pool NTP servers pool uk.pool.ntp.org minpoll 6 maxpoll 7 pool nl.pool.ntp.org minpoll 6 maxpoll 7 # Suggestions for NTP restrictions (accepting ntpq commands): restrict source notrap nomodify nopeer restrict 127.0.0.1 restrict ::1 restrict 192.168.0.0 mask 255.255.255.0 |
Corrections welcomed!
|