Selectable Precision Time Source (Chrony & PTP)

Hello all,

I currently am using an Apalis iMX6Q IT module running a custom OpenEmbedded linux (Dunfell) distribution. This module is connected to a GPS module with PPS output. We have a requirement for this to operate in any of the following modes (selectable at runtime):

  • GPS Time - This mode is implemented using Chrony and currently works as expected
  • PTP Master - With the GPS module with PPS being used as the GrandMaster clock
  • PTP Slave - I assume disable Chrony and enable ptp4l daemon and all is well

I have installed Linux PTP in to the kernel. Now my question is, has anyone done this before? It seems that Chrony does not support this and that maybe will have to be disabled for PTP. But then how does the PTP daemon sync with the GPS clock. The documentation for both daemons doesn’t really cover this particular use case. So I am reaching out for any thoughts, ideas, directions to head in on this. Thanks.

Hello @morgan1361,
Which of the three modes is currently giving you trouble? I don’t have real experience with clock synchronization, but I found this page that could help you configure it properly:

https://tsn.readthedocs.io/timesync.html

From this page, it’s my impression that the Grand Master will be automatically selected in the network based on this “Best Master Clock Algorithm”. It seems that if you have a node with a suitable high-resolution clock source (such as GPS) it should eventually be selected as the master clock source, but I could be wrong about this.

Please let us know if you are having specific problems with one of the modes.

Hello @rafael.tx

Thank you for reaching out. So under almost all use cases, this device will be used in GPS Time mode and output nothing over ethernet. Now we have a client that is requiring that we support both PTP Master and PTP Slave which needs to be selectable.

The problem that I am running in to is, how does the PTP daemon use the GPS as a GM clock. It seems that the daemon is designed to be sent PTP from a Stratum 2 time source (Boundary Clock) and then it rehosts it as a master. This is not going to work as the only precision source of time is the GPS. So I need whatever PTP daemon is running to use the GPS module as the GM and then source the time over PTP. I hope this makes sense.

-Mike

Hello @morgan1361,
My limited understanding is that you need to configure the correct parameters of ptp4l and it will figure out if needs to run in GM mode or not and agree with the peers on the network about who should be providing the clock and who should be a slave. The linuxptp documentation doesn’t seem to have an example of what you are trying to achieve.

I found some documents that explain the conceptual part:

https://blog.meinbergglobal.com/2022/03/11/bmca-deep-dive-part-2/

It also seems that you can forget about chrony and implement all you need with only the tools that come from linuxptp, but I’m also not completely sure.