ptp4l test-LinuxPTP\ptp4l configuration and troubleshooting

Directory

I. Introduction

1.1 What is ptp4l

1.2 Description

1.3 Official website connection

1.4 Purpose

1.5 Platform

2. Platform Necessary Software

2.1 Linux physical machine

2.2 imx6ull development board

3. Check whether the hardware supports

3.1 ifconfig View the name of the current network card

3.2 ethtool checks whether the driver and network card support

4. Open the ptp4l service

4.1 Method 1: The official recommended method to enable ptp4l service

4.2 Method 2: Open the ptp4l service (virtual machine platform) through groping


1. Foreword

1.1 What is ptp4l

ptp4l – PTP ordinary clock/boundary clock/transparent clock protocol stack

1.2 Description

ptp4l is an implementation of the PTP protocol (IEEE 1588) on Linux, supporting ordinary clocks, boundary clocks and transparent clocks.

1.3 Official website connection

Configuring PTP Using ptp4l :: Fedora Docs (fedoraproject.org)

1.4 Purpose

When configuring ptp4l for testing, it is found that there are some problems that make it impossible to test normally. Let’s troubleshoot and solve the problems encountered.

1.5 platform

master-linux physical machine. slave-linux virtual machine. Make sure both parties can ping through.

2. Platform necessary software

2.1 linux physical machine

1. Install ethtool

2. Install ptp4l

2.2 imx6ull development board

//1. imx6ull supports IEEE 1588 protocol

//2. The kernel configures the ptp clock

//3, cross compile or install ptp4l through buildroot, etc.

(Follow-up supplement)

3. Check whether the hardware supports it

3.1 ifconfig to view the name of the current network card

3.2 ethtool checks whether the driver and network card support

In order to use PTP, the network interface’s kernel network driver must support software or hardware time stamping functionality. In addition to the hardware time stamping support present in the driver, the NIC must be able to support this functionality in the physical hardware. The best way to verify the timestamping capabilities of a particular driver and NIC is to use ethtool to query the interface

Command: ethtool -T {network port name}

Note: For virtual machines, only software timestamps are available.

Software Timestamp Support

Hardware timestamp support

SOF_TIMESTAMPING_SOFTWARE

SOF_TIMESTAMPING_TX_SOFTWARE

SOF_TIMESTAMPING_RX_SOFTWARE

SOF_TIMESTAMPING_RAW_HARDWARE

SOF_TIMESTAMPING_TX_HARDWARE

SOF_TIMESTAMPING_RX_HARDWARE

4. Open ptp4l service

The following provides two ways to open the ptp4l service, one is the official recommended method, and the other is the method I explored by myself.

Refer to README configuration (path: /usr/share/doc/linuxptp/README.Debian)

Set step by step according to README, where ExecStart calls ptp4l, and its configuration items can be reasonably configured using man ptp4l or the configuration items I extracted below.

1. Default configuration

The default configuration can be found in /etc/linuxptp/ptp4l.conf.
This is the default.cfg provided by the upstream source.

2. Systemd services

The service ptp4l invokes ptp4l on eth0 by default. To adjust the
parameters, follow these steps:

1. create a directory /etc/systemd/system/ptp4l.service.d
2. place a file with its name ending in .conf there
3. put these lines into the file, with the parameters adjusted to your needs:

[Service]
ExecStart=
ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf -i eth0

The service phc2sys syncs the system clock with the PTP clock.
enabled and started by default. To activate this service, invoke the
following commands as root:

$ systemctl enable phc2sys
$ systemctl start phc2sys

It also uses eth0 as the default and can be customized as described above.

The service timemaster also isn't enabled and started by default

4.2 Method 2: Configure ptp4l service method by yourself (virtual machine platform)

Reason: Why not configure the service according to the official method? Because after installing ptp4l with apt, I directly started systemctl start ptp4l, and then used systemctl status ptp4l to check the error items for troubleshooting. Moreover, during the investigation process, it was found that the locations of the ptp4l service configuration files of different systems (virtual machines, physical machines) are different, so the following method can be applied.

