[LinuxPPS] HowTo: Linuxpps using ntp patched with latest NMEA patch from ntp bugs list.

MasonCide forensic at milwpc.com
Sun Nov 18 07:14:20 CET 2007


This is an instructional email.  Rodolfo may want to link it, temporarily, 
with the wiki help page.  There were some things I didn't understand at 
first, which are outlined here.

First, and most important, performance data:
ntpq is a script.  It translates to 'ntpq -c rv -p'

:/home/tom# ./ntpq
assID=0 status=04f4 leap_none, sync_uhf_clock, 15 events, 
event_peer/strat_chg,
version="ntpd 4.2.2p4 at 1.1585-o Thu Nov 15 12:51:49 UTC 2007 (2)",
processor="i686", system="Linux/2.6.23-11162007pps", leap=00, stratum=1,
precision=-20, rootdelay=0.000, rootdispersion=0.506, peer=9967,
refid=GPS, reftime=caea140b.2fa4f459  Sat, 2007 19:29:47.186,
poll=4, clock=caea141c.25c5ced5  Sat, 2007 19:30:04.147, state=4,
offset=-0.001, frequency=1.362, jitter=0.002, noise=0.001,
stability=0.000, tai=0
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*GPS_NMEA(0)     .GPS.     0 l   17   16  376    0.000   -0.001   0.002
+debian1.local     .GPS.     1 u   11   64  377    0.115    0.013   0.039
+debian.local       .GPS.     1 u   26   64  377    0.127    0.003   0.494
-jeo.wendtwerks                3 u   65   64  377   71.166    0.765   2.455
-newton.8086.net              2 u   22   64  377   64.954    1.910   3.121

I don't know what's going on with that jitter (0.002).  GPS_NMEA(0) is a local 
GPS.  The other two GPSs are on the lan.  All are using linuxpps.

Here's the local GPS with pps:

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.00053 s
reference ID:               [GPS]
reference time:           caea1574.2fa32147  Sat, 2007 19:35:48.186
system flags:              auth monitor ntp kernel stats
jitter:                           0.000000 s
stability:                      0.000 ppm
broadcastdelay:          0.003998 s
authdelay:                  0.000000 s

ntpdc> kern
pll offset:                    3.5e-05 s
pll frequency:             1.367 ppm
maximum error:        0.008213 s
estimated error:        2e-06 s
status:                       0001  pll
pll time constant:      4
precision:                  1e-06 s
frequency tolerance: 512 ppm

ntpdc> iostats
time since reset:       73390
receive buffers:          10
free receive buffers:   9
used receive buffers:  1
low water refills:          1
dropped packets:       0
ignored packets:        0
received packets:      594762
packets sent:             5211
packets not sent:       0
interrupts handled:    332108
received by int:          332108
ntpdc>

This is what syslog looks like when ntp starts, with pps debug enabled in the 
kernel config:
 
