GrandMaster config

This commit is contained in:
2026-09-07 00:13:37 +02:00
parent b79d98e348
commit 6d6750c7a2
6 changed files with 127 additions and 5 deletions

View File

@@ -9,17 +9,17 @@ GT-U7 GNSS
├─ NMEA over UART ──> gpsd/chrony
└─ PPS on GPIO18 ──> chrony
\/
CLOCK_REALTIME (UTC)
phc2sys
\/
eth0 NIC PHC
ptp4l
\/
PTP domain 0
```
@@ -115,7 +115,7 @@ refclock SHM 0 refid NMEA offset 0.0 precision 1e-1 poll 3 noselect
refclock PPS /dev/pps0 refid PPS lock NMEA poll 3
```
If this Pi should continue serving NTP to the lab, keep the required `allow` networks, for example:
Limit the `allow` networks to somethig like RFC1918 range as follows:
```text
allow 192.168.0.0/16
@@ -131,7 +131,7 @@ makestep 1 3
leapseclist /usr/share/zoneinfo/leap-seconds.list
```
Do **not** add `local stratum 1` for the GNSS/PPS setup. A selected local refclock already makes chronyd serve the correct NTP stratum; `local` is a separate fallback/local-reference mode.
<!-- Do **not** add `local stratum 1` for the GNSS/PPS setup. A selected local refclock already makes chronyd serve the correct NTP stratum; `local` is a separate fallback/local-reference mode. -->
Restart chrony and verify that PPS becomes the selected source:

7
RPi5_configs/config.txt Normal file
View File

@@ -0,0 +1,7 @@
sudo bash -c "echo '# GPS UART on GPIO14/GPIO15 for Pi 5' >> /boot/firmware/config.txt"
sudo bash -c "echo 'dtoverlay=uart0-pi5' >> /boot/firmware/config.txt"
sudo bash -c "echo 'init_uart_baud=9600' >> /boot/firmware/config.txt"
sudo bash -c "echo '' >> /boot/firmware/config.txt"
sudo bash -c "echo '# GPS PPS on physical pin 12 / GPIO18' >> /boot/firmware/config.txt"
sudo bash -c "echo 'dtoverlay=pps-rp1,pin=18,pull-down,schmitt-trigger' >> /boot/firmware/config.txt"

View File

@@ -0,0 +1,20 @@
# /etc/systemd/system/phc2sys-gm.service
[Unit]
Description=Synchronize eth0 PHC from GNSS-disciplined system clock
After=ptp4l-gm.service
Requires=ptp4l-gm.service
[Service]
Type=simple
ExecStart=/usr/sbin/phc2sys \
-s CLOCK_REALTIME \
-c eth0 \
-w \
--step_threshold=0.5 \
-m
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target

66
RPi5_configs/ptp-gm.conf Normal file
View File

@@ -0,0 +1,66 @@
#/etc/linuxptp/ptp4l-gm.conf
[global]
# extra logging
verbose 1
# use hardware timestamping (alternative is software, which isn't nearly as accurate/precise)
time_stamping hardware
# This needs to be set to full rather than default normal because RPi5 Hardware Rx timestamping doesn't support richer filters. This is why it is better to tell the NIC to timestamp every Rx packet.
hwts_filter full
# you can specify a "domain number", which is analogus to VLAN
domainNumber 0
network_transport UDPv4
delay_mechanism E2E
# force this node to act as a master (won't revert to slave).
serverOnly 1
# priority settings, 128 is default. lower numbers are higher priority in case there are multiple grandmasters
# BMCA priority
priority1 128
priority2 128
# clockClass=6 for GNSS reference
# other classes = https://documentation.nokia.com/srlinux/24-10/books/network-synchronization/ieee-1588-ptp.html
clockClass 6
# timeSource is where time comes from - 0x10 is "atomic clock" which is a bit sus for us but not ultimately wrong
# | Value | Meaning | Use case |
# | -----: | --------------------- | --------------------------------------- |
# | `0x10` | `ATOMIC_CLOCK` | Direct atomic/rubidium/cesium reference |
# | `0x20` | `GPS` | GPS/GNSS-disciplined time source |
# | `0x30` | `TERRESTRIAL_RADIO` | Radio time source |
# | `0x40` | `PTP` | Synced from another external PTP source |
# | `0x50` | `NTP` | Synced from NTP |
# | `0x60` | `HAND_SET` | Manually set by human/operator |
# | `0x90` | `OTHER` | Other external source |
# | `0xA0` | `INTERNAL_OSCILLATOR` | Free-running/local oscillator/default |
timeSource 0x20
# Start conservatively. 0x23 would claim <= 1 us.
clockAccuracy 0xFE
# Unknown/not characterized yet.
offsetScaledLogVariance 0xFFFF
# PTP/TAI - UTC.
utc_offset 37
# Two-step is the linuxptp default and is also a good match for Nexus.
twoStepFlag 1
summary_interval 1
[eth0]
# log output to a file, summary interval is 2^x, so 1 = 2^1 = every 2 seconds
# can also output with -m
# summary_interval 1
# logfile /var/log/ptp4l.log

View File

@@ -0,0 +1,16 @@
# /etc/systemd/system/ptp4l-gm.service
[Unit]
Description=PTP Grandmaster on eth0
After=network-online.target chrony.service
Wants=network-online.target
Requires=chrony.service
[Service]
Type=simple
ExecStart=/usr/sbin/ptp4l -i eth0 -f /etc/linuxptp/ptp4l-gm.conf -m
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,13 @@
# /etc/systemd/system/ptp_nic_coalesce.service
[Unit]
Description=NIC coalesce minimize
Requires=network.target
After=network.target
[Service]
ExecStart=/usr/sbin/ethtool -C eth0 tx-usecs 4 rx-usecs 4
Type=oneshot
[Install]
WantedBy=multi-user.target