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
相关推荐
不做无法实现的梦~16 分钟前
Linux 上使用 CLion 开发嵌入式,并用 Codex CLI
linux·运维·服务器
张32334 分钟前
Ansible拆分大型Playbook
linux·ansible
苦逼大学生被编程薄纱2 小时前
Ext 文件系统基础:Linux 存储基石入门(下)
linux·运维·服务器
Lumos_7772 小时前
Linux -- 进程
linux·运维·服务器
南境十里·墨染春水2 小时前
linux学习进展 进程间通讯——共享内存
linux·数据库·学习
小此方3 小时前
Re:Linux系统篇(五)指令篇 ·四:shell外壳程序及其工作原理
linux·运维·服务器
其实防守也摸鱼3 小时前
sqlmap下载和安装保姆级教程(附安装包)
linux·运维·服务器·测试工具·渗透测试·攻防·护网行动
jingyu飞鸟3 小时前
Linux系统发送邮件,解决信誉等级低问题 docker compose修改启动一键使用
linux·运维·docker
Lumos_7773 小时前
Linux -- exec 进程替换
linux·运维·chrome
ElfBoard4 小时前
飞凌精灵(ElfBoard)技术贴|如何在RK3506开发板上实现UART功能复用
大数据·linux·人工智能·驱动开发·单片机·嵌入式硬件·物联网