[LinuxPPS] PPS/ntpd fails on fresh startup

Luca Bertagnolio time at berta.com
Mon Oct 6 22:35:27 CEST 2008


Hi everyone,

been experiment a bit in the last month on my Gentoo-based Pentium MMX
using a Garmin GPS18LVC.  Found a few snags in my setup, and am
looking for guidance on how to find the issues.

Running Gentoo with vanilla kernel 2.6.27-rc3 and the latest patches with
v.5.3.2.  My Gentoo machine has nanosecond support in glibc, thanks
to Hal, and ntptime reports it correctly.  LinuxPPS is built as modules and
am currently using the debugging option to gather more data.

I face the same issue when running both a "stable" ntpd 4.2.4 and the
latest 4.2.5p135, both patched for PPS on driver 20.

The problem I face happens every time the machine wakes up after a fresh
reboot, and thus does not allow me to reliably list ntpd in the default
runlevel to allow a complete unattended startup upon a reboot.

In a nutshell, my slightly modified init script running for the first time
does *not* result in a valid ntpd+ppsldisc combo running, but after
stopping and restarting the ntpd+ppsldisc services , everything works fine.

My modifications to the startup script are these:

        killall ppsldisc
        /usr/local/sbin/ppsldisc /dev/ttyS1 &
        if [ ! -L /dev/gps1 ] ; then
                ln -s /dev/ttyS1 /dev/gps1
        fi
        if [ ! -L /dev/gpspps1 ] ; then
                ln -s /dev/pps0 /dev/gpspps1
        fi

        start-stop-daemon --start --exec /usr/sbin/ntpd \
            --pidfile /var/run/ntpd.pid \
            -- -p /var/run/ntpd.pid ${NTPD_OPTS}
        eend $? "Failed to start ntpd"

so I've simply added a killall to running ppsldisc processes, I restart a new
one, eventually create the symlinks in /dev, and finally start ntpd.

When doing /etc/init.d/ntpd start after a fresh reboot, I get this:

source serial1 got cdev (253:0)
new PPS source serial1 at ID 0
PPS source #0 "/dev/ttyS1" added
PPS event on source 0 at 1223324575.20490258
capture assert seq #1 for source 0
PPS assert at 84276 on source #0
PPS_GETCAP: source 0
PPS_SETPARAMS: source 0
PPS_GETCAP: source 0
PPS_SETPARAMS: source 0
PPS_FETCH: source 0
timeout 0.000000000
PPS_FETCH: source 0
timeout 0.000000000
PPS_FETCH: source 0
timeout 0.000000000

and the last two lines loop forever.

I then do a /etc/init.d/ntpd stop and since the script kills ppsldisc I get:

PPS source #0 removed

Second start of the ntpd service, and the dmesg output is very different:

source serial1 got cdev (253:0)
new PPS source serial1 at ID 0
PPS source #0 "/dev/ttyS1" added
PPS event on source 0 at 1223324681.088206
capture assert seq #1 for source 0
PPS assert at 108783 on source #0
PPS_GETCAP: source 0
PPS_SETPARAMS: source 0
PPS_GETCAP: source 0
PPS_SETPARAMS: source 0
PPS_FETCH: source 0
timeout 0.000000000
PPS event on source 0 at 1223324681.200085370
capture clear seq #1 for source 0
PPS clear at 108833 on source #0
PPS event on source 0 at 1223324682.084915
capture assert seq #2 for source 0
PPS assert at 109033 on source #0
PPS_FETCH: source 0
timeout 0.000000000
PPS event on source 0 at 1223324682.200085430
capture clear seq #2 for source 0
PPS clear at 109083 on source #0
PPS event on source 0 at 1223324683.084137
capture assert seq #3 for source 0
PPS assert at 109283 on source #0
PPS_FETCH: source 0
timeout 0.000000000
PPS event on source 0 at 1223324681.199876832
capture clear seq #3 for source 0
PPS clear at 109333 on source #0
PPS event on source 0 at 1223324681.999875539
capture assert seq #4 for source 0
PPS assert at 109533 on source #0
PPS_FETCH: source 0
timeout 0.000000000
PPS event on source 0 at 1223324682.199876054
capture clear seq #4 for source 0
PPS clear at 109583 on source #0

and everything starts to work fine:

$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 ntp.ien.it      .UTCI.           1 u    1   64    3    6.705    0.258   0.414
*GPS_NMEA(1)     .PPS.            0 l    2   16   37    0.000    0.135   0.008

This is consistent and repeatable, and I've finished all the tricks I could
use... help is very much appreciated!

Hint for Rodolfo, it's about time you add a runtime "debug=1" flag to the
modules, to avoid recompiling when turning debugging on or off... ;-)

Ciao, Luca
Milan, Italy



More information about the LinuxPPS mailing list