linuxptp适配记录

前提:物理机网卡加入ptp组播源
检查物理网卡是否支持ptp硬件时钟

1.安装linuxptp包

apt install linuxptp或dpkg -i linuxptp_1.9.2-1ubuntu0.1_amd64.deb

2.安装好了后有两个服务phc2sys.service和ptp4l.service以及pmc这三个工具。其中pmc是一个客户端工具

systemctl status phc2sys.service查看状态可能是dead

ptp4l.service的配置

ptp4l主要实现了普通/边界时钟;软/硬时间戳;延迟请求-响应/对等延迟机制;IEEE 802.3(以太网)/ UDP IPv4 / UDP IPv6网络传输。

bash 复制代码
[Unit]
Description=Precision Time Protocol (PTP) service
Documentation=man:ptp4l
 
[Service]
Type=simple
ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf -i eth0
 
[Install]
WantedBy=multi-user.target

phc2sys.service的配置

phc2sys主要同步两个时钟;当使用硬件时间戳的时候它用来调整系统时钟,软时间戳的时候不需要调整。

bash 复制代码
[Unit]
Description=Synchronize system clock or PTP hardware clock (PHC)
Documentation=man:phc2sys
After=ntpdate.service
Requires=ptp4l.service
After=ptp4l.service
 
[Service]
Type=simple
ExecStart=/usr/sbin/phc2sys -w -s eth0
 
[Install]
WantedBy=multi-user.target

pmc的作用是发送ptp管理消息到ptp节点。

3.这个时候我们需要调整配置,将/lib/systemd/system/phc2sys.service和/lib/systemd/system/ptp4l.service文件中的网卡eth0修改成已经加入了ptp组播源的网卡,systemctl daemon-reload然后重启下两个服务

4.发现ptp4l有如下错误,send sync failed

尝试调整tx_timestamp_timeout为60s、180s还是不行

做的其它尝试还有换其它版本的linuxptp(1.6,1.8,1.9,如果更高的版本就要升级libc的版本了)所以怀疑是driver bug。kern.log、syslog中除了上诉截图中的错误外,没有发现其它错误。

5.尝试在不升级的内核的情况下离线升级glibc(先用虚拟机模拟一下),如果可以则可以尝试linuxptp更高版本来进行适配

尝试失败,提示如下,看来必须要升级内核了

checking installed Linux kernel header files... missing or too old!

configure: error: GNU libc requires kernel header files from

6.升级版本后尝试,还是一样的错误,需要咨询一下厂商

咨询后,反馈那边没发现类似的问题,因为他们用的另外一个同步软件叫做ptpd

7.根据链接https://github.com/renesas/linux-ptp-driver-package,尝试编译相关驱动再做尝试.编译安装ptp相关驱动后,还是又如上的报错

8.最后实在没辙了,想了下,提示driver bug,这个ptp的使用也就两种驱动可能会影响,要么是ptp驱动要么是对应网卡的驱动。ptp驱动尝试了不行,接着尝试升级网卡驱动(驱动下载https://www.intel.com/content/www/us/en/download/14302/intel-network-adapter-driver-for-pcie-intel-10-gigabit-ethernet-network-connections-under-linux.html,内核驱动可以在当前系统中直接编译)

8.1>升级驱动

驱动已更新

8.2>再次验证ptp4l服务已经正常

当要把bond调成单网卡时,需要注意顺序。先加载新驱动,再将bond换成eno1。(如果这个顺序颠倒了会有问题)

tips:

查看网卡设备型号

先用eth -i eno1看bus-info,再lspci -knn -s 01:00.0(01:00.0为bus-info的后半部分)

相关参考文档

https://github.com/raspberrypi/linux/issues/5947

https://www.kernel.org/doc/html/v5.4/driver-api/ptp.html

https://blog.csdn.net/weixin_43129599/article/details/122026991

https://www.openil.org/files/OpenIL_User_Guide_Rev1.2.pdf

https://e2echina.ti.com/support/interface/f/interface-forum/290743/dp83640-linux-ptp

https://community.nxp.com/t5/QorIQ/ptp4l-tx-timestamp-timeout/m-p/892488

https://blog.csdn.net/yaojiawan/article/details/124601694

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-configuring_ptp_using_ptp4l

https://www.elecfans.com/d/1870476.html

关键

https://zshisite.wordpress.com/2017/10/25/sync-your-cloud-with-ptp/

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/chap-kvm_guest_timing_management

相关推荐
落羽的落羽39 分钟前
【算法札记】练习 | Week4
linux·服务器·数据结构·c++·人工智能·算法·动态规划
Mortalbreeze42 分钟前
深度理解文件系统 ---- 从磁盘存储到内核存储
大数据·linux·数据库
LN花开富贵4 小时前
Ubuntu aarch64 架构安装 NoMachine 远程控制 避坑与实战
linux·运维·笔记·学习·ubuntu·嵌入式
取经蜗牛4 小时前
Windows 11 WSL + Ubuntu 24.04 安装指南
linux·windows·ubuntu
杨云龙UP4 小时前
Oracle RAC/ODA环境下如何准确查询PDB表空间已分配大小?一次说清Oracle表空间逻辑大小和ASM三副本实际占用_2026-05-19
linux·运维·数据库·sql·oracle·ffmpeg
2023自学中4 小时前
imx6ull开发板,Linux-c编程,识别 键盘、鼠标、触摸屏坐标
linux·嵌入式·开发板·应用编程
步十人4 小时前
【Linux】环境配置
linux·运维·服务器
念恒123065 小时前
MySQl安装
linux·运维·服务器
kaoa0005 小时前
Linux入门攻坚——77、虚拟化技术基础原理-2
linux·服务器·网络
vortex55 小时前
现代 Linux 包管理全景:从 apt 到 Nix,四大派系与四大范式
linux·运维·服务器