Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Search this Thread
Old 09-13-2006, 05:43 AM   #1
Senior Member
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,593

Rep: Reputation: 162Reputation: 162
Post How To Use A Garmin 18 GPS Unit As An NTP Server With Microsecond Precision

It took me a bit of experimentation to figure out how to get 1 us
precision with the Garmin 18 LVC on linux.


Garmin 18 LVC, soldered on a DB-9 connector for serial comm and PPS, and
a USB cable for 5 V power according to Terje:

Rodolfo's Git repo for LinuxPPS:


Udo van den Heuvel's ntpd NMEA patch:

Linux Kernel:


CD 1 of Debian "testing" - Etch:

I stuck the gps unit out the window on a flat piece of steel about 3
feet long, fastened to the aluminum storm and screen sill with self
tapping sheet metal screws. It only requires the flimsiest piece of
steel, with the edges bent downwards for rigidity and to brace the steel
against the storm and screen unit and keep it from flopping down. The
Garmin unit is magnetic, and stuck on the steel plate stock by itself.
This configuration has stood up to high winds, and a blizzard. I used
the 18 LVC 5 meter cable model for extra reach. To check if your unit
is connected right you can do:

cat /dev/ttyS0

and you should see some NMEA sentences on the screen every second.
There is an MS Windows program called SNSRCFG.exe available from Garmin
if you go to the OEM section of their site. (I knew there was some
reason for that XP partition) I have three 18 LVC's, and none of them
came from the factory with PPS activated. I downloaded SNSRCFG.exe:

and ran it from a Windows XP installation. It was weird, but Windows
detected the Garmin as a serial mouse, and the cursor moved wantonly,
all over the desktop, creating mayhem; driven by the gps NMEA sentences.
So, I connected the gps after Windows booted. Then Windows didn't think
it was a mouse. Launch SNSRCFG, Leave baud rate on auto, and select com
1. I only want sentences $GPGGA, $GPGLL, and $GPRMC; and so disabled
the rest. I activated PPS, leaving everything else just the way it is.
I checked if the unit was in NMEA mode, and it was. The default 200 ms
PPS length seems adequate, and the assert edge of the signal is what
Garmin calibrates to UTC. I didn't need to know that for SNSRCFG.exe,
but I did for ntp.conf.

The 18 LVC and 18 5 Hz are the only Garmin 18s that have PPS signals. I
tried getting PPS activated on a 18 PC model and it wouldn't work. The
USB model doesn't even have enough wires (only 4) to physically be able
to have a separate PPS signal wire.

Rodolfo's git repository instructions:

to build a kernel patch for kernel Rodolfo's LinuxPPS wiki is

A very helpful page is Philip M. White's:

Which describes an excellent method of building a Garmin 18 LVC
reference clock. The ntp-nmea.patch is on his site, although I'm fairly
sure that is not his real name.

I copied the linux- kernel sources:
curl -O

Curl puts the file in current working directory, and is fast. I used
Debian Etch installed using CD 1 with a Debian mirror chosen during the
install for the bulk of necessary files. Debian Etch is a lean mean
distro, and easy to work with.

cp linux- /usr/src

Install qt development packages, kernel-package,
linux-patch-debian-2.6.17, git-core and yaird with:


I needed to do an access and update with dselect, so have the URL of at
least 1 Debian mirror written down. I use:

for an apt source. I also get rid of CDROM as a source or Debian always
asks for it when I install software. If I keep it in the drive it boots
the machine from the CD whenever I reboot. So, I just take it out. I
extract the kernel sources in /usr/src with:

tar xvfj *3*

because there is nothing in /usr/src with a 3 in the filename besides
linux- After the file extracts it makes a directory
called linux-, which I make a symlink to like this:

debian3:/usr/src # ln -s *3 linux

because the directory I want to symlink to is the only thing in /usr/src
that ends with 3. I made the LinuxPPS patch from the LinuxPPS git
repository, which, because I read the instructions in the instructions
link I gave earlier, was resident on my HDD. I copied the patch
to /usr/src/linux. I needed to make the patch from inside the
directory /home/sam/linuxpps.

