gpsd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to feed 1PPS to GPSD from GPIO pin


From: Jatinder
Subject: How to feed 1PPS to GPSD from GPIO pin
Date: Wed, 19 Jul 2023 11:27:59 -0700

Hello,

We would like to feed 1-pulse-per-second (1PPS) to Chrony using GPSD SHM not PPS. We have referred instructions given in https://gpsd.gitlab.io/gpsd/gpsd-time-service-howto.html#_feeding_chrony_from_gpsd . We are facing some complications. Chrony is not able to read and lock to SHM. Tried running ntpshmmon but it is not showing anything.

Given are the details of the system and configuration:
We are using https://www.variscite.com/product/system-on-module-som/cortex-a7/dart-6ul-freescale-imx-6ul/ which runs with Debian 10 and Kernel 4.14.170.
We are using the Kernel pps-gpio module to get a signal from a GPS receiver via GPIO pin.

Configuration in the Device-Tree:
pps@0 {
    compatible = "pps-gpio";
    pinctrl-0 = <&pps_mux>;
    gpios = <&gpio5 9 0>;
  };           

pps_mux: pps_mux-1 {
         fsl,pins = <MX6QDL_PAD_DISP0_DAT15__GPIO5_IO09  0x130B9>;
    };
               

Startup Kernel.log shows that pps0 is mapped with ptp0 and pps1 is mapped with 1PPS input.

pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti giometti@linux.it
pps pps0: new PPS source ptp0
pps pps1: new PPS source pps@0.-1
pps pps1: Registered IRQ 222 as PPS source


We have two devices pps0 and pps1 under /dev. If we run ppstest on /dev/pps0 and /dev/pps1, pps0 is not able to fetch anything but pps1 receives signal every second:

ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
time_pps_fetch() error -1 (Connection timed out)

ppstest /dev/pps1
trying PPS source "/dev/pps1"
found PPS source "/dev/pps1"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1689721508.999999321, sequence: 527 - clear  0.000000000, sequence: 0
source 0 - assert 1689721510.000005658, sequence: 528 - clear  0.000000000, sequence: 0
source 0 - assert 1689721510.999998303, sequence: 529 - clear  0.000000000, sequence: 0
source 0 - assert 1689721511.999998608, sequence: 530 - clear  0.000000000, sequence: 0


We are running GPSD using systemd and given is the configuration file being used:

cat /etc/default/gpsd
# Default settings for the gpsd init script and the hotplug wrapper.
# Start the gpsd daemon automatically at boot time
START_DAEMON="true"

# Use USB hotplugging to add new USB devices automatically to the daemon
USBAUTO="false"

# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/pps1"

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


Status of GPSD:
systemctl status gpsd
● gpsd.service - GPS (Global Positioning System) Daemon
   Loaded: loaded (/lib/systemd/system/gpsd.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2023-07-18 23:13:04 UTC; 19min ago
  Process: 16402 ExecStart=/usr/sbin/gpsd $GPSD_OPTIONS $DEVICES (code=exited, status=0/SUCCESS)
Main PID: 16403 (gpsd)
   CGroup: /system.slice/gpsd.service
           └─16403 /usr/sbin/gpsd -n -G /dev/pps1


Status of GPSD socket:
systemctl status gpsd.socket
● gpsd.socket - GPS (Global Positioning System) Daemon Sockets
   Loaded: loaded (/etc/systemd/system/gpsd.socket; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2023-07-18 23:13:04 UTC; 20min ago
   Listen: /var/run/gpsd.sock (Stream)
           [::1]:2947 (Stream)
           127.0.0.1:2947 (Stream)
   CGroup: /system.slice/gpsd.socket

Output of gpsmon
tcp://localhost:2947          JSON slave driver>
(82) {"class":"VERSION","release":"3.17","rev":"3.17","proto_major":3,"proto_minor":12}
(123) {"class":"DEVICES","devices":[{"class":"DEVICE","path":"/dev/pps1","driver":"PPS","activated":"2023-07-18T23:02:53.182Z"}]}
(122) {"class":"WATCH","enable":true,"json":false,"nmea":false,"raw":2,"scaled":false,"timing":false,"split24":false,"pps":true}

cat /etc/chrony/chrony.conf
 # WARNING: Private GPS-sourced NTP servers have no polling abuse concerns.
server 10.10.10.200 minpoll 0 maxpoll 0 maxdelay 0.5 iburst

# Location of ID/key pairs for NTP authentication.
keyfile /etc/chrony/chrony.keys

# Store new gain/loss rate, for compensating the system clock upon restart.
driftfile /var/lib/chrony/chrony.drift

logdir /var/log/chrony

# Enable logging of clock drift.
#log tracking measurements statistics
# Stop bad estimates upsetting machine clock.
maxupdateskew 100.0
 
# Enable kernel synchronisation (every 11 minutes) of the real-time clock.
rtcsync

# Use the real-time FIFO scheduler with the specified priority (between 0
# and 100). This results in reduced latency (extreme clock stability).
sched_priority 1

minsamples 32

# Step the system clock instead of slewing it if the adjustment is larger than
# one second, but only in the first three clock updates.
makestep 1 3 

# Enable hardware timestamping of NTP packets for all interfaces.
hwtimestamp *

# Synchronize time using the rising edge of a 1-pulse-per-second clock.
refclock PPS /dev/pps1 refid PPS1 poll 0 precision 1e-9 prefer
refclock SHM 0 offset 0.5 delay 0.2 refid SHM0


We can see that GPSD is creating shared memory objects and GPSD and Chrony seems connected to shmid "0".
ipcs -m
------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x4e545030 0          root       600        80         2
0x4e545031 32769      root       600        80         1
0x4e545032 65538      root       666        80         1
0x4e545033 98307      root       666        80         1
0x4e545034 131076     root       666        80         1
0x4e545035 163845     root       666        80         1
0x4e545036 196614     root       666        80         1
0x4e545037 229383     root       666        80         1
0x47505344 262152     root       666        8928       1 


Chrony is able to receive and lock to refid PPS1 but it is not able to receive anything on refid SHM0.
chronyc sources
210 Number of sources = 3
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
#* PPS1                          0   0   377     2   -329ns[ -369ns] +/- 1000ns
#? SHM0                          0   4     0     -     +0ns[   +0ns] +/-    0ns
^- 10.10.10.200                  1   0   377     1    +25us[  +25us] +/- 1169us


Questions:

Why is GPSD not able to read data from /dev/pps1 and feed it into SHM?
Are we missing any configuration?
Is it even possible to use GPSD SHM with pps-gpio?

Thanks,
Jatinder

reply via email to

[Prev in Thread] Current Thread [Next in Thread]