<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=LordMike</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=LordMike"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/LordMike"/>
	<updated>2026-05-06T14:40:38Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Chrony_and_GPSD&amp;diff=18700</id>
		<title>Chrony and GPSD</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Chrony_and_GPSD&amp;diff=18700"/>
		<updated>2021-03-13T19:38:02Z</updated>

		<summary type="html">&lt;p&gt;LordMike: Replace incorrect acronym NEMA with correct NMEA&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Sources such as:&lt;br /&gt;
&lt;br /&gt;
* http://www.rjsystems.nl/en/2100-ntpd-garmin-gps-18-lvc-gpsd.php&lt;br /&gt;
* http://lists.ntp.org/pipermail/questions/2005-November/007878.html&lt;br /&gt;
&lt;br /&gt;
Describe how to wire a Garmin gps 18 lvc to a serial port to grab the PPS (pulse-per-second) signal to create a Stratum 1 timesource.  Other sources show using ntpd, and the [http://gpsd.berlios.de/gpsd.html gpsd man page] provides config snippets.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Alpine Linux gpsd package 3.9-r1 and higher has the necessary pps code to interface with chrony.   This page lists all of the files for a complete, working example:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* /etc/modules needs to list the pps_ldisc module - you&#039;ll need to manually load it if not doing a reboot&lt;br /&gt;
{{Cat|/etc/modules|pps_ldisc}}&lt;br /&gt;
* If the GPS 18 LVC is on /dev/ttyS1, then:&lt;br /&gt;
{{Cat|/etc/conf.d/gpsd|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
# Copyright 1999-2010 Gentoo Foundation&lt;br /&gt;
# Distributed under the terms of the GNU General Public License v2&lt;br /&gt;
&lt;br /&gt;
# Config file for gpsd server&lt;br /&gt;
# Optional arguments&lt;br /&gt;
#  Options include:&lt;br /&gt;
#   -b                        = bluetooth-safe: open data sources read-only&lt;br /&gt;
#   -n                        = don&#039;t wait for client connects to poll GPS&lt;br /&gt;
#   -N                        = don&#039;t go into background&lt;br /&gt;
#   -F sockfile               = specify control socket location&lt;br /&gt;
#   -G                        = make gpsd listen on INADDR_ANY&lt;br /&gt;
#   -D integer (default 0)    = set debug level&lt;br /&gt;
#   -S integer (default 2947) = set port for daemon&lt;br /&gt;
&lt;br /&gt;
GPSD_OPTIONS=&amp;quot;-n -b&amp;quot;&lt;br /&gt;
DEVICES=&amp;quot;/dev/ttyS1&amp;quot;&lt;br /&gt;
GPSD_SOCKET=&amp;quot;/var/run/gpsd.sock&amp;quot;&lt;br /&gt;
BAUDRATE=&amp;quot;4800&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Serial setup&lt;br /&gt;
#&lt;br /&gt;
# For serial interfaces, options such as low_latency are recommended&lt;br /&gt;
# Also, http://catb.org/gpsd/upstream-bugs.html#tiocmwait recommends&lt;br /&gt;
#   setting the baudrate with stty&lt;br /&gt;
# Uncomment the following lines if using a serial device:&lt;br /&gt;
#&lt;br /&gt;
/bin/stty -F ${DEVICE} ${BAUDRATE}&lt;br /&gt;
/bin/setserial ${DEVICE} low_latency&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Note|As of v3.11, the init.d and conf.d files have been merged from gentoo.&lt;br /&gt;
The purpose is to allow gpsd to start without editing /etc/conf.d/gpsd.&lt;br /&gt;
Note that while gpsd will now start without editing the conf.d file, it will do so with no gps devices attached.  &lt;br /&gt;
&lt;br /&gt;
Also note that if you are using a serial device it is still recommended to add the stty and setserial commands as noted in the example configuration above.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* This shows all four methods of getting time from gpsd:&lt;br /&gt;
{{Cat|/etc/chrony/chrony.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server 0.pool.ntp.org&lt;br /&gt;
server 1.pool.ntp.org&lt;br /&gt;
server 2.pool.ntp.org&lt;br /&gt;
&lt;br /&gt;
initstepslew 30 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org&lt;br /&gt;
&lt;br /&gt;
# SHM0 from gpsd is the NMEA data at 4800bps, so is not very accurate&lt;br /&gt;
refclock SHM 0  delay 0.5 refid NMEA&lt;br /&gt;
&lt;br /&gt;
# SHM1 from gpsd (if present) is from the kernel PPS_LDISC&lt;br /&gt;
# module.  It includes PPS and will be accurate to a few ns&lt;br /&gt;
refclock SHM 1 offset 0.0 delay 0.1 refid NMEA+&lt;br /&gt;
&lt;br /&gt;
# SOCK protocol also includes PPS data and &lt;br /&gt;
# it also provides time within a few ns&lt;br /&gt;
refclock SOCK /var/run/chrony.ttyS1.sock delay 0.0 refid SOCK&lt;br /&gt;
&lt;br /&gt;
# PPS is from the /dev/pps0 device.  Note that&lt;br /&gt;
# chronyd creates the /var/run/chrony.ttyS1.sock device, but&lt;br /&gt;
# gpsd creates the /dev/pps0 device&lt;br /&gt;
# openrc rules start gpsd /after/ chronyd, so /dev/pps0 &lt;br /&gt;
#   is not created until after chronyd is started&lt;br /&gt;
#   If you want to use pps0, either edit the openrc rules&lt;br /&gt;
#   or add this source after gpsd is started&lt;br /&gt;
&lt;br /&gt;
# refclock PPS /dev/pps0 refid PPS&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# If you see something in ns... its good.&lt;br /&gt;
#          1 second =&lt;br /&gt;
#       1000 ms =&lt;br /&gt;
#    1000000 us =&lt;br /&gt;
# 1000000000 ns&lt;br /&gt;
&lt;br /&gt;
logchange 0.5&lt;br /&gt;
local stratum 10&lt;br /&gt;
&lt;br /&gt;
logdir /var/log/chrony&lt;br /&gt;
&lt;br /&gt;
keyfile /etc/chrony/chrony.keys&lt;br /&gt;
commandkey 10&lt;br /&gt;
&lt;br /&gt;
dumpdir /var/log/chrony&lt;br /&gt;
driftfile /var/log/chrony/chrony.drift&lt;br /&gt;
&lt;br /&gt;
allow all&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Chronyc ==&lt;br /&gt;
&lt;br /&gt;
If everything is working correctly, a chronyc &#039;sources&#039; command should look like this:&lt;br /&gt;
&lt;br /&gt;
 chronyc&amp;gt; sources&lt;br /&gt;
 210 Number of sources = 6&lt;br /&gt;
 MS Name/IP address         Stratum Poll Reach LastRx Last sample&lt;br /&gt;
 ===============================================================================&lt;br /&gt;
 #x NMEA                          0   4   377    14   +684ms[ +684ms] +/-  252ms&lt;br /&gt;
 #+ PPS                           0   4   377    13  +2040ns[+2060ns] +/-   50ms&lt;br /&gt;
 #* SOCK                          0   4   377     7   +225ns[ +245ns] +/- 2217ns&lt;br /&gt;
 ^? tick.tock.com                 2  10   377   318  -5144us[-5144us] +/-   72ms&lt;br /&gt;
 ^? time.keeper.net               3  10   377   720  -4571us[-4567us] +/-  139ms&lt;br /&gt;
 ^? dead.time.server.org          0  10     0   10y     +0ns[   +0ns] +/-    0ns&lt;br /&gt;
&lt;br /&gt;
* NMEA (SHM0)  is &amp;quot;x&amp;quot; - its really unstable&lt;br /&gt;
* PPS (SHM1) is good, but the delay of 0.1 makes it the not-preferred master&lt;br /&gt;
* SOCK is the preferred master&lt;br /&gt;
* The other NTP servers are only used if the local server goes down.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
* In /etc/chrony/chrony.conf, there are four possible time sources:&lt;br /&gt;
** SHM 0  (NMEA serial data)&lt;br /&gt;
** SHM 1  (NMEA with PPS)&lt;br /&gt;
** SOCK   (PPS &#039;proprietary&#039; gpsd/chrony interface)&lt;br /&gt;
** PPS    (PPS only from the serial interface pulse)&lt;br /&gt;
* You only need 1 of them, although 3 are shown above&lt;br /&gt;
* In the example above, SHM1 is specified with a delay of 0.1 to prevent it from competing with the SOCK protocol&lt;br /&gt;
** If you prefer to use the SHM1  source instead of SOCK, then either:&lt;br /&gt;
*** comment out the SOCK protocol line&lt;br /&gt;
*** or reverse the delay values.&lt;br /&gt;
* Note that the SHM0 source (NMEA only, no PPS) is set to a higher delay - don&#039;t use it if you have PPS available.&lt;br /&gt;
** An example of where you would want to use SHM0 is a USB based gps receiver - they don&#039;t have the PPS line&lt;br /&gt;
* Chrony creates the SOCK interface; chrony should be started before gpsd.   If you restart chronyd for some reason, make sure you restart gpsd after.&lt;br /&gt;
* The SHM0 interface can be used with USB based gps devices.   In this case, use /dev/ttyUSBX in the /etc/conf.d/gpsd file, and leave the stty and setserial lines commented out.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>LordMike</name></author>
	</entry>
</feed>