Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

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.

Contents

About 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.

The PTP is transported over UDP/IP. The system or network is classified into master and slave nodes for distributing the timing and clock information. Figure 1 shows the process that PTP uses for synchronizinga slave node to a master node by exchanging PTP messages.

image-20240222-110429.png

Most of the PTP implementation is done in the software above the UDP layer. However, the hardwaresupport is required to capture the exact time when specific PTP packets enter or leave the Ethernet port at the GMII/MII. This timing information must be captured and returned to the software for the proper implementation of PTP with high accuracy.

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.

Check whether your NIC(Network Interface Card) supports PTP with the following command.

$ 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)

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.

We run ptp4l on an PC as a PTP grandmaster to test.

$ sudo ./ptp4l -i enp2s0 -m -S
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

3. Run PTP slave.

To run ptp4l on SP7350, we need cross compile linuxptp, and install it on SP7350 Linux Roofs.

root@dbv3:~# ptp4l -i eth0 -s -m -H

Check NIC at promise mode?

image-20240222-111754.png

If not, you can switch over manually with this command.

root@dbv3:~# ifconfig eth0 promisc

Thus, SP7350 can receive all the broadcast packets.

4. Check synchronization result.

Use tool phc_ctl to check PHC time.

Before synchronization.

root@dbv3:~# phc_ctl eth0 get
[11814.957749] stmmaceth f8103000.stmmac eth0: stmmac get 0.0
[11814.958249] stmmaceth f8103000.stmmac eth0: stmmac get 0.0
phc_ctl[11814.750]: clock time is 0.000000000 or Thu Jan  1 00:00:00 1970

After synchronization.

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:~#

  • No labels