Can't get GPS/PPS to work

Philipp Ammann philipp.ammann at posteo.de
Fri May 20 10:49:31 UTC 2022


Hi Gary!

I don't get it -- I set up a new, clean system and now it works! Anyway,
for future reference here are my answers to your questions and maybe you
can explain what I did differently this time :)

Am 18.05.22 um 23:43 schrieb Gary E. Miller via users:
> Yo Philipp!
> 
> On Wed, 18 May 2022 08:13:23 +0000
> Philipp Ammann via users <users at ntpsec.org> wrote:
> 
>> I'm trying to get ntpsec (1.2.1; running on a Raspberry Pi 4 / Gentoo)
>> to sync to a GPS module connected via GPIO.
> 
> What version gpsd?  Compiles with, or without MAGIC_HAT?

gpsd 3.24. I didn't explicitly set magic_hat, but according to scons it
is always set when compiling on Linux...?

SConscript:
363 |    # FIXME: should check for Pi, not for "linux"
364 |    ("magic_hat", sys.platform.startswith('linux'),
365 |    "special Linux PPS hack for Raspberry Pi et al"),

> I assume you did not read this as you skipped some steps:
> 
> https://gpsd.io/gpsd-time-service-howto.html

I'm not actually using gpsd but the NMEA and PPS drivers built into
ntp{,sec}. I did at some point try gpsd via SHM. Which is another story
because the clock was constantly about 15min off (1000s perhaps?) when I
force-synced to GPS. I'd prefer to do this with just ntpsec. One less
daemon to configure, update and think about.

>> The GPS module a
>> run-of-the-mill (Whadda branded) uBlox Neo-7M based board.
> 
> Essentially obsolete.  It needs an exterior antenna.  What is your antenna.

I tried both of these

- https://www.navilock.de/produkt/60506/merkmale.html (passive)
- https://www.navilock.de/produkt/60521/merkmale.html (active)

with basically the same results (though I was a bit surprised that the
active one just worked). With the passive antenna I got around 5-6 good
satellites, with the active one it's 9-10.

> 
>> `gpsmon`
>> reports "Quality: 1 / Sats: 10" so everything seems to be working
>> perfectly fine here.
> 
> Good, but you should use cgps, not the unmatintained gpsmon.
> 

AFAIK cgps is a client for gpsd, which I'm not running. gpsmon directly
accesses the device without the need for a daemon.

>> `ppstest` also reports that everything is on
>> order. However, I am unable to use the GPS signal in ntpd. I have the
>> following devices:
>>
>>  * /dev/pps0
>>  * /dev/ttyAMA0 # the GPS device
>>  * /dev/gps0 -> /dev/ttyAMA0
>>  * /dev/gpspps0 -> /dev/pps0
> 
> No real need to use the ymlinks.
> 
>> ntp.conf:
>>
>> ```
>> driftfile /var/lib/ntp/ntp.drift
>> statsdir /var/log/ntp/stats
>>
>> restrict default kod limited nomodify nopeer noquery
>> restrict -4 127.0.0.1
>> restrict -6 ::1
>>
>> # tried that, didn't work
>> #refclock pps unit 0 flag2 0 1
>> #refclock nmea baud 9600 path /dev/ttyAMA0 ppspath /dev/pps0
>>
>> #server ptbtime1.ptb.de. iburst
>> #server ptbtime2.ptb.de. iburst
>> #server ptbtime3.ptb.de. iburst
>>
>> server 127.127.20.0 minpoll 2 maxpoll 4
>> fudge 127.127.20.0 time1 1 refid GPS
>>
>> server 127.127.22.0 minpoll 4 maxpoll 4 prefer
>> fudge 127.127.22.0 refid PPS
>> ```
> 
> You missed the step between gpsd and ntpd.  What does ntpshmmon show you?

Not using gpsd.

> I prefer the new style syntax to the magix 127.xxxx tstuff:
> 
> # at the TOP
> refclock shm unit 1 minpoll 4 maxpoll 4 refid PPS flag4 1
> 
> # at the BOTTOM
> refclock shm unit 0 time1 -0.0900  refid GPS flag4 1 noselect

My current (working) config:

```
driftfile /var/lib/ntp/ntp.drift

server ptbtime1.ptb.de. iburst
server ptbtime2.ptb.de. iburst
server ptbtime3.ptb.de. iburst


refclock nmea baud 9600 path /dev/ttyAMA0 refid GPS ppspath /dev/pps0
refclock pps path /dev/pps0 refid PPS prefer

# These are the defaults from Gentoo
restrict default kod limited nomodify nopeer noquery
restrict -6 default kod limited nomodify nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
```

I'm not sure if I need the separate `refclock pps` if ppspath is passed
to `refclock nmea`.

Output from ntpq:

