# Issue of NTP for getting the time from GPS

**URL:** <https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954>\
**Category:** Pool Development\
**Created:** [March 25, 2021, 11:26am UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954 "2021-03-25T11:26:42Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [March 25, 2021, 11:26am UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/1 "2021-03-25T11:26:42Z")

</div>

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?

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ntppool/original/1X/2fa7e07507d274ea37af08c1c450f5b2736bc57e.png)

---

<div class="post-metadata">

**Author:** ![elljay](https://avatars.discourse-cdn.com/v4/letter/e/5fc32e/32.png) [@elljay](https://community.ntppool.org/u/elljay)\
**Post date:** [March 25, 2021, 12:26pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/2 "2021-03-25T12:26:25Z")

</div>

Hi and welcome!

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

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [March 25, 2021, 12:28pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/3 "2021-03-25T12:28:07Z")

</div>

Yes, it both output GPS and PPS

 ![Screenshot from 2021-03-25 12-13-20](https://us1.discourse-cdn.com/flex016/uploads/ntppool/original/1X/fe9370fedebd9cf71b4164f30bc2e56234677135.png)

---

<div class="post-metadata">

**Author:** ![elljay](https://avatars.discourse-cdn.com/v4/letter/e/5fc32e/32.png) [@elljay](https://community.ntppool.org/u/elljay)\
**Post date:** [March 25, 2021, 12:50pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/4 "2021-03-25T12:50:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [March 25, 2021, 2:17pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/5 "2021-03-25T14:17:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [March 25, 2021, 2:52pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/6 "2021-03-25T14:52:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jamesb192](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/jamesb192/32/699_2.png) [@Jamesb192](https://community.ntppool.org/u/Jamesb192)\
**Post date:** [March 25, 2021, 5:59pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/7 "2021-03-25T17:59:22Z")

</div>

Please run [this script](https://gpsd.io/gpsdebuginfo) 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.

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [April 5, 2021, 7:59pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/8 "2021-04-05T19:59:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alica](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/alica/32/337_2.png) [@alica](https://community.ntppool.org/u/alica)\
**Post date:** [April 6, 2021, 8:46am UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/9 "2021-04-06T08:46:02Z")

</div>

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](http://doc.ntp.org/current-stable/drivers/driver22.html) of ntpd directly. Note this requires your ntpd to be build with KPPS support, which is not always the case provided by distribution.

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [April 6, 2021, 9:02am UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/10 "2021-04-06T09:02:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![alica](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/alica/32/337_2.png) [@alica](https://community.ntppool.org/u/alica)\
**Post date:** [April 6, 2021, 1:26pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/11 "2021-04-06T13:26:38Z")

</div>

> [@yulan](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [April 6, 2021, 2:19pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/12 "2021-04-06T14:19:03Z")

</div>

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](https://msadowski.github.io/pps-support-jetson-nano/)

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [April 6, 2021, 2:35pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/13 "2021-04-06T14:35:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alica](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/alica/32/337_2.png) [@alica](https://community.ntppool.org/u/alica)\
**Post date:** [April 6, 2021, 4:19pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/14 "2021-04-06T16:19:10Z")

</div>

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,

```perl
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](https://github.com/redlab-i/pps-tools). After that, simply build the ntpd source, `configure` shall find `timepps.h` and prepare it for you.

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [April 7, 2021, 10:47am UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/15 "2021-04-07T10:47:13Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![alica](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/alica/32/337_2.png) [@alica](https://community.ntppool.org/u/alica)\
**Post date:** [April 8, 2021, 3:37pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/16 "2021-04-08T15:37:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yulan](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yulan](https://community.ntppool.org/u/yulan)\
**Post date:** [April 8, 2021, 3:51pm UTC](https://community.ntppool.org/t/issue-of-ntp-for-getting-the-time-from-gps/1954/17 "2021-04-08T15:51:50Z")

</div>

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.