1. Problem phenomenon

After enabling the ptp4l service, check the service command: systemctl status ptp4l. See that the started service is failed

2. Data query

Use man ptp4l to see what the commands executed in the Process column mean.

PTP4l(8) System Manager's Manual PTP4l(8)

name
       ptp4l - PTP Boundary/Ordinary Clock

SYNOPSIS
       ptp4l [ -AEP246HSLmqsv ] [ -f config ] [ -p phc-device ] [ -l print-level ] [ -i interface ] [ long-options ] ?…

DESCRIPTION
       ptp4l is an implementation of the Precision Time Protocol (PTP) according to IEEE standard 1588 for Linux. It implements
       Boundary Clock (BC) and Ordinary Clock (OC).

OPTIONS
       -A Select the delay mechanism automatically. Start with E2E and switch to P2P when a peer delay request is received.

       -E Select the delay request-response (E2E) mechanism. This is the default mechanism. All clocks on single PTP commu‐
              nication path must use the same mechanism. A warning will be printed when a peer delay request is received on
              port using the E2E mechanism.

       -P Select the peer delay (P2P) mechanism. A warning will be printed when a delay request is received on port using ?
              the P2P mechanism.

       -2 Select the IEEE 802.3 network transport.
       -4 Select the UDP IPv4 network transport. This is the default transport.
       -6 Select the UDP IPv6 network transport.

       -H Select the hardware time stamping. All ports specified by the -i option and in the configuration file must be at‐
              tached to the same PTP hardware clock (PHC). This is the default time stamping.

       -S Select the software time stamping.

       -L Select the legacy hardware time stamping.

       -f config
              Read configuration from the specified file. No configuration file is read by default.

       -i interface
              Specify a PTP port, it may be used multiple times. At least one port must be specified by this option or in the
              configuration file.

       -p phc-device
              (This option is deprecated.) Before Linux kernel v3.5 there was no way to discover the PHC device associated
              with a network interface. This option specifies the PHC device (e.g. /dev/ptp0) to be used when running on
              legacy kernels.

       -s Enable the slaveOnly mode.

       -l print-level
              Set the maximum syslog level of messages which should be printed or sent to the system logger. The default is 6
              (LOG_INFO).

       -m Print messages to the standard output.

       -q Don't send messages to the system logger.

       -v Prints the software version and exits.

       -h Display a help message.

3. Parameter Analysis

For the command /usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf -i eth0.

Where -f is used to specify the configuration file. -i is used to specify the network port.

According to the prompt information in the picture, it can be seen that the problem is that the specified network card name is incorrect. Check it through the ifconfig command in 3.1. The current physical network interface is ens33

And because it is a virtual machine platform, and it is also checked in 3.2 that the network card only supports the software timestamp function. Therefore, the -S configuration item needs to be added.

4. Modify parameters

The first step in modifying parameters is to find the location of the configuration file. I have tested the virtual machine platform and the physical machine platform. It is found that the location of the ptp4l configuration file is different, so students also need to find the location of the configuration file according to the actual situation.

Find configuration file location:
cd /etc
sudo grep "ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf" -R

You can know the location of the ptp4l configuration file: /etc/systemd/system/multi-user.target.wants/ptp4l.service. Modify the NIC interface and apply soft timestamps.

After saving, restart ptp4l according to the following command:

sudo systemctl daemon-reload #Reload systemd manager configuration after modifying service
sudo systemctl restart ptp4l #restart ptp4l
sudo systemctl status ptp4l #Check whether the startup is successful

4.3 Verify soft timestamp time synchronization

Test platform: Use two virtual machines, one as master and the other as slave

Premise: For the virtual machine, it is necessary to ensure that both parties can ping each other

Master virtual machine startup command: sudo ptp4l -i ens33 -S -m

Slave virtual machine startup command: sudo ptp4l -i ens33 -S -m -s

The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge. CS introductory skill tree Introduction to LinuxFirst acquaintance with Linux31706 People are studying systematically