[ntp:questions] double pps device

Brian Inglis Brian.Inglis at SystematicSw.ab.ca
Sat Nov 12 16:13:26 UTC 2016

On 2016-11-12 08:04, folkert wrote:
> Hoping that this is the right list for this question.
> Before I used my rpi-gpio-ntpd program. As I would like better latency
> values, I'm going to try to use the kernel pps interface. This is all on
> a raspberry pi.
> Now I hit my head on the following.
> When my system is running no ntpd and no gpsd, there is a /dev/pps0
> device. This is strange. In fact, that's the one seeing timestamp updates in the
> assert-file under /sys.
> I verified that no program has /dev/ttyAMA0 open (serial port on the
> rpi).

That's the first prereq for running a serial GPS on the system;
second is you also have systemd or getty tty service disabled
on that port; in /boot/config.txt you have:
	# add pps
in /etc/modules you have:
at startup you should see:
	pps_core: LinuxPPS API ver. 1 registered
	pps_core: Software ver. 5.3.6 - Copyright 2005-2007 ...
	pps pps0: new PPS source pps.-1
	pps pps0: Registered IRQ 170 as PPS source
	Modules linked in: ... pps_gpio pps_core ...
and if you have a serial GPS with PPS hooked up and running,
you'll see:
$ head /sys/devices/platform/pps/power/*
==> /sys/devices/platform/pps/power/autosuspend_delay_ms <==
head: error reading "/sys/devices/platform/pps/power/autosuspend_delay_ms": Input/output error

==> /sys/devices/platform/pps/power/control <==

==> /sys/devices/platform/pps/power/runtime_active_time <==

==> /sys/devices/platform/pps/power/runtime_status <==

==> /sys/devices/platform/pps/power/runtime_suspended_time <==
$ head /sys/devices/virtual/pps/pps0/*
==> /sys/devices/virtual/pps/pps0/assert <==

==> /sys/devices/virtual/pps/pps0/clear <==

==> /sys/devices/virtual/pps/pps0/dev <==

==> /sys/devices/virtual/pps/pps0/echo <==

==> /sys/devices/virtual/pps/pps0/mode <==

==> /sys/devices/virtual/pps/pps0/name <==

==> /sys/devices/virtual/pps/pps0/path <==

==> /sys/devices/virtual/pps/pps0/power <==
head: error reading "/sys/devices/virtual/pps/pps0/power": Is a directory

==> /sys/devices/virtual/pps/pps0/subsystem <==
head: error reading "/sys/devices/virtual/pps/pps0/subsystem": Is a directory

==> /sys/devices/virtual/pps/pps0/uevent <==

Did you also setup PPS and GPS symlinks in udev e.g.
create /etc/udev/rules.d/99-gps-pps.rules:
	KERNEL=="ttyAMA0", SYMLINK+="gps0"
	$ sudo udevadm trigger
to create symlinks /dev/gps0 and /dev/gpspps0.
Check what's there and how it's set up with:
	$ ls -l /dev/?ps*
all you should see is, reflecting the last startup date/time:
lrwxrwxrwx 1 root root      7 Sep 27 22:43 /dev/gps0 -> ttyAMA0
lrwxrwxrwx 1 root root      4 Sep 27 22:43 /dev/gpspps0 -> pps0
crw------- 1 root root 245, 0 Sep 27 22:43 /dev/pps0

> If I now start gpsd, then suddenly a /dev/pps1 appears. This device
> is NOT the real pps device. Also the timestamp of the assert-file
> does not change for pps1. gpsd is also opening that file. Result of
> course is that things are not keeping track of correct time.
> Do you have any idea what could be the cause? I updated cmdline.txt,
> inittab, systemd, etc etc to not use the serial port and none is
> (apart from gpsd) which I verified with lsof

Did you start gpsd with:
	$ sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock
which runs it against the GPS device on /dev/ttyAMA0 port?
If you did not, maybe it's trying to be "smart" and detect and set
stuff up for you.
In man gpsd and on http://www.catb.org/gpsd/gpsd.html it says:
"On Linux systems supporting udev, gpsd is normally started
automatically when a USB plugin event fires (if it is not already
running) and is handed the name of the newly active device. In that
case no invocation is required at all."
And under FILES /dev/ttyS0:
"Prototype TTY device. After startup, gpsd sets its group ID to the
owning group of this device if no GPS device was specified on the
command line does not exist." [sic]
Do you see anything relevant from dmesg that could be causing
gpsd to do it's own setup?
See also:

I must admit I ran gpsd just long enough to validate PNT functions
and data were working properly, and tried out a few sat display
programs, before I shut it down and setup PPS as above.

Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

More information about the questions mailing list