首页 > 技术知识 > 正文

1. 前言

使用PTP同步时间之间的两个xavier nx设备 (与一个xavier nx设备为主和另一个xavier nx设备为slave)。

Master side

ifconfig eth0 down ifconfig eth0 up ifconfig eth0 0.0.0.0 ip addr add 10.0.0.1/24 dev eth0 ip link set dev eth0 up timedatectl set-ntp false date 010100002018 phc_ctl /dev/ptp0 set phc_ctl /dev/ptp0 get ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -m

slave side

ifconfig eth0 down ifconfig eth0 up ifconfig eth0 0.0.0.0 ip addr add 10.0.0.2/24 dev eth0 ip link set dev eth0 up timedatectl set-ntp false phc_ctl /dev/ptp0 get ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -s -m

使用“date”命令和“phc_ctl /dev/ptp0 get”命令检查了时间 主设备中发送的日期和时间没有反映在从设备中

2. 尝试如下命令

在主/从设备上执行以下命令

$ systemctl stop ptp4l $ systemctl disable ptp4l $ systemctl reboot

尝试在主服务器和从服务器上执行这些命令 但是仍然不能同步从时钟到主时钟

查看release标签, $ cat /etc/nv_tegra_release作为参考,

R32 (release), REVISION: 5.1, GCID: 26202423, BOARD: t186ref, EABI: aarch64, DATE: Fri Feb 19 16:50:29 UTC 2021 3.查询gPTP.cfg Default Data Set twoStepFlag 1 gmCapable 1 priority1 248 priority2 248 domainNumber 0 clockClass 248 clockAccuracy 0xFE offsetScaledLogVariance 0xFFFF free_running 0 freq_est_interval 1 Port Data Set logAnnounceInterval 1 logSyncInterval -3 logMinPdelayReqInterval 0 announceReceiptTimeout 3 syncReceiptTimeout 3 delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 800 min_neighbor_prop_delay -20000000 Run time options assume_two_step 1 logging_level 6 path_trace_enabled 1 follow_up_info 1 hybrid_e2e 0 tx_timestamp_timeout 1 use_syslog 1 verbose 0 summary_interval 0 kernel_leap 1 check_fup_sync 0 Servo options pi_proportional_const 0.0 pi_integral_const 0.0 pi_proportional_scale 0.0 pi_proportional_exponent -0.3 pi_proportional_norm_max 0.7 pi_integral_scale 0.0 pi_integral_exponent 0.4 pi_integral_norm_max 0.3 step_threshold 0.0 first_step_threshold 0.00002 max_frequency 900000000 clock_servo pi sanity_freq_limit 200000000 ntpshm_segment 0 Transport options transportSpecific 0x1 ptp_dst_mac 01:80:C2:00:00:0E p2p_dst_mac 01:80:C2:00:00:0E uds_address /var/run/ptp4l Default interface options network_transport L2 delay_mechanism P2P time_stamping hardware tsproc_mode filter delay_filter moving_median delay_filter_length 10 egressLatency 0 ingressLatency 0 boundary_clock_jbod 0
<
4. 修改配置 Host side ifconfig eth0 down ifconfig eth0 up ifconfig eth0 0.0.0.0 ip addr add 10.0.0.1/24 dev eth0 ip link set dev eth0 up timedatectl set-ntp false date 010100002018 phc_ctl /dev/ptp0 set phc_ctl /dev/ptp0 get ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -m slave side ifconfig eth0 down ifconfig eth0 up ifconfig eth0 0.0.0.0 ip addr add 10.0.0.2/24 dev eth0 ip link set dev eth0 up timedatectl set-ntp false phc_ctl /dev/ptp0 get ptp4l -f gPTP.cfg -i eth0 -p /dev/ptp0 -s -m

尝试以上的命令,仍不能在从属设备上得到时间同步 下面是我的设备上的phc_ctl /dev/ptp0输出

phc_ctl[235.617]: capabilities: 62500000 maximum frequency adjustment (ppb) 0 programable alarms 0 external time stamp channels 0 programmable periodic signals doesn’t have pulse per second support sudo phc_ctl /dev/ptp0 get phc_ctl[255.518]: clock time is 1625919201.249458848 or Sat Jul 10 17:43:21 2021

使用linuxptp

git clone git://git.code.sf.net/p/linuxptp/code linuxptp cd linuxptp/ make -j6 sudo make install 5. eth0的时间戳参数

