Page tree
Skip to end of metadata
Go to start of metadata

We recommend getting the basic overview of the IEE1588 and timestamping and basic terminologies.

建议先阅读以下文档来了解IEEE1588相关的技术。

https://elinux.org/images/f/f9/Introduction_to_IEEE_1588_Precision_Time_Protocol_%28PTP%29_Using_Embedded_Linux_Systems.pdf


使用前需要先查看网口是否支持硬件或软件时间戳

ethtool -T eth0
Time stamping parameters for eth0:
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: 1
Hardware Transmit Timestamp Modes:
        off                   (HWTSTAMP_TX_OFF)
        on                    (HWTSTAMP_TX_ON)
Hardware Receive Filter Modes:
        none                  (HWTSTAMP_FILTER_NONE)
        all                   (HWTSTAMP_FILTER_ALL)

Capabilities下的hardware-transmit, hardware-receive表示支持硬件时间戳,software-transmit, software-receive表示支持软件时间戳。


Master on PC

使用前需要安装linuxptp软件包

$ sudo ptp4l -i  enp5s0 -m -S 


Device


# ptp4l -H -A -l 7 -q -i eth1 -m -s
ptp4l[151.372]: config item (null).assume_two_step is 0
ptp4l[151.373]: config item (null).check_fup_sync is 0
ptp4l[151.374]: config item (null).tx_timestamp_timeout is 1
ptp4l[151.375]: config item (null).clock_servo is 0
ptp4l[151.376]: config item (null).time_stamping is 1
ptp4l[151.378]: config item (null).clock_servo is 0
ptp4l[151.379]: config item (null).clockClass is 248
ptp4l[151.380]: config item (null).clockAccuracy is 254
ptp4l[151.381]: config item (null).offsetScaledLogVariance is 65535
ptp4l[151.382]: config item (null).productDescription is ';;'
ptp4l[151.383]: config item (null).revisionData is ';;'
ptp4l[151.383]: config item (null).userDescription is ''
ptp4l[151.383]: config item (null).manufacturerIdentity is '00:00:00'
ptp4l[151.384]: config item (null).domainNumber is 0
ptp4l[151.385]: config item (null).slaveOnly is 1
ptp4l[151.385]: config item (null).twoStepFlag is 1
ptp4l[151.385]: config item (null).priority1 is 128
ptp4l[151.385]: config item (null).priority2 is 128
ptp4l[151.385]: config item (null).gmCapable is 1
ptp4l[151.386]: config item (null).gmCapable is 1
ptp4l[151.387]: config item (null).free_running is 0
ptp4l[151.387]: selected /dev/ptp1 as PTP clock
ptp4l[151.387]: config item (null).uds_address is '/var/run/ptp4l'
ptp4l[151.389]: section item /var/run/ptp4l.announceReceiptTimeout now 0
ptp4l[151.389]: section item /var/run/ptp4l.delay_mechanism now 0
ptp4l[151.389]: section item /var/run/ptp4l.network_transport now 0
ptp4l[151.389]: section item /var/run/ptp4l.delay_filter_length now 1
ptp4l[151.390]: config item (null).free_running is 0
ptp4l[151.390]: config item (null).freq_est_interval is 1
ptp4l[151.391]: config item (null).gmCapable is 1
ptp4l[151.392]: config item (null).kernel_leap is 1
ptp4l[151.392]: config item (null).timeSource is 160
ptp4l[151.392]: config item (null).pi_proportional_const is 0.000000
ptp4l[151.393]: config item (null).pi_integral_const is 0.000000
ptp4l[151.393]: config item (null).pi_proportional_scale is 0.000000
ptp4l[151.393]: config item (null).pi_proportional_exponent is -0.300000
ptp4l[151.393]: config item (null).pi_proportional_norm_max is 0.700000
ptp4l[151.393]: config item (null).pi_integral_scale is 0.000000
ptp4l[151.394]: config item (null).pi_integral_exponent is 0.400000
ptp4l[151.394]: config item (null).pi_integral_norm_max is 0.300000
ptp4l[151.394]: config item (null).step_threshold is 0.000000
ptp4l[151.394]: config item (null).first_step_threshold is 0.000020
ptp4l[151.394]: config item (null).max_frequency is 900000000
ptp4l[151.395]: config item (null).tsproc_mode is 0
ptp4l[151.395]: config item (null).delay_filter is 1
ptp4l[151.395]: config item (null).delay_filter_length is 10
ptp4l[151.395]: config item (null).summary_interval is 0
ptp4l[151.395]: config item (null).sanity_freq_limit is 200000000
ptp4l[151.396]: PI servo: sync interval 1.000 kp 0.700 ki 0.300000
ptp4l[151.396]: config item /var/run/ptp4l.boundary_clock_jbod is 0
ptp4l[151.397]: config item /var/run/ptp4l.network_transport is 0
ptp4l[151.397]: config item /var/run/ptp4l.delayAsymmetry is 0
ptp4l[151.397]: config item /var/run/ptp4l.follow_up_info is 0
ptp4l[151.397]: config item /var/run/ptp4l.freq_est_interval is 1
ptp4l[151.398]: config item /var/run/ptp4l.hybrid_e2e is 0
ptp4l[151.398]: config item /var/run/ptp4l.path_trace_enabled is 0
ptp4l[151.398]: config item /var/run/ptp4l.ingressLatency is 0
ptp4l[151.398]: config item /var/run/ptp4l.egressLatency is 0
ptp4l[151.398]: config item /var/run/ptp4l.delay_mechanism is 0
ptp4l[151.399]: config item /var/run/ptp4l.fault_badpeernet_interval is 16
ptp4l[151.399]: config item /var/run/ptp4l.fault_reset_interval is 4
ptp4l[151.399]: config item /var/run/ptp4l.tsproc_mode is 0
ptp4l[151.399]: config item /var/run/ptp4l.delay_filter is 1
ptp4l[151.399]: config item /var/run/ptp4l.delay_filter_length is 1
ptp4l[151.400]: config item eth1.boundary_clock_jbod is 0
ptp4l[151.400]: config item eth1.network_transport is 1
ptp4l[151.401]: config item eth1.delayAsymmetry is 0
ptp4l[151.401]: config item eth1.follow_up_info is 0
ptp4l[151.401]: config item eth1.freq_est_interval is 1
ptp4l[151.401]: config item eth1.hybrid_e2e is 0
ptp4l[151.401]: config item eth1.path_trace_enabled is 0
ptp4l[151.401]: config item eth1.ingressLatency is 0
ptp4l[151.401]: config item eth1.egressLatency is 0
ptp4l[151.401]: config item eth1.delay_mechanism is 0
ptp4l[151.402]: config item eth1.fault_badpeernet_interval is 16
ptp4l[151.403]: config item eth1.fault_reset_interval is 4
ptp4l[151.403]: config item eth1.tsproc_mode is 0
ptp4l[151.403]: config item eth1.delay_filter is 1
ptp4l[151.403]: config item eth1.delay_filter_length is 10
ptp4l[151.404]: config item eth1.logMinDelayReqInterval is 0
ptp4l[151.405]: config item eth1.logAnnounceInterval is 1
ptp4l[151.405]: config item eth1.announceReceiptTimeout is 3
ptp4l[151.405]: config item eth1.syncReceiptTimeout is 0
ptp4l[151.405]: config item eth1.transportSpecific is 0
ptp4l[151.405]: config item eth1.logSyncInterval is 0
ptp4l[151.406]: config item eth1.logMinPdelayReqInterval is 0
ptp4l[151.406]: config item eth1.neighborPropDelayThresh is 20000000
ptp4l[151.406]: config item eth1.min_neighbor_prop_delay is -20000000
ptp4l[151.406]: config item eth1.udp_ttl is 1
ptp4l[151.409]: driver changed our HWTSTAMP options
ptp4l[151.410]: tx_type   1 not 1
ptp4l[151.411]: rx_filter 1 not 12
ptp4l[151.411]: config item (null).dscp_event is 0
ptp4l[151.412]: config item (null).dscp_general is 0
ptp4l[151.412]: port 1: INITIALIZING to LISTENING on INITIALIZE
ptp4l[151.413]: config item /var/run/ptp4l.logMinDelayReqInterval is 0
ptp4l[151.413]: config item /var/run/ptp4l.logAnnounceInterval is 1
ptp4l[151.414]: config item /var/run/ptp4l.announceReceiptTimeout is 0
ptp4l[151.414]: config item /var/run/ptp4l.syncReceiptTimeout is 0
ptp4l[151.414]: config item /var/run/ptp4l.transportSpecific is 0
ptp4l[151.414]: config item /var/run/ptp4l.logSyncInterval is 0
ptp4l[151.414]: config item /var/run/ptp4l.logMinPdelayReqInterval is 0
ptp4l[151.415]: config item /var/run/ptp4l.neighborPropDelayThresh is 20000000
ptp4l[151.415]: config item /var/run/ptp4l.min_neighbor_prop_delay is -20000000
ptp4l[151.416]: config item (null).uds_address is '/var/run/ptp4l'
ptp4l[151.416]: port 0: INITIALIZING to LISTENING on INITIALIZE
ptp4l[151.418]: interface index 1 is up
ptp4l[151.419]: interface index 2 is down
ptp4l[151.419]: interface index 3 is down
ptp4l[151.420]: interface index 4 is up
ptp4l[151.420]: port 1: link up
ptp4l[151.421]: interface index 5 is down
ptp4l[152.319]: port 1: setting asCapable
ptp4l[153.319]: port 1: new foreign master 1831bf.fffe.e0ee96-1
ptp4l[154.621]: port 0: setting asCapable
ptp4l[157.320]: selected best master clock 1831bf.fffe.e0ee96
ptp4l[157.321]: foreign master not using PTP timescale
ptp4l[157.322]: port 1: LISTENING to UNCALIBRATED on RS_SLAVE
ptp4l[158.404]: port 1: delay timeout
ptp4l[158.408]: delay   filtered     236138   raw     236138
ptp4l[159.321]: master offset -317886227951 s0 freq      +0 path delay    236138
ptp4l[160.101]: port 1: delay timeout
ptp4l[160.104]: delay   filtered     234415   raw     232693
ptp4l[160.321]: master offset -317886232397 s1 freq   -4444 path delay    234415
ptp4l[160.884]: port 1: delay timeout
ptp4l[161.321]: master offset      -3311 s2 freq   -7755 path delay    234415
ptp4l[161.322]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED
ptp4l[162.322]: master offset      -1548 s2 freq   -6985 path delay    234415
ptp4l[163.120]: port 1: delay timeout
ptp4l[163.124]: delay   filtered     232693   raw     231386
ptp4l[163.322]: master offset         38 s2 freq   -5864 path delay    232693
ptp4l[163.936]: port 1: delay timeout
ptp4l[163.939]: delay   filtered     232039   raw      58862
ptp4l[164.322]: master offset       -114 s2 freq   -6004 path delay    232039
ptp4l[164.446]: port 1: delay timeout
ptp4l[164.449]: delay   filtered     231386   raw     230110
ptp4l[165.322]: master offset       -681 s2 freq   -6606 path delay    231386
ptp4l[166.322]: master offset       -374 s2 freq   -6503 path delay    231386
ptp4l[166.348]: port 1: delay timeout
ptp4l[166.351]: delay   filtered     231908   raw     232430
ptp4l[166.878]: port 1: delay timeout
ptp4l[166.882]: delay   filtered     232430   raw     233931
ptp4l[167.322]: master offset      -2300 s2 freq   -8541 path delay    232430
ptp4l[167.740]: port 1: delay timeout
ptp4l[167.743]: delay   filtered     232561   raw     232969
ptp4l[168.323]: master offset       -260 s2 freq   -7191 path delay    232561
ptp4l[168.480]: port 1: delay timeout
ptp4l[168.484]: delay   filtered     232693   raw     236010
ptp4l[169.323]: master offset       -725 s2 freq   -7734 path delay    232693
ptp4l[169.374]: port 1: delay timeout
ptp4l[169.377]: delay   filtered     232831   raw     233908
ptp4l[170.167]: port 1: delay timeout
ptp4l[170.170]: delay   filtered     232561   raw     228615
ptp4l[170.323]: master offset        958 s2 freq   -6269 path delay    232561
ptp4l[171.323]: master offset        284 s2 freq   -6655 path delay    232561
ptp4l[172.038]: port 1: delay timeout
ptp4l[172.042]: delay   filtered     232699   raw     233889
ptp4l[172.324]: master offset       -768 s2 freq   -7622 path delay    232699
ptp4l[172.358]: port 1: delay timeout
ptp4l[172.361]: delay   filtered     233429   raw     235046
ptp4l[173.324]: master offset       -366 s2 freq   -7450 path delay    233429
ptp4l[174.236]: port 1: delay timeout
ptp4l[174.239]: delay   filtered     233429   raw     229687
ptp4l[174.324]: master offset        830 s2 freq   -6364 path delay    233429
ptp4l[174.780]: port 1: delay timeout
ptp4l[174.783]: delay   filtered     233550   raw     233211
ptp4l[175.324]: master offset       -472 s2 freq   -7417 path delay    233550
ptp4l[175.842]: port 1: delay timeout
ptp4l[175.845]: delay   filtered     233550   raw     231953
ptp4l[176.088]: port 1: delay timeout
ptp4l[176.092]: delay   filtered     233550   raw     234050
ptp4l[176.238]: port 1: delay timeout
ptp4l[176.241]: delay   filtered     233550   raw     231870


硬件Event

$ ptp4l -A -4 -H -m -i eth1  &
$ echo 1 > /sys/class/ptp/ptp0/pps_enable
  • No labels
Write a comment…