19:52:07  ntpd[24179]: ntpd 4.2.2p4 at 1.1585-o Thu Nov 15 12:51:49 UTC 2007 (2)
19:52:07  ntpd[24180]: precision = 1.000 usec
19:52:07  ntpd[24180]: ntp_io: estimated max descriptors: 1024, initial socket 
boundary: 16
19:52:07  ntpd[24180]: Listening on interface wildcard, 0.0.0.0#123 Disabled
19:52:07  ntpd[24180]: Listening on interface wildcard, ::#123 Disabled
19:52:07  ntpd[24180]: Listening on interface lo, ::1#123 Enabled
19:52:07  ntpd[24180]: Listening on interface eth0, <mac here>#123 Enabled
19:52:07  ntpd[24180]: Listening on interface lo, 127.0.0.1#123 Enabled
19:52:07  ntpd[24180]: Listening on interface eth0, 192.168.xyz.x#123 Enabled
19:52:07  ntpd[24180]: kernel time sync status 0040
19:52:07  ntpd[24180]: refclock_nmea: found GPS source "/dev/gps0"
19:52:07  ntpd[24180]: refclock_nmea: try "/dev/gpspps0" for PPS
19:52:07  ntpd[24180]: refclock_nmea: found PPS source "/dev/gpspps0"
19:52:07  kernel: PPS_GETCAP: source 0
19:52:07  kernel: PPS_SETPARAMS: source 0
19:52:07  ntpd[24180]: refclock_nmea: time_pps_kcbind failed: Operation not 
supported
19:52:07  kernel: PPS_GETCAP: source 0
19:52:07  kernel: PPS_SETPARAMS: source 0
19:52:07  ntpd[24180]: frequency initialized 1.407 PPM from /var/lib/ntp/drift
19:52:07  ntpd[24180]: logging to file /var/log/ntpd.log
19:52:08  kernel: PPS event on source 0 at 1195350728.3854670
19:52:08  kernel: capture assert seq #74546 for source 0
19:52:08  kernel: PPS event on source 0 at 1195350728.103855839
19:52:08  kernel: capture clear seq #74546 for source 0
19:52:09  kernel: PPS event on source 0 at 1195350729.3853877
19:52:09  kernel: capture assert seq #74547 for source 0
19:52:09  kernel: PPS event on source 0 at 1195350729.103866686
19:52:09  kernel: capture clear seq #74547 for source 0
19:52:09  kernel: PPS_FETCH: source 0
19:52:09  kernel: timeout 0.000000000
19:52:10  kernel: PPS event on source 0 at 1195350730.3854402
19:52:10  kernel: capture assert seq #74548 for source 0
19:52:10  kernel: PPS event on source 0 at 1195350730.103857457
19:52:10  kernel: capture clear seq #74548 for source 0
19:52:10  kernel: PPS_FETCH: source 0
19:52:10  kernel: timeout 0.000000000


Here's what ntp.log, if ntp is configured to log, looks like with operating
pps.
Not much different than without pps.  This is only for reference.


16 Nov 23:13:50 ntpd[24603]: peer GPS_NMEA(0) event 'event_reach' (0x84) 
status 'unreach, conf, 1 event, event_reach' (0x8014)
16 Nov 23:13:50 ntpd[24603]: peer 192.168.xyz.x event 'event_reach' (0x84) 
status 'unreach, conf, 1 event, event_reach' (0x8014)
16 Nov 23:13:51 ntpd[24603]: peer 192.168.xyz.x event 'event_reach' (0x84) 
status 'unreach, conf, 1 event, event_reach' (0x8014)
16 Nov 23:13:52 ntpd[24603]: peer 64.246.40.39 event 'event_reach' (0x84) 
status 'unreach, conf, 1 event, event_reach' (0x8014)
16 Nov 23:13:53 ntpd[24603]: peer 64.22.86.210 event 'event_reach' (0x84) 
status 'unreach, conf, 1 event, event_reach' (0x8014)
16 Nov 23:14:43 ntpd[24603]: system event 'event_peer/strat_chg' (0x04) 
status 'sync_alarm, sync_uhf_clock, 2 events, event_restart' (0xc421)
16 Nov 23:14:43 ntpd[24603]: synchronized to GPS_NMEA(0), stratum 0
16 Nov 23:14:42 ntpd[24603]: time reset -0.855049 s
16 Nov 23:14:42 ntpd[24603]: kernel time sync enabled 0001

Here is what I did:

I could not get git to work, so I used patch: ntp-pps-2.6.23-quater.diff from 
here:   
http://ftp.enneenne.com/pub/misc/linuxpps/patches/ntp-pps-2.6.23-quater.diff 
a link on the linuxpps help wiki here: 
http://wiki.enneenne.com/index.php/LinuxPPS_support

I used ntp-4.2.2p4 from here:  
http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.2p4.tar.gz
With the NMEA driver patch from here:  
https://support.ntp.org/bugs/attachment.cgi?id=405

I used kernel 2.6.23.1 from here:  
http://www.kernel.org/linux/kernel/v2.6/linux-2.6.23.1.tar.bz2 

To patch the kernel and NMEA driver I expanded the kernel sources from the 
above link in 

debian> /usr/src
I made a soft link to the kernel sources:
linux
I copied the ntp-pps-2.6.23-quater.diff to /usr/src/linux
and typed:
patch -p1 < *.diff
and the patch worked perfectly.
Do the same thing with ntp-4.2.2p4.tar.gz, with the NMEA patch, after you 
compile the kernel, reboot, and follow the help wiki link, and do that stuff.

