Skip to content

Instantly share code, notes, and snippets.

@michalpelka
Last active August 18, 2025 21:00
Show Gist options
  • Save michalpelka/b3530b39125bca228a0f583a7c1e3f97 to your computer and use it in GitHub Desktop.
Save michalpelka/b3530b39125bca228a0f583a7c1e3f97 to your computer and use it in GitHub Desktop.
Create PTP server for Pandar XT on Raspberry Pi 5

Create PTP server

Install software

sudo apt-get update && sudo apt-get install linuxptp

Create config

sudo vim /etc/linuxptp/gm-l2.conf

and add content:

[global]
serverOnly            1         
time_stamping         hardware
network_transport     L2    
delay_mechanism       E2E
domainNumber          0
twoStepFlag           1
summary_interval      1
logAnnounceInterval   1
logSyncInterval       0
summary_interval      1
[eth0]

Create service for PTP

sudo vim /etc/systemd/system/[email protected]

Add content:

[Unit]
Description=linuxptp Grandmaster (ptp4l) on eth0
Wants=network-online.target
After=network-online.target sys-subsystem-net-devices-eth0.device
Requires=sys-subsystem-net-devices-eth0.device

[Service]
Type=simple
User=root
ExecStartPre=/sbin/ip link show dev eth0
ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/gm-l2.conf -i eth0 -m
Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target

Service for updating time in /dev/ptp

sudo vim /etc/systemd/system/phc2sys-gm-eth0.service

Content:

[Unit]
Description=phc2sys (CLOCK_REALTIME -> /dev/ptp0) on eth0
After=ptp4l-gm-eth0.service
Requires=ptp4l-gm-eth0.service

[Service]
Type=simple
User=root
ExecStart=/usr/sbin/phc2sys -s CLOCK_REALTIME -c /dev/ptp0 -O 0 -w -m
Restart=always
RestartSec=2

[Install]
WantedBy=multi-user.target

Start it

sudo systemctl daemon-reload
sudo systemctl enable --now ptp4l-gm-eth0.service
sudo systemctl enable --now phc2sys-gm-eth0.service

Log

journalctl -u ptp4l-gm-eth0 -n 50 -e | tail
journalctl -u phc2sys-gm-eth0 -n 50 -e | tail

Setup Lidar

Set Clock source to PTP and choose network transport "L2".

Test

Setup Xsense

sudo adduser mandeye dialout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment