Thread: [Linuxptp-users] How to configure a grand master
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
|
From: Keith S. <kei...@gm...> - 2018-08-01 21:00:21
|
I am new to PTP and having some difficulty setting up and configuring a grand master. Most of the documentation I have found talk about setting up slaves to grand masters but not configuring a grand master. In my setup, I have two machines on a LAN. One has a GPS receiver that provides a 1PPS in addition to spitting out a proprietary packet protocol. I am able to read and parse the packets to get the time. I have no other NTP or PTP servers. I installed ptp4l and phc2sys. I am also using hardware time stamping. 1. How do I get the time from the GPS receiver to PTP? Should I simply call settimeofday() to set the system clock? Or should I forward the time to an NTP daemon like ntpd or chronyd and have it set the system clock in conjunction with the PPS? 2. Do I need to pass the PPS to phc2sys? I'm assuming no because I'm trying to use the system clock as a master and the man page says, "This option can be used only with the system clock as the slave clock." 3. How do I synchronize the PHC to the system clock? Do I run phc2sys with "-a -r -r"? Or do I need something like "-s CLOCK_REALTIME -c eth0 -w"? 4. Do I need to mess around with the proportional and integral constants? 5. PTP uses TAI time, correct? How does ptp4l or phc2sys get the TAI-UTC offset? 6. Do ptp4l or phc2sys need to know about upcoming leap seconds? How does that information get passed to them? 7. Do I need to disable dynamic ticks in the kernel using nohz=off? Any help would be appreciated! Keith |
|
From: Richard C. <ric...@gm...> - 2018-08-02 03:34:25
|
On Wed, Aug 01, 2018 at 04:00:02PM -0500, Keith Squier wrote: > 1. How do I get the time from the GPS receiver to PTP? Ideally you feed the 1 PPS from the GPS into your PHC. Then write a program that reads out the 1 PPS time stamps from the PHC and disciplines the PHC to match the GPS time. You can then optionally use phc2sys to synchronize the Linux system time to the PHC. Regarding TAI-UTC, the GPS does provide the information needed to figure that offset. HTH, Richard |
|
From: Keith S. <kei...@gm...> - 2018-08-13 14:43:32
|
I apologize, but I'm completely new to all this timekeeping stuff, and I'm very confused. How do I feed the 1 PPS to the PHC? Do I use phc2sys? What API do I use to read the 1 PPS time stamps from the PHC and set the PHC? Instead of feeding the PPS to the PHC, reading the time stamps from the PHC, and then setting the PHC to match the GPS time, wouldn't it be better to have a separate program that reads the PPS and time from the GPS and sets the PHC? Of course, then I wonder what the point of the PPS is if I have the time from the GPS. Is it really this difficult to synchronize a system to a GPS receiver, or am I overthinking things? On Wed, Aug 1, 2018 at 10:34 PM Richard Cochran <ric...@gm...> wrote: > On Wed, Aug 01, 2018 at 04:00:02PM -0500, Keith Squier wrote: > > 1. How do I get the time from the GPS receiver to PTP? > > Ideally you feed the 1 PPS from the GPS into your PHC. Then write a > program that reads out the 1 PPS time stamps from the PHC and > disciplines the PHC to match the GPS time. > > You can then optionally use phc2sys to synchronize the Linux system > time to the PHC. > > Regarding TAI-UTC, the GPS does provide the information needed to > figure that offset. > > HTH, > Richard > |
|
From: Richard C. <ric...@gm...> - 2018-08-13 14:55:40
|
On Mon, Aug 13, 2018 at 09:43:13AM -0500, Keith Squier wrote: > How do I feed the 1 PPS to the PHC? Do I use phc2sys? No, you must physically connect the output pin of the GPS to the input pin of your MAC. (Of course, make sure the signals are compatible!) > What API do I use to > read the 1 PPS time stamps from the PHC and set the PHC? It is the same Linux PTP Hardware Clock API we use for everything. See the testptp.c program in the Linux kernel sources. > Instead of feeding the PPS to the PHC, reading the time stamps from the > PHC, and then setting the PHC to match the GPS time, wouldn't it be better > to have a separate program that reads the PPS and time from the GPS and > sets the PHC? This is exactly what I am suggesting. > Of course, then I wonder what the point of the PPS is if I > have the time from the GPS. If you don't use the PPS, then the PHC won't be synchronized to the GPS. You want to be a GM, right? > Is it really this difficult to synchronize a system to a GPS receiver, or > am I overthinking things? Yes, it is difficult, but it isn't rocket science either. HTH, Richard |
|
From: Keith S. <kei...@gm...> - 2018-08-13 18:29:14
|
Thank you for helping me. I'm going to reiterate to make sure I'm understanding correctly. I need to physically connect the 1 PPS output pin to an input pin on my network card. Then I need to write a program that reads the 1 PPS from the PHC and sets the PHC clock to match the GPS time (using testptp.c as an example). Then I need to use phc2sys to synchronize the system clock to the PHC. Is that correct? Does this mean I don't need an NTP server like ntpd or chrony? I've read about other configurations where people feed the PPS and NMEA sentences from the GPS into gpsd, which then feeds the time to ntpd/chrony to set the Linux system clock, which is then used to synchronize the PHC using phc2sys. Your method is skipping NTP altogether. Wouldn't an NTP server more smoothly adjust the system clock? Or does PTP handle that, too? On Mon, Aug 13, 2018 at 9:55 AM Richard Cochran <ric...@gm...> wrote: > On Mon, Aug 13, 2018 at 09:43:13AM -0500, Keith Squier wrote: > > How do I feed the 1 PPS to the PHC? Do I use phc2sys? > > No, you must physically connect the output pin of the GPS to the input > pin of your MAC. (Of course, make sure the signals are compatible!) > > > What API do I use to > > read the 1 PPS time stamps from the PHC and set the PHC? > > It is the same Linux PTP Hardware Clock API we use for everything. > See the testptp.c program in the Linux kernel sources. > > > Instead of feeding the PPS to the PHC, reading the time stamps from the > > PHC, and then setting the PHC to match the GPS time, wouldn't it be > better > > to have a separate program that reads the PPS and time from the GPS and > > sets the PHC? > > This is exactly what I am suggesting. > > > Of course, then I wonder what the point of the PPS is if I > > have the time from the GPS. > > If you don't use the PPS, then the PHC won't be synchronized to the > GPS. You want to be a GM, right? > > > Is it really this difficult to synchronize a system to a GPS receiver, or > > am I overthinking things? > > Yes, it is difficult, but it isn't rocket science either. > > HTH, > Richard > |