-
-
Notifications
You must be signed in to change notification settings - Fork 5
Get PTP configuration tied up and daemonized #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was trying to use timemaster to set up both chrony and linuxptp but got sidetracked. Maybe this would be of interest to get both tied together? |
@jauderho - I was planning on configuring the individual portions by hand, but timemaster does seem like a potential way to tie it all together as well. |
Hmm... also https://github.com./MaciekMachni/ptp_recipes/blob/main/grandmaster.md for a tidy config (assuming NTP not running, in this case; see this NetDevConf presentation). |
Also just testing it manually. In first session:
And second session:
[edit: This is still happening today if I try to run the same commands.] |
This comment has been minimized.
This comment has been minimized.
Interesting aside on If I just run it unprivileged (
Instead of using auto config, I tried forcing it (on the grandmaster) to sync the eth1 PHC:
|
On a slave Pi:
Letting it run a while, I see it settle in around 30-60ns sometimes, but then it gets jumpy up to 300 to -300 ns offset. Not the best :P Using the
|
On the grandmaster node:
|
After working through #12 and #13, I have been able to get GPS PPS to the PHY, then used the PHY for Chrony (so it sends that time out over NTP), but I'm still dealing with three issues:
I also need to wrap all the ptp4l/phc2sys/ts2phc configuration into files and systemd units. Great guide from @Nerdy-Austin here: https://austinsnerdythings.com/2025/02/18/nanosecond-accurate-ptp-server-grandmaster-and-client-tutorial-for-raspberry-pi/ — after that, also make sure to add a battery to the Pi's RTC battery header, so it can hold over at least using the little built in XO during an outage or reboot. I also have had another read through @jclark's excellent ts2phc guide, and am happy to see a very tiny offset confirmed between the system clock and the PHC:
|
My satpulse project https://satpulse.net is designed to make this a lot easier. It can automatically handle NICs that timestamp both edges. First, it detects whether the NIC is one that does this. Second, if so, it can detect/configure the pulse width on u-blox receivers to distinguish the edges. If the pulse width is 0.1s and you have two pulses 0.1s apart, then you know the first one is the rising edge. Getting your setup working with satpulse would involve:
Hooking it up to chrony would involve:
I have this running on 7 different NIC/GPS combos and have some Ansible playbooks to automate the deployment and testing of whether it is working. It can write nice logs of the PHC/PPS offsets and there's a python script for analyzing those. The other checking mechanism is to have chrony setup to use both satpulse and several other NTP time servers (including a very accurate local one): if things go wrong (so satpulse doesn't match the others), chrony will use the other NTP servers, and so drop down to stratum 2. |
Working on daemonizing the config on the mini-time server, not on the one currently connected via Ethernet (mini-time is currently on WiFi so it can get good GPS reception). When 'port 1' is not connected I get a
Edit: Testing that theory, I plugged in a cable and
|
I have almost everything wrapped into automation now, but I'm still missing a couple bits, I think. I have a temporary antenna routed up into my ceiling area, so I'll let the whole thing chill overnight and see how things are synced in the morning with a 2nd Pi on my desk (which is going through three switches...). |
I'm also not syncing time of day... need to figure that out. Also saw the Tindie description is having same issue. (see below). Maybe need ptp4l v4?
|
@jclark - Just now seeing your post on satpulse. I had a note somewhere to test it out... and probably will soon. I'm finally reaching the point where I halfway understand how all these parts are working, so using satpulse would be useful in terms of seeing whether it has any of the same annoying issues I'm seeing (some that don't appear until after it's been going for an hour or two) with the i226. I can adjust my playbook to use satpulse instead, at some point. United efforts definitely would keep things tidier :) |
I broke out the satpulse discussion to #16 — still want to get things wrapped up in here separately, then work on untangling everything once I have it working, and seeing if there are some things I still want to manage separately from Satpulse (or anything in my setup that could be added as an option in Satpulse...). |
Right now I have a couple tasks in the
ptp.yml
tasks file that I still need to write:Time Pi - Grandmaster
sudo phc2sys -s CLOCK_REALTIME -c eth1 -m -O 0
sudo ts2phc -c /dev/ptp0 -s generic --ts2phc.pin_index 2 --ts2phc.extts_polarity both --ts2phc.pulsewidth 100000000 -m -l 7
extts_polarity
andpulsewidth
would not be needed with the patch referenced in that issue)eth1
:sudo ptp4l -i eth1 -m --masterOnly 1
(could be--serverOnly
on newer versions of linuxPTP)/etc/linuxptp/ptp4l.conf
?sudo phc2sys -s /dev/ptp0 -c CLOCK_REALTIME --step_threshold=1 --transportSpecific=1 -O 37 -m
(NOTE: This offset is the current offset between TAI and UTC—it can change depending on leap seconds!)Testing Sync on the Grandmaster:
Use
testptp
to set PPS out on the proper pin:sudo testptp -d /dev/ptp0 -L0,2
(for the SMA closest to the 40-pin GPIO header)sudo testptp -d /dev/ptp0 -p 1000000000
Slave/Client Pi
This example assumes a Pi running Pi OS:
sudo apt install -y linuxptp
sudo systemctl stop systemd-timesyncd
sudo ptp4l -i eth0 --step_threshold=1 -m --slaveOnly 1
to begin time sync over PTPport 1: new foreign master 00a0c9.fffe.000002-1
, and then theoffset
values should settle in < 100ns. Ideally...sudo phc2sys -s eth0 -c CLOCK_REALTIME -q -m -w
To check if clocks are configured correctly and PTP is happy:
For reference:
The text was updated successfully, but these errors were encountered: