How to link the gpsd and the pps in the ntp.conf file?

615 views Asked by At

I'm working on the AM335x custom board with yocto where "u-blox LEA-M8F" is used as a gps module. Basically I wanted to use the "ntpd deamon" so while going through the internet i found that i suppose to link the gpsd and the pps to do so, i have configured the ntp.conf file as follows

#/etc/ntp.conf, configuration for ntpd

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

#statistics loopstats peerstats clockstats
#filegen loopstats file loopstats type day enable
#filegen peerstats file peerstats type day enable
#filegen clockstats file clockstats type day enable

# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example

# pool.ntp.org maps to more than 300 low-stratum NTP servers.
# Your server will pick a different set every time it starts up.
# *** Please consider joining the pool! ***
# *** ***
#server 0.rhel.pool.ntp.org iburst 
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
#server ntp0.pipex.net
#server ntp1.pipex.net

#server 127.127.1.0
#fudge 127.127.1.0 stratum 10

# By default, exchange time with everybody, but don't allow configuration.
# See /usr/share/doc/ntp-doc/html/accopt.html for details.
#restrict  default kod notrap nomodify nopeer noquery
#restrict -6 default kod notrap nomodify nopeer noquery
#restrict otherntp.server.org mask 255.255.255.255 nomodify notrap noquery
#restrict ntp.research.gov mask 255.255.255.255 nomodify notrap noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict -6 ::1

# Clients from this (example!) subnet have unlimited access,
# but only if cryptographically authenticated
#restrict 192.168.123.0 mask 255.255.255.0 notrust
restrict 200.1.2.0 mask 255.255.255.0 nomodify notrap

# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 200.1.255.255 minpoll 1
#server  127.127.1.0 # local clock
#fudge   127.127.1.0 stratum 10

# If you want to listen to time broadcasts on your local subnet,
# de-comment the next lines. Please do this only if you trust everybody
# on the network!
#disable auth
#broadcastclient
restrict default kod nomodify notrap nopeer noquery
restrict -4 default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

#tinker  step 0.4  stepback 0.4  stepfwd 0.4

server 127.127.28.0 minpoll 4 maxpoll 4
fudge 127.127.28.0 flag1 1 time1 -0.875 refid GPS stratum 1

server 127.127.22.0 minpoll 4 maxpoll 4  
fudge 127.127.22.0 refid PPS

driftfile /var/lib/ntp/drift

pidfile /var/run/ntpd.pid

after rebooting board when i used the following command

ntpq -p

remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
SHM(0)          .GPS.            0 l    -   16    0    0.000    0.000   0.000
PPS(1)          .PPS.            0 l    -   16    0    0.000    0.000   0.000

As shown above offset values are always zero. Can anyone please help me to understand where exactly I'm doing wrong in the ntp.conf file?

1

There are 1 answers

0
Visseroth On

My setup is a bit different, but I assume you are using gpsd, as I am.

I am also using a u-blox GPS chipset, and I am able to get GPS sync but not PPS, so I've been digging around trying to figure out how to get PPS working.

For GPS sync edit your GPSD config file.

I'm using a Ubuntu-based OS, so my config file is /etc/default/gpsd

My config reads:

# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/serial/by-id/usb-u-blox_AG_-_www.u-blox.com_u-blox_7_-_GPS_GNSS_Receiver-if00 /dev/pps0"

# Other options you want to pass to gpsd
GPSD_OPTIONS="-n"
GPSD_SOCKET="/var/run/gpsd.socket

Adding the GPSD_SOCKET got the GPS syncing time.

Make sure the gpsd.socket service is running and that will give you /dev/pps0 and time syncing via GPS but again, no syncing on PPS for some reason.

sudo systemctl enable gpsd
sudo systemctl start gpsd
sudo systemctl enable gpsd.socket
sudo systemctl start gpsd

Hopefully you or someone else finds this helpful.