To patch the kernel:

debian3:/usr/src/linux # patch -p1 -i <linuxpps-patch>


failed to patch correctly. I opened the patch file in one terminal,
searched for netlink.h, and found the part of the patch that referred to
netlink.h. In nano this function is "ctrl w". Then, I
opened /usr/src/linux/include/linux/netlink.h, and did a search for the
line and column number where the patch was supposed to go. In nano you
do "ctrl-shift-_", and enter line, column. It is fairly easy from this
point to manually patch netlink.h with the PPS line.

cp /boot/config-2.6.xx.y /usr/src/linux/.config

make xconfig

I don't try to change things I don't have to. You need to check "Prompt
for experimental drivers" to have the PPS module visible down the list.
I compiled serial drivers in with the kernel. I needed to select PPS
drivers to be compiled with the kernel also. PPS 8250 support is
needed. I can select both as modules, but can't make one a module and
one compiled in with the kernel. I save the .config file, and do:

make-kpkg --added-patches=debian --revision=xyz kernel_image

This will make a .deb file of the kernel image in /usr/src. When the
compile is done, I cd .. out of /usr/src/linux into /usr/src and do:

dpkg -i *.deb

Then do:

yaird --output=/boot/initrd.img-<space>

Then do:

nano /boot/grub/men*

and change the new kernel entry to reflect an initrd file named
initrd.img- by adding an initrd line after the kernel line in
the first boot entry. I edit the kernel line to read noapic nolapic
acpi=off noapm at the end of the line because I don't want any of that
running with the time server when I reboot. Reboot with the new kernel.

cp /usr/src/linux- timex.h /usr/include/

I used ntp-4.2.2p4.tar.gz from the site. You need the
ntp-nmea.patch file from Philip M. White's page.
After you extract the ntp-4.2.2p4.tar.gz file with

cd /home/sam

or wherever the ntp archive file is.

tar zxvf *2p4*

cd *4

