如何正确启用 E 版网卡的 PTP (IEEE 1588) 支持 #121

Open
opened 2026-02-07 10:51:56 -05:00 by Candinya · 0 comments
Candinya commented 2026-02-07 10:51:56 -05:00 (Migrated from github.com)

问题描述

已经确认网卡支持硬件 PTP 的能力:

# ethtool -T eth0
Time stamping parameters for eth0:
Capabilities:
        hardware-transmit
        software-transmit
        hardware-receive
        software-receive
        software-system-clock
        hardware-raw-clock
PTP Hardware Clock: 0
Hardware Transmit Timestamp Modes:
        off
        on
Hardware Receive Filter Modes:
        none
        all
        ptpv1-l4-event
        ptpv1-l4-sync
        ptpv1-l4-delay-req
        ptpv2-l4-event
        ptpv2-l4-sync
        ptpv2-l4-delay-req
        ptpv2-event
        ptpv2-sync
        ptpv2-delay-req

在内核里开启 PTP 支持(CONFIG_PTP_1588_CLOCK 和 CONFIG_NETWORK_PHY_TIMESTAMPING 均设置为 y)后,系统日志 (dmesg) 有 PTP 相关信息输出:

[    0.055998] PTP clock support registered
...
[    5.125489] bm-dwmac 4070000.ethernet eth0: registered PTP clock

为避免是人为操作导致的错误,在系统启动后从日志 /var/log/messages 中收集信息(ptp4l 配置文件增加 verbose 1 以输出日志):

phc2sys 的日志输出:

Jan  1 00:08:06 licheervnano-f183 user.info : [13.081] eth0 sys offset     -1038 s0 freq      -0 delay    480
Jan  1 00:08:07 licheervnano-f183 user.info : [14.082] eth0 sys offset     -1154 s2 freq    -116 delay    480
Jan  1 00:08:08 licheervnano-f183 user.info : [15.082] eth0 sys offset -1147484800 s0 freq    -116 delay    480
Jan  1 00:08:09 licheervnano-f183 user.info : [16.082] eth0 sys offset -1147484728 s0 freq    -116 delay    480
Jan  1 00:08:10 licheervnano-f183 user.warn : [17.082] clockcheck: clock jumped backward or running slower than expected!
Jan  1 00:08:10 licheervnano-f183 user.info : [17.082] eth0 sys offset -2294968360 s0 freq    -116 delay    480
Jan  1 00:08:11 licheervnano-f183 user.info : [18.083] eth0 sys offset -2294968334 s1 freq     -90 delay    480
Jan  1 00:08:12 licheervnano-f183 user.warn : [19.083] clockcheck: clock jumped backward or running slower than expected!
Jan  1 00:08:12 licheervnano-f183 user.info : [19.083] eth0 sys offset -1147483632 s0 freq     -90 delay    480
Jan  1 00:08:13 licheervnano-f183 user.info : [20.083] eth0 sys offset -1147483636 s1 freq     -94 delay    480
Jan  1 00:08:14 licheervnano-f183 user.warn : [21.083] clockcheck: clock jumped backward or running slower than expected!
Jan  1 00:08:14 licheervnano-f183 user.info : [21.084] eth0 sys offset -1147483686 s0 freq     -94 delay    480
Jan  1 00:08:15 licheervnano-f183 user.info : [22.084] eth0 sys offset -1147483674 s1 freq     -82 delay    480

ptp4l 的日志输出:

Jan  1 00:08:05 licheervnano-f183 user.info : [12.075] selected /dev/ptp0 as PTP clock
Jan  1 00:08:05 licheervnano-f183 user.err : [12.079] The current filter does not match the required
Jan  1 00:08:05 licheervnano-f183 user.notice : [12.084] port 1 (eth0): INITIALIZING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
Jan  1 00:08:05 licheervnano-f183 user.notice : [12.085] port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE
Jan  1 00:08:05 licheervnano-f183 user.notice : [12.088] port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE

补充信息

