Files
RPi5-PTP-server/clientConfig.md
2026-09-07 00:27:05 +02:00

207 lines
3.8 KiB
Markdown

# Prereqs
Here I assume that your NIC is called enp4s0d1
Then check if the client supports **hardware-transmit** and **hardware-receive**.
```bash
ethtool -T enp4s0d1
```
If the client does support these two, continue on
# Prepare PTP configs
First, install the **linuxptp** package.
Then make sure that no other time synchronization services, like chrony or ntpd or systemd-timesynced, are running.
```bash
sudo systemctl stop ntpd
sudo systemctl stop chrony
sudo systemctl stop systemd-timesyncd
sudo systemctl disable ntpd
sudo systemctl disable chrony
sudo systemctl disable systemd-timesyncd
```
## Create PTP config file
sudo vim /etc/linuxptp/ptp4l-client.conf
```bash
[global]
verbose 1
# Hardware timestamping using the NIC PHC
time_stamping hardware
# Must match your grandmaster
domainNumber 0
network_transport UDPv4
delay_mechanism E2E
# Force this machine to be a PTP client, never grandmaster
clientOnly 1
# Useful while tuning
summary_interval 1
# Repeat these square brackets for each interface
[enp4s0]
```
# Make PTP persistent
sudo vim /etc/systemd/system/ptp4l-client.service
```bash
[Unit]
Description=PTP client on enp4s0
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/sbin/ptp4l -i enp4s0 -f /etc/linuxptp/ptp4l-client.conf -m
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
```
sudo vim /etc/systemd/system/phc2sys-client.service
```bash
[Unit]
Description=Sync system clock from enp4s0 PHC
After=ptp4l-client.service
Requires=ptp4l-client.service
[Service]
Type=simple
ExecStart=/usr/sbin/phc2sys -s enp4s0 -c CLOCK_REALTIME -w -m
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
```
Then reload daemon and activate both PTP client and phc2sys
```bash
sudo systemctl daemon-reload
sudo systemctl enable --now ptp4l-client.service
sudo systemctl enable --now phc2sys-client.service
```
# Verification
Verify if PTP and phc2sys works with these commands
```bash
journalctl -u ptp4l-client -f
journalctl -u phc2sys-client -f
```
and also verify the status of PTP with these commands
```bash
pmc -u -b 0 'GET PORT_DATA_SET'
pmc -u -b 0 'GET TIME_STATUS_NP'
pmc -u -b 0 'GET CURRENT_DATA_SET'
```
# Boundary clock server
First, create a ptp4l-boundary-server.conf
sudo vim /etc/linuxptp/ptp4l-boundary-server.conf
```bash
[global]
time_stamping hardware
domainNumber 0
network_transport UDPv4
delay_mechanism E2E
# boundary_clock_jbod 1
# Let BMCA decide:
# upstream-facing port should become SLAVE/client
# downstream-facing port should become MASTER/server
priority1 200
priority2 128
summary_interval 1
[eno1]
# toward RPi5 grandmaster
[ens1f0]
# toward Nexus
```
Here's systemd service configs for a boundary clock server
sudo vim /etc/systemd/system/ptp4l-boundary-server.service
```bash
[Unit]
Description=PTP client on <NIC1>, <NIC2>
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/sbin/ptp4l -i <NIC1> -i <NIC2> -f /etc/linuxptp/ptp4l-boundary-server.conf -m
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
```
sudo vim /etc/systemd/system/phc2sys-boundary-server.service
```bash
[Unit]
Description=Sync system clock from enp4s0 PHC
After=ptp4l-boundary-server.service
Requires=ptp4l-boundary-server.service
[Service]
Type=simple
ExecStart=/usr/sbin/phc2sys -a -rr -m
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
```
Then reload daemon and activate both PTP client and phc2sys
```bash
sudo systemctl daemon-reload
sudo systemctl enable --now ptp4l-boundary-server.service
sudo systemctl enable --now phc2sys-boundary-server.service
```