Subject: Re: ntp problems with GPS under NetBSD/amd64
To: None <>
From: Brian Buhrow <>
List: port-amd64
Date: 03/11/2005 22:10:22
	Hello Alicia.  I was googling for NetBSD gps and ntp related issues
when I saw your mail.
I ran into the same problem you're having, and I think I know what's wrong.
Are you trying to run ntpd in debug mode? If so, then ntpd won't work if you're
trying to debug a serially connected GPS because TIOCSCTTY is trying to
assign the controlling terminal to the serial port to which the GPS is
attached.  Under normal conditions, this works because when ntpd is
started, it has no controlling terminal.  However, when you run it in debug
mode, ntpd has a controlling terminal, and a new one can't be assigned.
	Does it work if you just run it from the /etc/rc.d/ntpd start command?
Or, at least, do you get different output?

   Subject: ntpd problems with GPS receiver under NetBSD-amd64
   To: None <>
   From: Alicia da Conceicao <>
   List: tech-net
   Date: 02/02/2005 16:10:40

I have a GPS receiver with a TTL PPS feed, which I managed to successfully
wire up to a RS232 (DB9) serial port.  When I connect it to a NetBSD-amd64
version 2.0 computer running minicom at 4800 bps for tty02, I am able to
read all of the GPS data (including time, position, etc.) in the
raw NMEA-0183 strings.  So far so good right.

Note that the DB9 serial port was wired as follows (male view):

        \  [1-TTL] [2-TX] [3-RX] [4-???] [5-GND] /
          \    [6-???] [7-???] [8-???] [9-???]   /

with the TTL on pin1, transmit on pin2, receive on pin3, and ground on

Also note that NetBSD-amd64 2.0 kernel was compiled with the following
related options:

        options NTP
        options PPS_SYNC

Then I try to run it under ntpd version "4.2.0-r" with the following

        pidfile /var/run/
        driftfile /var/db/ntp.drift
        logconfig -syncstatus
        peer prefer
        fudge stratum 0
        fudge time1 -1.0
        fudge stratum 0
        fudge flag2 0
        fudge flag3 1

and with symlinks:

        /dev/gps0 => /dev/tty02
        /dev/pps0 => /dev/tty02

Unfortunately ntpd fails with the following errors:

        ioctl(TIOCSCTTY, 0) fails for clock I/O: Operation not permitted
        internal error: refclockio structure not found
        configuration of failed
        reclock_atom: /dev/pps0: Interrupted system call
        configuration of failed

I could understand if there where some ntpd related issues regarding the
NetBSD implimentation of PPS, even though I did enable it in the kernel.
But considering that I can see a continuous stream of NMEA strings being
sent by the GPS clock through the serial bus when I use minicom, I am at
a loss as to why ntpd is failing for the NMEA pseduo-port at

Looking at the NetBSD kernel source code, the original of that EPERM errno
value outputed by ntpd appears to originate in "/usr/src/sys/kern/tty.c"
when ntpd attempts to do a "ioctl(rio->fd,TIOCSCTTY,0)" in "libntp/iosignal.c"
to become a controlling tty.

Any suggestions is greatly apprecated.

Thanks in advance.