Issue of NTP for getting the time from GPS

Hi!
I would like to ask you a question that I used Jetson Nano and Ublox gps receiver, I hope to give the Jetson Nano with PPS and NMEA, I applied the method GPSD+NTP, then I got the result of gpsd:

and I set my ntp.conf like this:

driftfile /var/lib/ntp/ntp.drift
leapfile /usr/share/zoneinfo/leap-seconds.list
statsdir /var/log/ntpstats/

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

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

restrict 127.0.0.1
restrict ::1

server 127.127.28.0 minpoll 4 maxpoll 4
fudge 127.127.28.0 time1 0.40444156 refid GPS flag4 1

server 127.127.28.1 minpoll 4 maxpoll 4 prefer
fudge 127.127.28.1 refid PPS

The problem is that I can only get the information like this:
driftfile /var/lib/ntp/ntp.drift
leapfile /usr/share/zoneinfo/leap-seconds.list
statsdir /var/log/ntpstats/

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

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

restrict 127.0.0.1
restrict ::1

server 127.127.28.0 minpoll 4 maxpoll 4
fudge 127.127.28.0 time1 0.40444156 refid GPS flag4 1

server 127.127.28.1 minpoll 4 maxpoll 4 prefer
fudge 127.127.28.1 refid PPS

In normal condition, I can get SHM(0) and SHM(1) for my PPS and NMEA sentence, bu I can only get like below: I used the port UART(Not RS232). Does anyone know this problem?

Hi and welcome!

Does syslog have any useful messages? Does gpsmon show GPS output?

Yes, it both output GPS and PPS

Anything useful from ntpd in syslog? “grep ntpd /var/log/syslog”

Thank you for your quick reply, I am sorry it did not work…

Actually yesterday when I found that it showed SHM but when I reboot my computer it still had no SHM(0) and SHM(1)

Please run this script as root and paste the output here. I suspect you might not be initially be running gpsd as root or with some fool options via system.

gpsd needs root privileges initially to bind the NTP0 and NTP1 shm segments because of historical bad decisions. packagers have a tendency to set gpsd to only run gpsd sometimes particularly on systemd or ship systemd without certain features that nobody (read chrony, ntp, ntpsec) uses like the shm segment and chrony socket support.

Thank you for your quick reply, I would like to tell you that I used the root to run GPSD. I can run NTP0 and NTP2. But I could not get the SHM in NTP interface.For the python file you provided, I ran it in my system but it could not work and it has som grammer errors.

If your GPS device works fine and has /dev/pps0 device spawned, you may skip GPSD and try to use the PPS Clock Discipline driver of ntpd directly. Note this requires your ntpd to be build with KPPS support, which is not always the case provided by distribution.

Thank you for your quick reply, and my pps is:/dev/pps1. You mean that I can just use the NTPd to get the time from GPS?

Theoretically yes. But you should make sure why your PPS source is spawned as /dev/pps1. Is there another device spawned as /dev/pps0? If there is no pps0 but only pps1 then I guess you should recheck your boot log to see if something interferes the normal device initiation process.

Thank you for your quick reply and /dev/pps0 is the kernel pulse from the Jetson Nano. And the external pps is the pps1, I followed the instruction from the weblink: Enabling PPS on Jetson Nano

And one more question: I do not know how to built ntp with Kpps. Do you have more instruction about it? Thanks!

OK, your pps0 comes from kernel itself as a debug device. I would suggest you disable it to make configuration simpler and avoid possible confusions.

Before going to build ntpd with KPPS support, first check if the ntpd package provided by your distribution has KPPS support built-in or not: set the type 22 driver up,

server 127.127.22.X   # X refers to your /dev/ppsX GPS PPS device
fudge  127.127.22.X refid PPS

and check if it works. If it works then you can save the build work.

If not, check if you have timepps.h in your include path (usually /usr/include/sys/). If not, you should install the PPSAPI header files first, either from package of your distribution (eg. pps-tools for Debian based ones) or from the project’s repository. After that, simply build the ntpd source, configure shall find timepps.h and prepare it for you.

Thank you for your advice and I followed the instruction you said, however, it could not work. Can I show you the ntp.conf of mine? Thx!

What do you mean by could not work? Unable to build your own ntpd, or unable to use the type 22 driver? And sure you can post your ntp.conf (and other useful info like syslog or configuration output) for debuging purpose.

I followed your advice to add:
server 127.127.22.X # X refers to your /dev/ppsX GPS PPS device
fudge 127.127.22.X refid PPS
in the ntp.conf file, but when I restart my NTP, it is still the same problem. The NMEA information was not shown.