基于树莓派的DIY PTP主时钟
DIY PTP Grandmaster Clock with a Raspberry Pi

原始链接: https://www.jeffgeerling.com/blog/2025/diy-ptp-grandmaster-clock-raspberry-pi

Time Pi 是一个开源项目,使用树莓派 5 创建一个 Stratum 1 PTP 和 NTP 时间服务器。其目标是使以往昂贵且复杂的精准网络时间同步技术更容易被业余爱好者和专业人士所使用。 该项目利用 TimeHAT,一个售价 200 美元的树莓派 HAT,它具有一个 2.5 Gbps 英特尔 i226 网卡(带有 PTP 硬件时间戳功能)和一个用于 GPS 模块的 OCP M.2 GNSS 插槽,以及 PPS I/O 端口。软件配置通过树莓派操作系统/Debian 上的 Ansible 完成。 早期测试表明,Time Pi 作为 NTP 时间服务器运行稳定,在靠近窗户放置时能够成功进行 GPS 定时。未来的计划包括安装室外 GPS 天线,进行 PTP 同步测试,与 Masterclock 进行时钟比较,以及使用 Time Card 的芯片级原子钟进行实验。该项目旨在突破 DIY 定时精度和易用性的界限。

Hacker News 最新 | 过去 | 评论 | 提问 | 展示 | 工作 | 提交 登录 使用树莓派自制PTP主时钟 (jeffgeerling.com) ingve 1小时前 6 分 | 隐藏 | 过去 | 收藏 | 讨论 加入我们,参加6月16日至17日在旧金山举办的AI创业学校! 指导原则 | 常见问题 | 列表 | API | 安全 | 法律 | 申请YC | 联系我们 搜索:

原文

tl;dr: I set up an open source Time Pi project to build a stratum 1 PTP and NTP timeserver using a Raspberry Pi.

Time is important to modern society, and most of us have a clock on our wrist that's more accurate than at any time in human history. But highly precise time is important in many industries, especially robotics, finance, and media production. And with tech like VR working its way into homes, precise time may become more important there, too.

The timing industry has many solutions for 'grandmaster' clocks, which take in highly accurate time from GPS, GNSS, or other atomic-clock-backed time sources, and distribute it to local networks with extreme precision—down to the nanosecond range—using PTP.

Time Pi - Raspberry Pi Time Grandmaster Clock in mini rack with Masterclock NTP clock

Historically, setting up a DIY PTP grandmaster clock server was a painful and expensive endeavor, pricing out most hobbyists. So I'm introducing a project that's been in the works for some time: Time Pi, a stratum 1 PTP and NTP timeserver based on a Raspberry Pi 5.

In the picture above, it is installed inside a LabStack module inside a 3U RackMate TT (an as-yet-unreleased version of DeskPi's mini racks—I'm working with them on ironing out the design). I have powered it using a PoE to USB-C power splitter, from my GigaPlus 2.5 Gbps PoE+ switch.

Video

I'm lucky to live in the same city as Masterclock, a timing solutions company that's been manufacturing time servers and clocks for most of my life.

I've been discussing my project with them for over a year, and they provided me two PoE-powered NTP clocks for the studio, and for my testing with the Time Pi (the analog/digital hybrid clock is pictured above, and a 1U rackmount clock is pictured below):

Time Pi - 1U Masterclock rackmount clock

Dr. Demetrios Matsakis, formerly the Chief Scientist for the US Naval Observatory (which helps coordinate the time in UTC!), is now Masterclock's Chief Scientist. He and John Clark (the CTO) were gracious enough to visit my studio and chat with me about their new time server, the GMR6000, and about time and DIY solutions.

Dr. Demetrios Matsakis with Jeff Geerling in studio

(Special thanks to Dave Bour for providing the photo above.)

A video I published on my YouTube channel includes my conversations with them (and a lot more detail about the Time Pi). You can watch it below:

Time Pi

Assuming you don't want to watch the full video, I'll also describe the hardware itself here—as it is built around the TimeHAT from TimeAppliances.

The TimeHAT is a $200 HAT for the Pi 5 which includes an Intel i226 2.5 Gbps NIC with PTP hardware timestamping support. There are two SMA connectors for PPS in/out (configurable), an extra U.fl connector to another PPS port on the NIC, and an M.2 slot routed for a custom GPS module.

Time Pi TimeHAT with GPS Module in Mini Rack LabStack module

The slot is a little interesting, it's described as an "OCP M.2 GNSS 2242 Slot", and it follows the M2 Sync Module Form Factor from the Open Compute Project. Right now I can only find one commercially-available option: OCP M.2 Neo-M9N GNSS, a $195 add-on with a timing-focused u-blox GPS module.

The HAT interfaces with the Pi 5 through both PCIe (for the Intel i226 NIC), and GPIO (for GPS communications and configuration).

I have had some hardware issues with the i226 NIC, but it doesn't seem like those issues are related to either the TimeHAT or the Pi, but rather, Intel's Linux drivers. It seems like both the i225 and i226 have various strange issues, and the main one I ran into is it won't work at 2.5 Gbps, but does at 1 Gbps.

On the software side, I configure everything (Chrony, NTP, and PTP) with Ansible. Raspberry Pi OS / Debian is the base OS, which makes configuring all the appropriate software easy. Linux has a pretty robust set of timing-related libraries and packages, especially for PTP.

I won't go through the whole setup process in this post—for that, visit the time-pi repository.

Conclusion

My first post and video is about the Time Pi hardware and comparing it to some commercial offerings. It's been running stably as an NTP time server in my studio for months now, and I've even gotten GPS to work for timing when used with a battery near one of the exterior walls.

But I will be following up with more timing-related adventures (to be documented here and on YouTube):

  • Permanently installing an outdoor GPS antenna with my Dad, and exploring ways to combat GPS jamming
  • Configuring PTP and testing sync across a variety of target devices (including a consumer Intel motherboard!)
  • Testing various clock options, including diving deeper into Masterclock's own (pictured above)
  • Making another attempt at getting the Pi to interface with the open source Time Card, with it's chip-scale atomic clock (CSAC) for seriously overkill holdover performance
  • (Hopefully) building an ensemble clock with Masterclock to see if we can improve overall timing accuracy combining both our clocks together.
联系我们 contact @ memedata.com