Before you compile the kernel, know this, you need to enable pps debug!
If you don't know how to compile a kernel, you'll need to learn that first.  
It's not very difficult, but it's one of those things.  You copy the most 
recent /boot/config-2.xy.z  to   /usr/src/linux/.config
type:
make xconfig from the /usr/src/linux directory, which is also the kernel root 
directory.  Configure pps, which means 'Prompt for experimental drivers' must 
be selected.  That's near the top, and pps is near the middle.  I place a lot 
of faith in Rodolfo Giometti, so I put check marks in the boxes next to 
serial 16550/8250 and pps, so these compile into the kernel, and I don't need 
to load modules.  One thing to remember, serial and pps need to be set both 
as modules, or both as compiled in the kernel (both dots or both checkmarks)
Don't touch anything else, unless you want to learn how to make your computer 
not boot. 

If make xconfig doesn't work, type :
xhost + in a user shell terminal (i.e. non root)
I don't recommend compiling in a root shell, but rather using the command:

sudo make all
If make left behind a command line, 'if and some commands fi', copy that to 
the clipboard, and paste it on the command line, enter to run it. 
If you didn't know anything about kernel compilation before this email, you 
might want to get some practice.

type:
make modules_install
make install

Install yaird or mkinitramfs-tools packages

make initrd like this:

Yaird --output=/boot/initrd.img-2.6.23.1<space>2.6.23.1

or 

update-initramfs -k 2.6.23.1 -c

which I think is better.

do:

update-grub -y

After you reboot with the new kernel, you need to go back to the linuxpps help 
wiki above, but with a few additions.  You need to enable ttyS0 or ttyS1, 
whichever your GPS is on, like so:

/usr/src/linuc/Documentation/pps : ./ppsctl /dev/ttyS0 enable

After you change /etc/udev/udev.conf as indicated in the help wiki.

Now /dev/pps0 will exist.

before you go back to the help wiki, launch something that uses /dev/ttyS0.
You can do this: make soft links from /dev/ttyS0 to /dev/gps0 and 
from /dev/pps0 to /dev/gpspps0

Add kernel to libc as in wiki help.  Compile ntp after you patch it with the 
NMEA.patch, using the configure command line in the linuxpps help wiki.

don't install ntp, just make.

run ntpd from inside the ntp-4.2.2p4/ntpd directory, or type a path to that 
file, and launch it using the -g option.  Ntp will try to get the NMEA 
sentences from /dev/gps0, and separately, and subsequent to that, try to get 
the pps signal from /dev/gpspps0.

Syslog should look like the above syslog output I pasted, if /dev/gpspps0 is 
linked to /dev/pps0.

You can also test /dev/pps0 using:

/usr/src/linux/Documentation/pps : # ./ppstest /dev/pps0

And the output should not say timed out.

The linuxpps help wiki is necessary to read if you want to have pps.  If a 
beginning person does not fully grasp how to do this, don't fear.  Linuxpps 
is going to be part of the linux kernel in the near future.  Right now it is 
in development, which means it's hard to use for a beginner.

I know it's just about impossible to wait to get that microsecond precision of 
your new, or used GPS, from the pps output, but it is better to wait until 
the stable version comes back if you don't know linux very well.  I don't 
think it will take more than a month.  It took me about 4 hours to get pps 
working with the new api, but God was helping.  Without God, I don't think I 
could have gotten it working. 

I congratulate Rodolfo Giometti, Udo van den Havel, Dave Mills, Linus 
Torvalds, and the kernel gang, for making NMEA pps precision time keeping 
possible.  The Lord willing; I'll have a public time server.  

I started with time when GPSs with pps became inexpensive.  It's been a blast 
using linuxpps for pps, and linuxpps is the best, because it captures both 
the NMEA sentence, and the pps signal.  Nothing else does this like linuxpps.
 
-Tom
-- 
He who exalts man's intellect makes himself laughing stock for The Sons of 
God.



More information about the LinuxPPS mailing list