cp ../*nm* ntp-nmea.patch

patch -p1 -i *.patch

./configure --disable-all-clocks --disable-parse-clocks --enable-NMEA
--enable-LOCAL-CLOCK --enable-linuxcaps


nano /etc/ntp.conf

#ntp.conf, ntp configuration

restrict default nomodify


server minpoll 4 prefer
fudge time1 0.0 flag3 1 flag2 0


driftfile /var/lib/ntp/drift

keys /etc/ntp/keys

logconfig = +syncall +clockall +sysall +peerall
logfile /var/log/ntpd.log

statsdir /var/lib/ntp/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

save the file and exit

mkdir /etc/ntp
touch /etc/ntp/keys

mkdir /var/lib/ntp
touch /var/lib/ntp/drift
chmod g+w /var/lib/ntp/drift

mkdir /var/lib/ntp/ntpstats
touch /var/lib/ntp/ntpstats/loopstats
touch /var/lib/ntp/ntpstats/clockstats
touch /var/lib/ntp/ntpstats/peerstats

touch /var/log/ntpd.log

ln -s /dev/ttyS0 /dev/gps0

from the ntp directory where I configure and make the ntp programs, as

ntpd/./ntpd -g

And in a tabbed terminal:

tail -f /var/log/ntpd.log
tail -f /var/lib/ntp/ntpstats/peerstats
tail -f /var/lib/ntp/ntpstats/loopstats
tail -f /var/lib/ntp/ntpstats/clockstats

then try ntpq/./ntpq -c rv -p

I've gotten excellent performance with this method:

debian1:/home/tom/time/ntp-4.2.2p4# ntpq/./ntpq -c rv -p
assID=0 status=0444 leap_none, sync_uhf_clock, 4 events,
version="ntpd 4.2.2p4 at 1.1585-o Wed Nov 29 23:30:04 UTC 2006 (1)",
processor="i686", system="Linux/", leap=00, stratum=1,
precision=-20, rootdelay=0.000, rootdispersion=0.376, peer=7197,
refid=GPS, reftime=c918dda8.2ecfb2e2 Wed, Nov 29 2006 22:33:44.182,
poll=5, clock=c918ddb0.cf8c2d4d Wed, Nov 29 2006 22:33:52.810, state=4,
offset=0.000, frequency=57.894, jitter=0.003, noise=0.001,
stability=0.001, tai=0
remote refid st t when poll reach delay offset
*GPS_NMEA(0) .GPS. 0 l 8 16 377 0.000 0.000
0.003 .ACTS. 1 u 64 64 377 50.920 1.247
2.821 .ACTS. 1 u 59 64 377 60.612 3.590
1.838 .ACTS. 1 u 50 64 367 61.990 4.104
+time-c.timefreq .ACTS. 1 u 1 64 377 50.955 1.217

debian1:/home/tom/time/ntp-4.2.2p4# ntpdc/./ntpdc
ntpdc> kern
pll offset: 0 s
pll frequency: 57.894 ppm
maximum error: 0.001504 s
estimated error: 1e-06 s
status: 0001 pll
pll time constant: 1
precision: 1e-06 s
frequency tolerance: 512 ppm

ntpdc> sysinfo
system peer: GPS_NMEA(0)
system peer mode: client
leap indicator: 00
stratum: 1
precision: -20
root distance: 0.00000 s
root dispersion: 0.00035 s
reference ID: [GPS]
reference time: c918ddb8.2f086614 Wed, Nov 29 2006 22:34:00.183
system flags: auth monitor ntp kernel stats
jitter: 0.000000 s
stability: 0.000 ppm
broadcastdelay: 0.003998 s
authdelay: 0.000000 s



If PPS is working, tail /var/log/syslog should reveal a pps source was
found after ntpd -g is started. If you compiled pps debug into the
kernel, dmesg should show pps events. /proc/pps/sources should show 4

If I messed up and said something wrong people might want to read to the
end of this thread before they accept this method as foolproof. I know
how to do this this exact way, but before a reader undertakes to get an
ntp server up they should have some idea of what ntp does, and how it
works because once the server is up it has to be taken care of. Ntp
servers are not magical. There are problems encountered along the way.
I'll try to watch this thread, but I'm writing a book right now so am
quite busy. I do, however, know what time it is. I have two machines
configured the exact same way, and I get 1 us accuracy on both. One is
an AMD athlon, and one is a Pentium 4. You also want to turn off spread
spectrum in the bios setup program.

Last edited by AwesomeMachine; 02-08-2007 at 12:52 PM. Reason: New Data
Old 09-13-2006, 05:19 PM   #2
LQ Veteran
Registered: Mar 2003
Location: Milwaukee, WI
Distribution: Mint
Posts: 6,642

Rep: Reputation: 69
You might want to consider submitting this as a Linux Answer. Please click on the Linux Tutorials link in the upper right hand "Main Menu" box
Old 09-18-2006, 12:00 AM   #3
Senior Member
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,593

Original Poster
Rep: Reputation: 162Reputation: 162
I tried making a howto out of it, but it didn't work. I couldn't preview it. So, I'm leaving it here for now.
Old 02-08-2007, 12:55 PM   #4
Senior Member
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,593

Original Poster
Rep: Reputation: 162Reputation: 162
This op is completely redone, so I'm replying.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Debian 3.1 and Garmin GPS ekimyerac Linux - General 2 03-27-2006 08:52 AM
Audigy2 ZS PRO external unit Synesthesia Linux - Hardware 2 01-21-2006 06:25 PM
Garmin GPS V and NTPD figadiablo Linux - Hardware 1 04-08-2005 04:58 PM
External DVD-RW unit, Firewire/USB but does it work? davecs Linux - Hardware 0 02-26-2005 03:58 PM
Garmin GPS-18 - Need a Driver mWare Linux - Hardware 0 06-15-2004 11:21 PM

All times are GMT -5. The time now is 10:48 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration