Changes between Initial Version and Version 1 of timesync


Ignore:
Timestamp:
10/31/2017 09:31:08 PM (7 years ago)
Author:
Tim Harvey
Comment:

restored html from 2017/10/17 cache

Legend:

Unmodified
Added
Removed
Modified
  • timesync

    v1 v1  
     1{{{#!html
     2
     3<h1 id="LinuxTimeSyncrhronization"><b style="color:#000;background:#66ffff">Linux Time Syncrhronization</b></h1>
     4<p>
     5Many applications in factory automation, test and measurement, and telecommunications require very close time synchronization. The use case for this for our customers is often scenarios where they have multiple boards transmitting on the same RF channel and they want to synchronize the system clocks to a precision that allows the boards to Time Division Multiplex (TDM) the use of the transmitters so they are not producing collisions and thus maximizing RF throughput as this is the most efficient way of utilizing available bandwidth.
     6</p>
     7<p>
     8There are two common solutions to this problem:
     9</p>
     10<ul><li><a class="wiki" href="/wiki/linux/timesync#ieee1588-ptp">IEEE 1588 Precision Time Protocol (PTP)</a> - uses Ethernet frames
     11</li><li><a class="wiki" href="/wiki/linux/timesync#gps-pps">GPS Pulse-Per-Seconds</a> - uses GPS information
     12</li></ul><p>
     13<span class="wikianchor" id="ieee1588-ptp"></span>
     14</p>
     15<h2 id="TimesynchronizationviaIEEE1588PrecisionTimeProtocolPTPEthernet">Time synchronization via IEEE 1588 Precision Time Protocol (PTP) (Ethernet)</h2>
     16<p>
     17The purpose of the IEEE 1588 Precision Time Protocol (PTP) is to synchronize the time between different nodes on an Ethernet network.
     18</p>
     19<p>
     20The Linux kernel has IEEE 1588 PTP support for a handful of ethernet devices that offer this feature including the Freescale IMX6 FEC which is used as eth0 on the majority of the Gateworks Ventana boards including the GW51xx, GW52xx, GW53xx, and GW54xx (Note GW5520 does not use the IMX6 FEC and instead provides 2x full GigE capable PCIe based MAC/PHY devices so it lacks IEEE 1588 hardware support).
     21</p>
     22<p>
     23In hardware PTP the ethernet MAC is responsible for getting and setting the timestamps to remove latency of the queuing and network stack which provides the best accuracy.
     24</p>
     25<p>
     26The <a class="ext-link" href="http://linuxptp.sourceforge.net/"><span class="icon">​</span>Linux PTP</a> project is an implementation of the IEEE 1588 for Linux featuring:
     27</p>
     28<ul><li>Supports hardware and software time stamping via the Linux SO_TIMESTAMPING socket option.
     29</li><li>Supports the Linux PTP Hardware Clock (PHC) subsystem by using the clock_gettime family of calls, including the new clock_adjtimex system call.
     30</li><li>Implements Boundary Clock (BC) and Ordinary Clock (OC).
     31</li><li>Transport over UDP/IPv4, UDP/IPv6, and raw Ethernet (Layer 2).
     32</li><li>Supports IEEE 802.1AS-2011 in the role of end station.
     33</li><li>Modular design allowing painless addition of new transports and clock servos.
     34</li></ul><p>
     35The linuxptp package is install on the Gateworks Ventana Yocto v1.8 BSP.
     36</p>
     37<p>
     38Example usage on a GW54xx:
     39</p>
     40<ul><li>master:
     41<pre class="wiki">root@ventana:~# ptp4l -i eth0 -m
     42ptp4l[112.404]: selected /dev/ptp0 as PTP clock
     43ptp4l[112.409]: driver changed our HWTSTAMP options
     44ptp4l[112.409]: tx_type   1 not 1
     45ptp4l[112.409]: rx_filter 1 not 12
     46ptp4l[112.409]: port 1: INITIALIZING to LISTENING on INITIALIZE
     47ptp4l[112.409]: port 0: INITIALIZING to LISTENING on INITIALIZE
     48ptp4l[120.064]: port 1: LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES
     49ptp4l[120.065]: selected best master clock 00d012.fffe.13f09d
     50ptp4l[120.065]: assuming the grand master role
     51</pre><ul><li>the ptp4l tries to use hardware time stamping by default, otherwise you can use the '-H' to force hardware timestamping, or '-S' to force software timestamping
     52</li><li>the -m parameter tells ptp4l to output messages to the console
     53</li><li>no master was found so this target became the master
     54</li></ul></li><li>slave:
     55<pre class="wiki">ptp4l[228.234]: selected /dev/ptp0 as PTP clock
     56ptp4l[228.239]: driver changed our HWTSTAMP options
     57ptp4l[228.239]: tx_type   1 not 1
     58ptp4l[228.239]: rx_filter 1 not 12
     59ptp4l[228.239]: port 1: INITIALIZING to LISTENING on INITIALIZE
     60ptp4l[228.239]: port 0: INITIALIZING to LISTENING on INITIALIZE
     61ptp4l[229.995]: port 1: new foreign master 00d012.fffe.13f09d-1
     62ptp4l[233.995]: selected best master clock 00d012.fffe.13f09d
     63ptp4l[233.995]: port 1: LISTENING to UNCALIBRATED on RS_SLAVE
     64ptp4l[235.995]: master offset 250446314787536 s0 freq      +0 path delay      3768
     65ptp4l[236.995]: master offset 250446314782408 s1 freq   -5128 path delay      3768
     66ptp4l[237.995]: master offset      -1635 s2 freq   -6763 path delay      3768
     67ptp4l[237.995]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED
     68ptp4l[238.995]: master offset        754 s2 freq   -4864 path delay      2996
     69ptp4l[239.995]: master offset       1083 s2 freq   -4309 path delay      2404
     70ptp4l[240.995]: master offset        248 s2 freq   -4819 path delay      2404
     71ptp4l[241.995]: master offset        -53 s2 freq   -5046 path delay      2372
     72ptp4l[242.995]: master offset       -129 s2 freq   -5138 path delay      2341
     73</pre></li><li>this was started after the master, so it found the master and became a slave
     74</li></ul><p>
     75References:
     76</p>
     77<ul><li><a class="ext-link" href="http://events.linuxfoundation.org/sites/events/files/slides/lcjp14_ichikawa_0.pdf"><span class="icon">​</span>Introduction to linuxptp</a>
     78</li><li><a class="ext-link" href="http://linuxptp.sourceforge.net/"><span class="icon">​</span>Linux PTP Project</a>
     79<ul><li><a class="ext-link" href="http://sourceforge.net/p/linuxptp/code/ci/master/tree/"><span class="icon">​</span>Linux PTP code</a>
     80</li></ul></li><li><a class="ext-link" href="https://github.com/torvalds/linux/blob/master/Documentation/ptp/ptp.txt"><span class="icon">​</span>Linux PTP Documentation</a>
     81<ul><li><a class="ext-link" href="https://github.com/torvalds/linux/blob/master/Documentation/ABI/testing/sysfs-ptp"><span class="icon">​</span>sysfs API</a>
     82</li><li><a class="ext-link" href="https://github.com/torvalds/linux/blob/master/Documentation/ptp/testptp.c"><span class="icon">​</span>userspace test program</a>
     83</li></ul></li><li><a class="ext-link" href="http://www.ixxat.com/introduction_ieee_1588_en.html"><span class="icon">​</span>IEEE 1588 PTP Introduction</a>
     84</li><li><a class="ext-link" href="https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-Configuring_PTP_Using_ptp4l.html"><span class="icon">​</span>Configuring PTP Using ptp4l</a>
     85</li></ul><p>
     86<span class="wikianchor" id="gps-pps"></span>
     87</p>
     88<h1 id="TimesynchronizationviaPPSPulse-Per-SecondGPS">Time synchronization via PPS (Pulse-Per-Second) (GPS)</h1>
     89<p>
     90One handy feature of an on-board GPS is that it can deliver Pulse-Per-Second (PPS) signal. This signal can be used to get a high-precision time reference that an application can use to adjust system clock time. Common use is to configure the Network Time Protocol Daemon (NTPD) with a PPS source to obtain a wallclock-time with sub-millisecond synchronization to UTC.
     91</p>
     92<p>
     93See <a class="wiki" href="/wiki/gps#pps">the GPS page</a> for more info
     94</p>
     95</div>
     96         
     97          <div class="trac-modifiedby">
     98            <span><a href="/wiki/linux/timesync?action=diff&amp;version=2" title="Version 2 by tharvey: added example usage">Last modified</a> <a class="timeline" href="/timeline?from=2015-08-27T16%3A41%3A56-07%3A00&amp;precision=second" title="See timeline at 08/27/15 16:41:56">2 years ago</a></span>
     99            <span class="trac-print">Last modified on 08/27/15 16:41:56</span>
     100          </div>
     101       
     102       
     103      </div>
     104     
     105
     106    </div>
     107    <div id="altlinks">
     108      <h3>Download in other formats:</h3>
     109      <ul>
     110        <li class="last first">
     111          <a rel="nofollow" href="/wiki/linux/timesync?format=txt">Plain Text</a>
     112        </li>
     113      </ul>
     114    </div>
     115    </div>
     116    <div id="footer" lang="en" xml:lang="en"><hr />
     117      <a id="tracpowered" href="http://trac.edgewall.org/"><img src="/chrome/common/trac_logo_mini.png" height="30" width="107" alt="Trac Powered" /></a>
     118      <p class="left">Powered by <a href="/about"><strong>Trac 1.0</strong></a><br />
     119        By <a href="http://www.edgewall.org/">Edgewall Software</a>.</p>
     120      <p class="right">Visit the Trac open source project at<br /><a href="http://trac.edgewall.org/">http://trac.edgewall.org/</a></p>
     121    </div>
     122
     123}}}