Linux – Setting ntp time from gpsd

gpslinuxntptime-synchronization

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

Best Answer

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.