[ntp:questions] HowTo: Garmin 18 LVC GPS Reference Clock 1 us Accuracy on Debian Etch

Thomas Kayser forensic at milwpc.com
Sun Dec 17 04:55:30 UTC 2006


On Sat, 2006-12-02 at 22:00 -0600, Thomas Kayser wrote:

A few other notes:

in grub I use

kernel    /boot/vmlinuz-2.6.18.3xy root=/dev/sda1 ro acpi=off apm=off
noapic nolapic

I compiled the 2.6.18.3 kernel without acpi or apm support, and disabled
these in the system bios.  Performance is three times better without
these.  However, full libata support in 2.6.19 requires apic.

I have tried this same configuration with the 2.6.19 kernel and
performance of ntp is degraded severely, from 1 us offset to 700 us.
When I went back to 2.6.18.3, excellent performance was restored to ntp.



> It took me a bit of experimentation to figure out how to get 1 us
> precision with the Garmin 18 LVC on linux.  
> 
> Ingredients:
> 
> 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:  
> 
> http://lists.ntp.isc.org/pipermail/questions/2005-November/007878.html
> 
> Rodolfo's Git repo for LinuxPPS:
> 
> Git://git.enneenne.com/linuxpps
> 
> Udo van den Heuvel's ntpd NMEA patch:
> 
> http://time.qnan.org/linux2.6-pps/ntpd-nmea.patch
> 
> Linux 2.8.18.3 Kernel:
> 
> ftp://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.3.tar.gz
> 
> ntp-2.2.2p4.tar.gz:
> 
> http://www.ntp.org/downloads.html
> 
> CD 1 of Debian "testing" - Etch:
> 
> http://cdimage.debian.org/cdimage/weekly-builds/i386/iso-cd/
> 
> 
> 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:
> 
> http://www.garmin.com/products/gps18oem/
> 
> 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 18's 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:
> 
> http://www.wraith.sf.ca.us/ntp/linuxpps.html
> 
> to build a kernel patch for kernel 2.6.18.3.  Rodolfo's LinuxPPS wiki is
> here:  
> 
> http://wiki.enneenne.com/index.php/LinuxPPS_support
> 
> A very helpful page is Philip M. White's:
> 
> http://time.qnan.org
> 
> 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-2.6.18.3.tar.bz2 kernel sources:
> curl -O
> ftp://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.3.tar.bz2
> 
> 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.  
> 
> Copy linux-2.6.18.3.tar.bz2 to /usr/src  
> 
> Install qt development packages, kernel-package,
> linux-patch-debian-2.6.17, git-core and yaird with:
> 
> dselect
> 
> I needed to do an access and update with dselect, so have the URL of at
> least 1 Debian mirror written down.  I use:
> 
> ftp://ftp.egr.msu.edu/debian/
> 
> 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-2.6.18.3.tar.bz2.  After the file extracts it makes a directory
> called linux-2.6.18.3, which I make a symlink to like this:
> 
> 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, in /usr/src/linux
>  
> patch -p1 -i <linuxpps-patch>
> 
> /usr/src/linux/include/linux/netlink.h
> 
> 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.
> 
> 
> Copy /boot/config-2.6.xx.y to /usr/src/linux/.config and do:
> 
> 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-2.6.18.3<space>2.6.18.3
> 
> Then do:
> 
> nano /boot/grub/men*
> 
> and change the new kernel entry to reflect an initrd file named
> initrd.img-2.6.18.3 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.
> 
> Copy /usr/src/linux-2.6.18.3/include/linux/timepps.h and timex.h
> to /usr/include/timepps.h and timex.h
> 
> I used ntp-4.2.2p4.tar.gz from the ntp.org site.  You need the
> ntp-nmea.patch file from Philip M. White's http://time.qnan.org 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
> 
> make
> 
> nano /etc/ntp.conf
> 
> restrict default nomodify
> 
> restrict 127.0.0.1
> 
> server 127.127.20.0 minpoll 4 prefer
> fudge 127.127.20.0 time1 0.0 flag3 1 flag2 0
> 
> server time-a.nist.gov
> server time-b.nist.gov
> server time-c.timefreq.bldrdoc.gov
> 
> 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
> root:
> 
> 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,
> event_peer/strat_chg,
> version="ntpd 4.2.2p4 at 1.1585-o Wed Nov 29 23:30:04 UTC 2006 (1)",
> processor="i686", system="Linux/2.6.18.3pps", 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
> jitter
> ==============================================================================
> *GPS_NMEA(0)     .GPS.            0 l    8   16  377    0.000    0.000
> 0.003
> +time.nist.gov   .ACTS.           1 u   64   64  377   50.920    1.247
> 2.821
> -time-a.nist.gov .ACTS.           1 u   59   64  377   60.612    3.590
> 1.838
> -time-b.nist.gov .ACTS.           1 u   50   64  367   61.990    4.104
> 7.483
> +time-c.timefreq .ACTS.           1 u    1   64  377   50.955    1.217
> 1.725
> 
> 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
> ntpdc>
> 
> 
> Cheers,
> 
> Tom
> 
> 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
> entries.
> 
> 
> 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. 
> 
> _______________________________________________
> questions mailing list
> questions at lists.ntp.isc.org
> https://lists.ntp.isc.org/mailman/listinfo/questions




More information about the questions mailing list