5

I try to sync time using NTP and GPS. I can get time from cgps -s command, but NTP didn't sync with it.

This's my ntp.conf:

tos mindist 1.0

# GPS Serial data reference
server 127.127.28.0 minpoll 4 maxpoll 4 prefer
fudge 127.127.28.0 refid GPS
fudge 127.127.28.0 time1 +0.140  # coarse processing delay offset

# GPS PPS reference
server 127.127.22.0 minpoll 4 maxpoll 4
fudge 127.127.22.0 refid PPS
fudge 127.127.22.0 flag3 1  # enable kernel PLL/FLL clock discipline

This's ntpd status:

# ntpq -c peer -c as -c rl
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 SHM(0)          .GPS.            0 l    -   16    0    0.000    0.000   0.000
 PPS(0)          .PPS.            0 l    -   16    0    0.000    0.000   0.000

ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 49508  801b   yes    no  none    reject clock_alarm  1
  2 49509  8011   yes    no  none    reject    mobilize  1
associd=0 status=c011 leap_alarm, sync_unspec, 1 event, freq_not_set,
version="ntpd [email protected] Wed Mar  8 00:02:05 UTC 2017 (1)",
processor="armv7l", system="Linux/3.14.2", leap=11, stratum=16,
precision=-20, rootdelay=0.000, rootdisp=34.350, refid=INIT,
reftime=00000000.00000000  Thu, Feb  7 2036 14:28:16.000,
clock=d66f067f.64a88e62  Thu, Jan  2 2014  5:26:23.393, peer=0, tc=3,
mintc=3, offset=0.000, frequency=0.000, sys_jitter=0.000,
clk_jitter=0.001, clk_wander=0.000

This's the output of cgps command:

# cgps -s
┌───────────────────────────────────────────┐
│    Time:       2017-03-15T00:51:10.000Z   │
│    Latitude:    37.927624 S               │
│    Longitude:  145.135400 E               │
│    Altitude:   261.5 ft                   │
│    Speed:      0.1 mph                    │
│    Heading:    0.0 deg (true)             │
│    Climb:      0.0 ft/min                 │
│    Status:     3D FIX (5 secs)            │
│    Longitude Err:   +/- 61 ft             │
│    Latitude Err:    +/- 142 ft            │
│    Altitude Err:    +/- 75 ft             │
│    Course Err:      n/a                   │                                 
│    Speed Err:       +/- 194 mph           │                                 
│    Time offset:     -100926684.061        │                                
│    Grid Square:     QF22nb                │                                 
└───────────────────────────────────────────┘

This's options for ntp and gps:

# ps | grep gps
  149 root     /usr/sbin/gpsd -n -P /var/run/gpsd.pid /dev/ttyS1    
# ps | grep ntp
11952 root     /usr/sbin/ntpd -g

I appreciate any tips that can guide is in the right direction.

7
  • 1
    You should set PPS as prefer, rather than GPS. Also, NTP can take up to 15 minutes calibrating the connection before it starts adjusting the clock. And if you can, you should have some external higher stratum servers in your ntp.conf. Commented Mar 15, 2017 at 1:30
  • 1
    I tried to set PPS as prefer, but no luck, I waited enough time (over 1 hour) for NTP to sync. And as this product will be used in desert, there no network, no 3g. except GPS I don't know is there any external higher stratum I can use to sync time. Thank you.
    – sanduo
    Commented Mar 15, 2017 at 3:29
  • If you have ppstest, what does the output of sudo /path/to/ppstest /dev/pps0 look like? Commented Mar 15, 2017 at 14:08
  • 3
    Sorry for the late reply. This week I got a chance continue to test this issue. And found out it's because shm flag1. reference is: eecis.udel.edu/~mills/ntp/html/drivers/driver28.html Thank you very much for your help:)
    – sanduo
    Commented Apr 13, 2017 at 6:54
  • 1
    side questyion are you sure your GPS antenna is OK ? Speed Err: +/- 194 mph sounds like a hell lot for a GPS.
    – Kiwy
    Commented Apr 23, 2018 at 14:44

1 Answer 1

3

I had the same problem and SHM flag1 was the culprit. For clarity, this is how I resolved it (make these changes in ntp.conf):

server 127.127.28.0 
fudge  127.127.28.0 time1 0.183 flag1 1 refid GPS
server 127.127.28.2 prefer
fudge  127.127.28.2 flag1 1 refid PPS
1
  • 1
    That flag1 is SO important!! It tells ntp not to throw out samples where the time would change more than 24h.
    – Brad Hein
    Commented Apr 26, 2021 at 2:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .