1

I'm trying to configure ntpd to source it's time from a gps receiver (BU-353S4) but I'm getting some errors.

I'm using ntpd 4.2.8.p6-3 and gpsd 3.16-2 on Arch Linux Arm. I've been following the tutorial on the arch wiki but it doesn't have any troubleshooting information.

The gpsd log contains the entry

gpsd:ERROR: response: {"class":"ERROR","message":"No such device as /dev/gps0"}\x0d\x0a

Repeated every 6 seconds or so, nothing else other than start, stop messages.

/var/log/ntp.log contains:

Listen and drop on 0 v6wildcard [::]:123
Listen and drop on 1 v4wildcard 0.0.0.0:123
Listen normally on 2 lo 127.0.0.1:123
Listen normally on 3 eth0 172.10.10.75:123
Listen normally on 4 lo [::1]:123
Listen normally on 5 eth0 [fe80::ba27:ebff:feba:af05%2]:123
Listening on routing socket on fd #22 for interface updates
GPSD_JSON(0): GPSD revision=3.16 release=3.16 protocol=3.11

ntpq -p outputs

    remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 GPSD_JSON(0)    .GPS.            0 l    -   64    0    0.000    0.000   0.000

/etc/ntp.conf contains

restrict 127.0.0.1
restrict ::1

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

# GPSD config
server 127.127.46.0
fudge 127.127.46.0 time1 0.0 time2 0.0 refid GPS

driftfile /var/lib/ntp/ntp.drift
logfile /var/log/ntp.log

However sudo gpscat /dev/gps0 outputs (to my untrained eye) valid nmea gps information, and cgps and gpsmon all get a fix and output useful information.

/dev/ttyUSB0 has permissions crw-rw---- 1 root uucp 188. gpsd is running under user nobody and ntpd is running as user ntp

timlyo
  • 202
  • 2
  • 9
  • What are the permissions on `/dev/gps0`? If those look OK, is there any chance selinux is confusing matters? – MadHatter Mar 30 '16 at 09:54
  • `ls -l /dev/gps0` returns `lrwxrwxrwx 1 root root 7 Mar 30 10:36 /dev/gps0 -> ttyUSB0` I haven't changed those, it's what gpsd creates it with. – timlyo Mar 30 '16 at 09:55
  • The permissions on soft links are ignored; what are the permissions on the target, and what user is the daemon that errors running as? Also, selinux? – MadHatter Mar 30 '16 at 09:56
  • `crw-rw---- 1 root uucp 188, 0 Mar 30 10:40 /dev/ttyUSB0` I'm not running selinux – timlyo Mar 30 '16 at 09:59
  • Please stop answering only part of the question - this will go quicker if you answer in full each time! What user is the daemon that logs the errors you quote (`gpsd`) running as? – MadHatter Mar 30 '16 at 10:03
  • `gpsd` is running as `nobody`, `ntp` is running as `ntp`. – timlyo Mar 30 '16 at 10:08

2 Answers2

2

gpsd is running as nobody, and so doesn't have privilege to read /dev/ttyUSB0, which is exactly what it's complaining about.

If you add the nobody user to the group uucp, that should fix things, but it's not recommended. Or you can change the modes on /dev/ttyUSB0 to be 666, which is slightly less dreadful. Best of all would be to edit the gpsd startup config so it runs as some other user, possibly gpsd, and make /dev/ttyUSB0 group-owned by gpsd's primary group (also probably gpsd).

Assuming that gpsd sets the time once it can read the GPS correctly, this will enable ntpd to advertise the time, knowing (since you have configured it) that it's got it from a stratum-0 (ntp) source.

MadHatter
  • 78,442
  • 20
  • 178
  • 229
1

Be careful that you must "run gpsd on that linked /dev/gps0 so that the GPSD_JSON line appears as expected". So check whether your GPSD run on /dev/gps0 or not. My GPSD run on /dev/ttyS0 on my server and after I change the DEVICES to /dev/gps0 in /etc/default/gpsd, NTPd can link GPSD successfully.

timlyo
  • 202
  • 2
  • 9
JK Zhang
  • 11
  • 1