```
ntpq> associations

ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 17767  b014   yes   yes  none    reject   reachable  1
  2 17768  b014   yes   yes  none    reject   reachable  1
  3 17769  b014   yes   yes  none    reject   reachable  1
  4 17770  961a   yes   yes  none  sys.peer    sys_peer  1
  5 17771  8011   yes    no  none    reject    mobilize  1

ntpq> peers
     remote      refid st t when poll reach   delay   offset   jitter
=====================================================================
 ptbtime1.ptb.de .PTB.  1 u    2   64    1  26.7332 -29.1734  28.8178
 ptbtime2.ptb.de .PTB.  1 u    1   64    1  24.0914 -27.9199  22.7684
 ptbtime3.ptb.de .PTB.  1 u    -   64    1  24.0243 -28.6919  24.3199
*NMEA(0)         .GPS.  0 l   19   64    1   0.0000 -149.510   0.0000
 PPS(0)          .PPS.  0 l    -   64    0   0.0000   0.0000   0.0002
```

> 
> And, you neglect to mention how you start gpsd and ntpd.

ntpd -g -G -n -D 99

For gpsd I used similar flags (foreground/no-fork and debug on).

See below for the output of gpsdebuginfo.

Thank you
Philipp

> 
>> I did try many variations in the config. But no matter what, I always
>> get:
>>
>> ```
>> ntpq> peers  
>>      remote      refid st t when poll reach   delay   offset   jitter
>> =====================================================================
>>  NMEA(0)    .GPS.       0 l    -    4    0   0.0000   0.0000   1.9531
>>  PPS(0)     .PPS.       0 l    -   16    0   0.0000   0.0000   0.0002
> 
> Unreachable.  Thus the need to see your ntpshmmon result.
> 
> You realize that by default nptd needs more than three time sources to
> do anything?
> 
>> ntpq> associations  
>>
>> ind assid status  conf reach auth condition  last_event cnt
>> ===========================================================
>>   1 17767  80fb   yes    no  none    reject clock_alarm 15
>>   2 17768  8011   yes    no  none    reject    mobilize  1
>> ```
> 
> Confirming the missing additional chimers.
> 
>> HOWEVER it did work once (yesterday), reporting:
>>
>> ```
>> $ ntpq -p
>>      remote      refid st t when poll reach   delay   offset   jitter
>> =====================================================================
>> *NMEA(0)    .GPS.       0 l    2    4  377   0.0000 218.7745   1.5621
>>  PPS(0)     .PPS.       0 l    -   16    0   0.0000   0.0000   0.0002
>> ```
> 
> Sure not looking like working to me.
> 
> Try running gpsdebuginfo, as root, from here:
> 
> https://gpsd.io/gpsdebuginfo
> 
> and returning the output of that here.


++ id -u
+ '[' 0 '!=' 0 ']'
+ '[' -n '' ']'
+ id
uid=0(root) gid=0(root)
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),26(tape),27(video)
+ uname -a
Linux localhost 5.15.40-bcm2711 #4 SMP Fri May 20 08:36:07 -00 2022
aarch64 GNU/Linux
+ cat /etc/gentoo-release /etc/os-release
Gentoo Base System release 2.8
NAME=Gentoo
ID=gentoo
PRETTY_NAME="Gentoo Linux"
ANSI_COLOR="1;32"
HOME_URL="https://www.gentoo.org/"
SUPPORT_URL="https://www.gentoo.org/support/"
BUG_REPORT_URL="https://bugs.gentoo.org/"
VERSION_ID="2.8"
+ command -v gpsd
+ command -v sockstat
+ command -v lsof
+ command -v netstat
+ command -v ss
/sbin/ss
+ ss -ltpn
+ sed -nE '1p;/:2947 |gpsd/p'
State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
+ ps ax
+ sed -nE '1p;/gpsd/p'
  PID TTY      STAT   TIME COMMAND
 3799 pts/3    S+     0:00 /bin/sh ./gpsdebuginfo
 3809 pts/3    S+     0:00 sed -nE 1p;/gpsd/p
+ command -v gpspipe
+ command -v ipcs
/usr/bin/ipcs
+ ipcs -m
+ sed -nE '/key/p;/KEY/p;/0x4e5450/p'
key        shmid      owner      perms      bytes      nattch     status
+ command -v ntpshmmon
+ ls -l /dev/pps0 /dev/ttyAMA0 /dev/ttyS0
crw------- 1 root root 251,  0 Jan  1  1970 /dev/pps0
crw------- 1 root root 204, 64 Jan  1  1970 /dev/ttyAMA0
crw------- 1 root root   4, 64 Jan  1  1970 /dev/ttyS0
+ command -v lsusb
+ echo PYTHONPATH
PYTHONPATH
+ command -v gpscat
+ command -v python
/usr/bin/python
+ python -V
Python 3.10.4
+ python -c 'import gps;print(gps.__version__)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'gps'
+ command -v python3
/usr/bin/python3
+ python3 -V
Python 3.10.4
+ python3 -c 'import gps;print(gps.__version__)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'gps'
+ command -v systemctl
+ command -v aa-status
+ command -v apparmor_status
+ set +x
Please send the entire, untouched output.

> 
> RGDS
> GARY
> ---------------------------------------------------------------------------
> Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
> 	gem at rellim.com  Tel:+1 541 382 8588
> 
> 	    Veritas liberabit vos. -- Quid est veritas?
>     "If you can't measure it, you can't improve it." - Lord Kelvin
> 
> 
> _______________________________________________
> users mailing list
> users at ntpsec.org
> https://lists.ntpsec.org/mailman/listinfo/users
> 




More information about the users mailing list