ethtool -T 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: 0 Hardware Transmit Timestamp Modes: off (HWTSTAMP_TX_OFF) on (HWTSTAMP_TX_ON) Hardware Receive Filter Modes: none (HWTSTAMP_FILTER_NONE) ptpv1-l4-sync (HWTSTAMP_FILTER_PTP_V1_L4_SYNC) ptpv1-l4-delay-req (HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) ptpv2-l4-sync (HWTSTAMP_FILTER_PTP_V2_L4_SYNC) ptpv2-l4-delay-req (HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) ptpv2-l2-sync (HWTSTAMP_FILTER_PTP_V2_L2_SYNC) ptpv2-l2-delay-req (HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) ptpv2-event (HWTSTAMP_FILTER_PTP_V2_EVENT)

从根终端运行了命令 但是客户端上的“phc_ctl /dev/ptp0 get”并没有返回主机端上的时间

Host side: sudo ptpd -M -V -i eth0 Device side: sudo ptpd -s -V -i eth0 6. 调试记录

主端使用下面的命令

ifconfig eth0 down ifconfig eth0 up ifconfig eth0 0.0.0.0 ip addr add 10.0.0.1/24 dev eth0 ip link set dev eth0 up timedatectl set-ntp false date 010100002018 phc_ctl /dev/ptp0 set phc_ctl /dev/ptp0 get ptp4l -i eth0 -m -H phc2sys -m -s CLOCK_REALTIME -c eth0 -w

从端使用以下命令

ifconfig eth0 down ifconfig eth0 up ifconfig eth0 0.0.0.0 ip addr add 10.0.0.2/24 dev eth0 ip link set dev eth0 up timedatectl set-ntp false phc_ctl /dev/ptp0 get ptp4l -i eth0 -p /dev/ptp0 -s -m phc2sys -a -r -m

附加主从侧的日志

root@linux:/home/nvidia# ptp4l -i eth0 -m -H ptp4l[186.842]: selected /dev/ptp0 as PTP clock ptp4l[186.844]: port 1 (eth0): INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[186.845]: port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[186.845]: port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[193.957]: port 1 (eth0): LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES ptp4l[193.957]: selected local clock 48b02d.fffe.07645e as best master ptp4l[193.957]: port 1 (eth0): assuming the grand master role ptp4l[245.714]: port 1 (eth0): link down ptp4l[245.714]: port 1 (eth0): MASTER to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED) ptp4l[245.714]: port 1 (eth0): assuming the grand master role ptp4l[254.625]: port 1 (eth0): link up ptp4l[254.626]: port 1 (eth0): FAULTY to LISTENING on INIT_COMPLETE ptp4l[260.711]: port 1 (eth0): LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES ptp4l[260.711]: port 1 (eth0): assuming the grand master role ——————————————————————————— root@linux:/home/nvidia# sudo /usr/local/sbin/phc2sys -m -s CLOCK_REALTIME -c eth0 -w phc2sys[2640.073]: eth0 sys offset -39792 s0 freq +280 delay 3552 phc2sys[2641.074]: eth0 sys offset -40032 s1 freq +40 delay 3552 phc2sys[2642.074]: eth0 sys offset -96 s2 freq -56 delay 3552 phc2sys[2643.074]: eth0 sys offset -16 s2 freq -5 delay 3520 phc2sys[2644.075]: eth0 sys offset -16 s2 freq -9 delay 3520 phc2sys[2645.075]: eth0 sys offset 0 s2 freq +2 delay 3552 phc2sys[2646.075]: eth0 sys offset 0 s2 freq +2 delay 3552 phc2sys[2647.075]: eth0 sys offset 16 s2 freq +18 delay 3520 phc2sys[2648.076]: eth0 sys offset -16 s2 freq -9 delay 3552 phc2sys[2649.076]: eth0 sys offset -16 s2 freq -14 delay 3552 phc2sys[2650.076]: eth0 sys offset 16 s2 freq +13 delay 3520 phc2sys[2651.077]: eth0 sys offset 0 s2 freq +2 delay 3520 phc2sys[2652.077]: eth0 sys offset -16 s2 freq -14 delay 3488 phc2sys[2653.077]: eth0 sys offset 0 s2 freq -3 delay 3552 phc2sys[2654.077]: eth0 sys offset -16 s2 freq -19 delay 3520
<

nvidia nx平台使用ptp 同步两台nx设备

猜你喜欢