The purpose of the IEEE 1588 Precision Time Protocol (PTP) is to synchronize the time between different nodes on an Ethernet network. Many applications in factory automation, test and measurement, and telecommunications require very close time synchronization. This requirement is often well beyond what can be provided by a standard software solution.
Table of Contents
Table of Contents | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
Introduction to PTP
The IEEE 1588-2002 standard defines a protocol, Precision Time Protocol (a.k.a PTP Version 1), which enables precise synchronization of clocks in measurement and control systems implemented with technologies such as network communication, local computing, and distributed objects. The PTP applies to systems communicating by local area networks supporting multicast messaging, including (but not limited to) Ethernet. This protocol enables heterogeneous systems that include clocks of varying inherent precision, resolution, and stability to synchronize. The protocol supports system-wide synchronization accuracy in the sub-microsecond range with minimal network and local clock computing resources.
...
Info |
---|
Check if PTPv2 is supported? To check whether support IEEE 1588-2008 standard (a.k.a PTP Version 2), read HW feature register bit 13 and bit 24. SP7350 does not support PTPv2. |
Compare with NTP
NTP | IEEE 1588 | |
---|---|---|
Communication | Internet | LAN |
Accuracy | Millisecond | < Microsecond |
H/W Support | No | Usually required |
Network Time Protocol (NTP) has been the traditional way to synchronization time over Ethernet networks. NTP allows time synchronization up to 100 milliseconds. The IEEE 1588 PTP is required to achieve tighter synchronization. In software PTP applications, single link synchronization in the range of 100 microseconds can be reached. Hardware assistance is required to achieve time synchronization in the nanosecond region.
Hardware Timestamping of PTP
Hardware time stamp unit (TSU) incorporate a time of day (TOD) accumulator that measures the passage of time by counting the cycles of a reference clock signal from a PTP hardware clock (PHC). The PHC is steered by the PTP clock servo that issues corrections (clock operations) to the PHC. The IEEE 1588 protocol stack obtains the PTP timestamp information from the hardware TSU and provides it to the clock servo.
...
The above example output indicates support for hardware time stamping.
Run PTP
...
App on SP7350
We use linuxptp project to test PTP flow on SP7350, it contains several tools to use, like ptp4l, phc_ctl etc.
Basically, just follow these steps:
1. Run PTP
...
Grandmaster within LAN
...
PTP grandmaster has accurate time source, such as GPS.
...
Code Block | ||
---|---|---|
| ||
ptp4l[34476.707]: port 1 (enp2s0): INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[34476.707]: port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[34476.707]: port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[34483.780]: port 1 (enp2s0): LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES ptp4l[34483.781]: selected local clock 94c691.fffe.fc9abf as best master ptp4l[34483.781]: port 1 (enp2s0): assuming the grand master role |
2. Run PTP
...
Slave
To run ptp4l on SP7350, we need cross compile linuxptp, and install it on SP7350 Linux Roofs.
Code Block | ||
---|---|---|
| ||
root@dbv3:~# ptp4l -i eth0 -s -m -H |
...
Check the master offset value, if its absolute value is getting smaller and smaller, it means that the time difference between slave and master is getting smaller and smaller, i.e., time synchronization is successful.
Check NIC at promise mode?
...
If not, you can switch over manually with this command.
...
Thus, SP7350 can receive all the broadcast packets.
3. Check
...
Synchronization Result
Use tool phc_ctl
to check PHC time.
...