Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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
minLevel1
maxLevel6
include
outlinefalse
indent
styledefault
excludeContents
typelist
class
printablefalse

...

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.

...

Code Block
languagebash
$ ethtool -T eno1
Time stamping parameters for eno1:
Capabilities:
        hardware-transmit     (SOF_TIMESTAMPING_TX_HARDWARE)
        software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
        hardware-receive      (SOF_TIMESTAMPING_RX_HARDWARE)
        software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
        software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
        hardware-raw-clock    (SOF_TIMESTAMPING_RAW_HARDWARE)
PTP Hardware Clock: 0
Hardware Transmit Timestamp Modes:
        off                   (HWTSTAMP_TX_OFF)
        on                    (HWTSTAMP_TX_ON)
Hardware Receive Filter Modes:
        none                  (HWTSTAMP_FILTER_NONE)
        ptpv1-l4-event        (HWTSTAMP_FILTER_PTP_V1_L4_EVENT)
        ptpv2-l4-event        (HWTSTAMP_FILTER_PTP_V2_L4_EVENT)
        ptpv2-l2-event        (HWTSTAMP_FILTER_PTP_V2_L2_EVENT)

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
languageplain
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
languageplain
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?

...

Thus, SP7350 can receive all the broadcast packets.

...

3. Check

...

Synchronization Result

Use tool phc_ctl to check PHC time.

...

Code Block
languageplain
root@dbv3:~# phc_ctl eth0 get
[11961.087454] stmmaceth f8103000.stmmac eth0: stmmac get 1708594606.185219257
[11961.094886] stmmaceth f8103000.stmmac eth0: stmmac get 1708594606.192565729
phc_ctl[11960.888]: clock time is 1708594606.192565729 or Thu Feb 22 09:36:46 2024

root@dbv3:~#