LinuxPTP在汽车时钟同步网络中的实践

这里列举一些在汽车以太网中使用LinuxPTP的注意点。

请使用较新版本的LinuxPTP,可以自己编译部署!

在使用中,我遇到了某些指令或者配置文件关键字已经废弃,官方网页中的文档和实际工具对不上的问题。

研究发现是目标板中部署的LinuxPTP版本较老,而网上的文档较新。

在实际操作中可以自己根据源码编译部署。 保证文档和实际的工具是同一套。

LinuxPTP 兼容 汽车以太网中其他时间同步ECU,需要使用配置文件。因为某些配置项没有提供指令,而是以配置文件的形式记录和提供。

如果不指定/dev/PTP设备,工具会自动选择一个,请注意这个设备,在使用phc2sys时需要保持一致。

在配置文件中有一个配置项 ,transportSpecific 0x1。 其功能类似于VLAN , 在使用phc2sys时需要保持一致, 添加--transportSpecific=1 指令。

bash 复制代码
./ptp4l -i eth0 -f configs/automotive-slave.cfg  -m -H
ptp4l[514.862]: selected /dev/ptp1 as PTP clock
ptp4l[514.896]: port 1 (eth0): INITIALIZING to SLAVE on INIT_COMPLETE
ptp4l[514.897]: port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[514.897]: port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[516.918]: rms 805708105219 max 1611416211536 freq -17263 +/- 6638 delay  7398 +/-  18
ptp4l[517.956]: rms  373 max  552 freq -18157 +/- 522 delay  7343 +/-   0
ptp4l[518.997]: rms 122271 max 345831 freq +45042 +/- 164142 delay -338043 +/-   0
ptp4l[520.038]: rms 216113 max 326596 freq +161766 +/- 281863 delay  7339 +/-   0
ptp4l[521.076]: rms 157176 max 250243 freq -221411 +/- 45583 delay  7341 +/-   0
ptp4l[522.117]: rms 21874 max 37404 freq -83173 +/- 30596 delay  7339 +/-   0
ptp4l[523.158]: rms 33590 max 35226 freq -14791 +/- 10063 delay  7341 +/- 
ptp4l[524.196]: rms 22287 max 29284 freq   -739 +/- 761 delay  7343 +/-   0
ptp4l[525.238]: rms 7574 max 12270 freq  -6771 +/- 2469 delay  7352 +/-   0
ptp4l[526.276]: rms 1088 max 1613 freq -13943 +/- 1521 delay  7352 +/-   0
ptp4l[527.317]: rms 1842 max 1948 freq -17425 +/- 526 delay  7370 +/-   0
ptp4l[528.358]: rms 1134 max 1414 freq -18019 +/- 120 delay  7392 +/-   0
ptp4l[529.399]: rms  373 max  576 freq -17696 +/- 115 delay  7392 +/-   0
ptp4l[530.437]: rms   87 max  192 freq -17293 +/- 111 delay  7392 +/-   0
ptp4l[531.478]: rms  117 max  197 freq -17122 +/-  70 delay  7376 +/-   0

使用 -s /dev/ptp1 -c CLOCK_REALTIME 来指定时钟源和目标修改的时钟,避免通过-a 自动选择使得选取的时钟源和前面ptp4l中同步的硬件时钟不一致。

有的/dev/PTP 会受到硬件限制或者配置限制,而在实现同步的过程中出现报错。例如,不支持快速step跃迁。这个时候可以读取/dev/ptp 设备的属性配置,或者更改其配置。如果有多个/dev/ptp设备可以更换选择不同的/dev/ptp设备来尝试。

bash 复制代码
./phc2sys -s /dev/ptp1 -c CLOCK_REALTIME -w -O 0 --transportSpecific=1 -m
phc2sys[734.929]: CLOCK_REALTIME phc offset      -232 s0 freq  -17079 delay    520
phc2sys[735.930]: CLOCK_REALTIME phc offset      -378 s2 freq  -17225 delay    605
phc2sys[736.930]: CLOCK_REALTIME phc offset      -203 s2 freq  -17428 delay    505
phc2sys[737.930]: CLOCK_REALTIME phc offset        47 s2 freq  -17239 delay    600
phc2sys[738.931]: CLOCK_REALTIME phc offset       125 s2 freq  -17147 delay    600
phc2sys[739.931]: CLOCK_REALTIME phc offset       201 s2 freq  -17034 delay    505
phc2sys[740.931]: CLOCK_REALTIME phc offset       109 s2 freq  -17065 delay    535
phc2sys[741.932]: CLOCK_REALTIME phc offset         1 s2 freq  -17141 delay    605
phc2sys[742.932]: CLOCK_REALTIME phc offset        57 s2 freq  -17084 delay    540
phc2sys[743.932]: CLOCK_REALTIME phc offset       -43 s2 freq  -17167 delay    590
phc2sys[744.932]: CLOCK_REALTIME phc offset        27 s2 freq  -17110 delay    515
相关推荐
消失的旧时光-194334 分钟前
Linux 入门核心命令清单(工程版)
linux·运维·服务器
艾莉丝努力练剑41 分钟前
【Linux:文件】Ext系列文件系统(初阶)
大数据·linux·运维·服务器·c++·人工智能·算法
Trouvaille ~1 小时前
【Linux】TCP Socket编程实战(一):API详解与单连接Echo Server
linux·运维·服务器·网络·c++·tcp/ip·socket
旖旎夜光2 小时前
Linux(13)(中)
linux·网络
威迪斯特2 小时前
CentOS图形化操作界面:理论解析与实践指南
linux·运维·centos·组件·图形化·桌面·xserver
一方热衷.2 小时前
在线安装对应版本NVIDIA驱动
linux·运维·服务器
独自归家的兔3 小时前
ubuntu系统安装dbswitch教程 - 备份本地数据到远程服务器
linux·运维·ubuntu
ONE_SIX_MIX3 小时前
ubuntu 24.04 用rdp连接,桌面黑屏问题,解决
linux·运维·ubuntu
龙飞053 小时前
Systemd -systemctl - journalctl 速查表:服务管理 + 日志排障
linux·运维·前端·chrome·systemctl·journalctl
*小海豚*3 小时前
在linux服务器上DNS正常,但是java应用调用第三方解析域名报错
java·linux·服务器