有问题的构建工程在 Candinya/LicheeRV-Nano-Build , 配置命令为 defconfig sg2002_licheervnano_sd_gps

## 问题描述 已经确认网卡支持硬件 PTP 的能力: ```log # ethtool -T eth0 Time stamping parameters for eth0: Capabilities: hardware-transmit software-transmit hardware-receive software-receive software-system-clock hardware-raw-clock PTP Hardware Clock: 0 Hardware Transmit Timestamp Modes: off on Hardware Receive Filter Modes: none all ptpv1-l4-event ptpv1-l4-sync ptpv1-l4-delay-req ptpv2-l4-event ptpv2-l4-sync ptpv2-l4-delay-req ptpv2-event ptpv2-sync ptpv2-delay-req ``` 在内核里开启 PTP 支持(CONFIG_PTP_1588_CLOCK 和 CONFIG_NETWORK_PHY_TIMESTAMPING 均设置为 y)后,系统日志 (dmesg) 有 PTP 相关信息输出: ```log [ 0.055998] PTP clock support registered ... [ 5.125489] bm-dwmac 4070000.ethernet eth0: registered PTP clock ``` 为避免是人为操作导致的错误,在系统启动后从日志 `/var/log/messages` 中收集信息(ptp4l 配置文件增加 verbose 1 以输出日志): phc2sys 的日志输出: ```log Jan 1 00:08:06 licheervnano-f183 user.info : [13.081] eth0 sys offset -1038 s0 freq -0 delay 480 Jan 1 00:08:07 licheervnano-f183 user.info : [14.082] eth0 sys offset -1154 s2 freq -116 delay 480 Jan 1 00:08:08 licheervnano-f183 user.info : [15.082] eth0 sys offset -1147484800 s0 freq -116 delay 480 Jan 1 00:08:09 licheervnano-f183 user.info : [16.082] eth0 sys offset -1147484728 s0 freq -116 delay 480 Jan 1 00:08:10 licheervnano-f183 user.warn : [17.082] clockcheck: clock jumped backward or running slower than expected! Jan 1 00:08:10 licheervnano-f183 user.info : [17.082] eth0 sys offset -2294968360 s0 freq -116 delay 480 Jan 1 00:08:11 licheervnano-f183 user.info : [18.083] eth0 sys offset -2294968334 s1 freq -90 delay 480 Jan 1 00:08:12 licheervnano-f183 user.warn : [19.083] clockcheck: clock jumped backward or running slower than expected! Jan 1 00:08:12 licheervnano-f183 user.info : [19.083] eth0 sys offset -1147483632 s0 freq -90 delay 480 Jan 1 00:08:13 licheervnano-f183 user.info : [20.083] eth0 sys offset -1147483636 s1 freq -94 delay 480 Jan 1 00:08:14 licheervnano-f183 user.warn : [21.083] clockcheck: clock jumped backward or running slower than expected! Jan 1 00:08:14 licheervnano-f183 user.info : [21.084] eth0 sys offset -1147483686 s0 freq -94 delay 480 Jan 1 00:08:15 licheervnano-f183 user.info : [22.084] eth0 sys offset -1147483674 s1 freq -82 delay 480 ``` ptp4l 的日志输出: ```log Jan 1 00:08:05 licheervnano-f183 user.info : [12.075] selected /dev/ptp0 as PTP clock Jan 1 00:08:05 licheervnano-f183 user.err : [12.079] The current filter does not match the required Jan 1 00:08:05 licheervnano-f183 user.notice : [12.084] port 1 (eth0): INITIALIZING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED) Jan 1 00:08:05 licheervnano-f183 user.notice : [12.085] port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE Jan 1 00:08:05 licheervnano-f183 user.notice : [12.088] port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE ``` ## 补充信息 有问题的构建工程在 [Candinya/LicheeRV-Nano-Build](https://github.com/Candinya/LicheeRV-Nano-Build) , 配置命令为 `defconfig sg2002_licheervnano_sd_gps` 。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
maxpeterkaya/LicheeRV-Nano-Build#121
No description provided.