🛠 Horodatage industriel : PTP IEEE 1588 sur le PHY Ethernet du CM4

Raspberry Pi Compute Module 4 (CM4, 2020) — Board Sheet · avance · Schéma : IMG-compute-module-4-avance-1-ptp-1588-gbe-cm4.svg — deux CM4 sur IO Board reliés par un câble Ethernet droit ; chaque module porte la mention « PHY GbE compatible IEEE 1588 » ; un graphique d'offset temporel en µs s'affiche sur un écran de contrôle.

Objectives

A unique feature in the Pi range: the CM4 embeds a Gigabit Ethernet PHY compatible with IEEE 1588 (PTP) on the module — designed for industrial real-time synchronization (flagship cards use discrete PHYs without this claim). This tutorial sets up a two-node PTP domain with linuxptp: one grandmaster, one slave, and measures the residual offset in microseconds.

Hardware

Complete code

# --- Nœud A : grandmaster ---
sudo tee /etc/linuxptp/master.conf >/dev/null <<'EOF'
[global]
slaveOnly 0
networkTransportAddress eth0:500
summaryRatio -1
syncInterval 0
EOF
sudo ptp4l -f /etc/linuxptp/master.conf -m &

# --- Nœud B : esclave ---
sudo tee /etc/linuxptp/slave.conf >/dev/null <<'EOF'
[global]
slaveOnly 1
networkTransportAddress eth0:500
EOF
sudo ptp4l -f /etc/linuxptp/slave.conf -m &
# Ajuste CLOCK_REALTIME depuis la hardware clock de eth0
sudo phc2sys -s eth0 -c CLOCK_REALTIME -O 0 -m &

# --- Sur l'esclave : interroger l'état de synchronisation ---
sudo pmc -u -b eth0 'GET TIME_STATUS_NP' | grep -E 'master_offset|gmIdentity'

Expected verification

In the output of ptp4l -m on the slave side, the master offset lines converge to values in the order of microseconds in a direct topology; pmc 'GET TIME_STATUS_NP' displays a stable master_offset and the grandmaster identity; phc2sys no longer reports jumps. The two date commands at both ends agree to within a millisecond.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials