Black Lives Matter - Action and Equality. ... Adafruit is part of the Stop Hate for Profit campaign. Adafruit is open and shipping.
0

Raspberry Pi GPS Stratum 1 NTP Server
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 3:06 pm

I did read it and it looked good.

Look at /var/log/messages and see if there are any ntp related errors.
Make sure that the /dev/gps0 and /dev/gpspps0 links are created.
With ntpd stopped, run 'lsof /dev/ttyAMA0' and 'lsof /dev/pps0' to see if any other program has the devices open.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 3:15 pm

So this are the last entry of the messages but at least 3 hours ago (here it's 8pm):
Code: Select all | TOGGLE FULL SIZE
r 20 17:37:02 raspberrypi kernel: [    1.511196] EXT4-fs (mmcblk0p2): INFO: recovery required on readonly filesystem
Mar 20 17:37:02 raspberrypi kernel: [    1.512923] EXT4-fs (mmcblk0p2): write access will be enabled during recovery
Mar 20 17:37:02 raspberrypi kernel: [    1.685941] usb 1-1: new high-speed USB device number 2 using dwc_otg
Mar 20 17:37:02 raspberrypi kernel: [    1.687945] Indeed it is in host mode hprt0 = 00001101
Mar 20 17:37:02 raspberrypi kernel: [    1.886243] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
Mar 20 17:37:02 raspberrypi kernel: [    1.888045] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Mar 20 17:37:02 raspberrypi kernel: [    1.890996] hub 1-1:1.0: USB hub found
Mar 20 17:37:02 raspberrypi kernel: [    1.892944] hub 1-1:1.0: 5 ports detected
Mar 20 17:37:02 raspberrypi kernel: [    2.175993] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
Mar 20 17:37:02 raspberrypi kernel: [    2.276260] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
Mar 20 17:37:02 raspberrypi kernel: [    2.278141] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Mar 20 17:37:02 raspberrypi kernel: [    2.282974] smsc95xx v1.0.4
Mar 20 17:37:02 raspberrypi kernel: [    2.340420] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-bcm2708_usb-1.1, smsc95xx USB 2.0 Ethernet, b8:2$
Mar 20 17:37:02 raspberrypi kernel: [    3.365329] EXT4-fs (mmcblk0p2): recovery complete
Mar 20 17:37:02 raspberrypi kernel: [    3.375856] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
Mar 20 17:37:02 raspberrypi kernel: [    3.379670] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
Mar 20 17:37:02 raspberrypi kernel: [    3.382999] devtmpfs: mounted
Mar 20 17:37:02 raspberrypi kernel: [    3.386063] Freeing unused kernel memory: 340K (c0795000 - c07ea000)
Mar 20 17:37:02 raspberrypi kernel: [    6.500913] pps_core: LinuxPPS API ver. 1 registered
Mar 20 17:37:02 raspberrypi kernel: [    6.504828] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
Mar 20 17:37:02 raspberrypi kernel: [    6.606428] pps pps0: new PPS source pps.-1
Mar 20 17:37:02 raspberrypi kernel: [    6.622724] pps pps0: Registered IRQ 398 as PPS source
Mar 20 17:37:02 raspberrypi kernel: [   10.185885] random: nonblocking pool is initialized
Mar 20 17:37:02 raspberrypi kernel: [   11.070863] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
Mar 20 17:37:02 raspberrypi kernel: [   11.511605] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
Mar 20 17:37:02 raspberrypi kernel: [   22.312139] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
Mar 20 17:37:02 raspberrypi kernel: [   23.892676] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
Mar 20 17:37:04 raspberrypi kernel: [   27.987548] Adding 102396k swap on /var/swap.  Priority:-1 extents:2 across:2134012k SSFS


How can i check the links?

And here the others:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ lsof /dev/ttyAMA0
-bash: lsof: command not found

pi@raspberrypi ~ $ lsof /dev/pss0
-bash: lsof: command not found


Could it be a problem that the drift file ( /var/lib/ntp/ntp.drift) is empty?

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 3:31 pm

Those are the messages from the kernel. My mistake. Look at /var/log/syslog instead...

Code: Select all | TOGGLE FULL SIZE
# grep ntp /var/log/syslog
Mar 20 13:29:55 ernie ntpd[16759]: ntpd 4.2.6p5@1.2349-o Thu Feb  5 14:49:17 UTC 2015 (1)
Mar 20 13:29:55 ernie ntpd[16760]: proto: precision = 0.558 usec
Mar 20 13:29:55 ernie ntpd[16760]: 0.0.0.0 c01d 0d kern kernel time sync enabled
Mar 20 13:29:55 ernie ntpd[16760]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
Mar 20 13:29:55 ernie ntpd[16760]: Listen and drop on 1 v6wildcard :: UDP 123
Mar 20 13:29:55 ernie ntpd[16760]: Listen normally on 2 lo 127.0.0.1 UDP 123
...


To check the links...

Code: Select all | TOGGLE FULL SIZE
# ls -al /dev
<snip>
lrwxrwxrwx   1 root root             7 Mar 17 09:59 gps0 -> ttyAMA0
lrwxrwxrwx   1 root root             7 Mar 17 09:59 gpspps0 -> pps0
<snip>
#


To install lsof... 'apt-get install lsof'

The drift file will stay empty until ntpd runs successfully and can calculate the drift.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 3:45 pm

Okay this is the last syslog:
Code: Select all | TOGGLE FULL SIZE
Mar 20 17:37:05 raspberrypi ntpd[2057]: format error frequency file /var/lib/ntp/ntp.drift
Mar 20 17:37:02 raspberrypi kernel: [    0.001987] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mar 20 17:37:04 raspberrypi ntpd[2061]: ntpd 4.2.8p1@1.3265-o Thu Mar 19 14:29:47 UTC 2015 (1): Starting
Mar 20 17:37:04 raspberrypi ntpd[2061]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 102:104
Mar 20 17:37:05 raspberrypi ntpd[2082]: proto: precision = 3.000 usec (-18)
Mar 20 17:37:05 raspberrypi ntpd[2082]: Listen and drop on 0 v4wildcard 0.0.0.0:123
Mar 20 17:37:05 raspberrypi ntpd[2082]: Listen normally on 1 lo 127.0.0.1:123
Mar 20 17:37:05 raspberrypi ntpd[2082]: Listen normally on 2 eth0 192.168.2.3:123
Mar 20 17:37:05 raspberrypi ntpd[2082]: Listening on routing socket on fd #19 for interface updates
Mar 20 17:37:05 raspberrypi ntpd[2082]: restrict 0.0.0.0: KOD does nothing without LIMITED.
Mar 20 17:37:05 raspberrypi ntpd[2082]: restrict ::: KOD does nothing without LIMITED.
Mar 20 17:37:05 raspberrypi ntpd[2082]: restrict: ignoring line 37, mask '::' unusable.
Mar 20 17:37:05 raspberrypi ntpd[2082]: format error frequency file /var/lib/ntp/ntp.drift
Mar 20 17:44:30 raspberrypi ntpd[2082]: ntpd exiting on signal 15 (Terminated)
Mar 20 17:44:33 raspberrypi ntpd[2408]: ntpd 4.2.8p1@1.3265-o Thu Mar 19 14:29:47 UTC 2015 (1): Starting
Mar 20 17:44:33 raspberrypi ntpd[2408]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 102:104
Mar 20 17:44:33 raspberrypi ntpd[2411]: proto: precision = 3.000 usec (-18)
Mar 20 17:44:33 raspberrypi ntpd[2411]: Listen and drop on 0 v4wildcard 0.0.0.0:123
Mar 20 17:44:33 raspberrypi ntpd[2411]: Listen normally on 1 lo 127.0.0.1:123
Mar 20 17:44:33 raspberrypi ntpd[2411]: Listen normally on 2 eth0 192.168.2.3:123
Mar 20 17:44:33 raspberrypi ntpd[2411]: Listening on routing socket on fd #19 for interface updates
Mar 20 17:44:33 raspberrypi ntpd[2411]: restrict 0.0.0.0: KOD does nothing without LIMITED.
Mar 20 17:44:33 raspberrypi ntpd[2411]: restrict ::: KOD does nothing without LIMITED.
Mar 20 17:44:33 raspberrypi ntpd[2411]: restrict: ignoring line 37, mask '::' unusable.
Mar 20 17:44:33 raspberrypi ntpd[2411]: format error frequency file /var/lib/ntp/ntp.drift
Mar 20 17:54:06 raspberrypi ntpd[2411]: ntpd exiting on signal 15 (Terminated)
Mar 20 17:54:08 raspberrypi ntpd[2491]: ntpd 4.2.8p1@1.3265-o Thu Mar 19 14:29:47 UTC 2015 (1): Starting
Mar 20 17:54:08 raspberrypi ntpd[2491]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 102:104
Mar 20 17:54:08 raspberrypi ntpd[2494]: proto: precision = 3.000 usec (-18)
Mar 20 17:54:08 raspberrypi ntpd[2494]: Listen and drop on 0 v4wildcard 0.0.0.0:123
Mar 20 17:54:08 raspberrypi ntpd[2494]: Listen normally on 1 lo 127.0.0.1:123
Mar 20 17:54:08 raspberrypi ntpd[2494]: Listen normally on 2 eth0 192.168.2.3:123
Mar 20 17:54:08 raspberrypi ntpd[2494]: Listening on routing socket on fd #19 for interface updates
Mar 20 17:54:08 raspberrypi ntpd[2494]: restrict 0.0.0.0: KOD does nothing without LIMITED.
Mar 20 17:54:08 raspberrypi ntpd[2494]: restrict ::: KOD does nothing without LIMITED.
Mar 20 17:54:08 raspberrypi ntpd[2494]: restrict: ignoring line 37, mask '::' unusable.
Mar 20 17:54:08 raspberrypi ntpd[2494]: format error frequency file /var/lib/ntp/ntp.drift
Mar 20 19:44:25 raspberrypi ntpd[2494]: refclock_params: time_pps_kcbind: Operation not supported
Mar 20 19:54:57 raspberrypi ntpd[2494]: ntpd exiting on signal 15 (Terminated)
Mar 20 19:55:00 raspberrypi ntpd[2595]: ntpd 4.2.8p1@1.3265-o Thu Mar 19 14:29:47 UTC 2015 (1): Starting
Mar 20 19:55:00 raspberrypi ntpd[2595]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 102:104
Mar 20 19:55:00 raspberrypi ntpd[2598]: proto: precision = 3.000 usec (-18)
Mar 20 19:55:00 raspberrypi ntpd[2598]: Listen and drop on 0 v4wildcard 0.0.0.0:123
Mar 20 19:55:00 raspberrypi ntpd[2598]: Listen normally on 1 lo 127.0.0.1:123
Mar 20 19:55:00 raspberrypi ntpd[2598]: Listen normally on 2 eth0 192.168.2.3:123
Mar 20 19:55:00 raspberrypi ntpd[2598]: Listening on routing socket on fd #19 for interface updates
Mar 20 19:55:00 raspberrypi ntpd[2598]: restrict 0.0.0.0: KOD does nothing without LIMITED.
Mar 20 19:55:00 raspberrypi ntpd[2598]: restrict ::: KOD does nothing without LIMITED.
Mar 20 19:55:00 raspberrypi ntpd[2598]: restrict: ignoring line 37, mask '::' unusable.
Mar 20 19:55:00 raspberrypi ntpd[2598]: format error frequency file /var/lib/ntp/ntp.drift
Mar 20 20:09:43 raspberrypi ntpd[2598]: ntpd exiting on signal 15 (Terminated)


Thats the links:
Code: Select all | TOGGLE FULL SIZE
lrwxrwxrwx  1 root root           7 Jan  1  1970 gps0 -> ttyAMA0
lrwxrwxrwx  1 root root           4 Jan  1  1970 gpspps0 -> pps0


After lsof installed typing lsof /dev/ttyAMA0 nothing happens and lsof /dev/pps0:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ lsof /dev/ttyAMA0
pi@raspberrypi ~ $ lsof /dev/pss0
lsof: status error on /dev/pss0: No such file or directory
lsof 4.86
 latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
 latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
 latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
 usage: [-?abhKlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-f[gG]] [+|-e s]
 [-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]] [-p s]
[+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Use the ``-h'' option to get more help information.

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 3:55 pm

OK, well, delete the /var/lib/ntp/ntp.drift file. I don't think that's the problem but it won't hurt.

When you did the lsof, you need to use /dev/pps0. I typed pss0 by mistake. :)

So what's the output of ntpq -pn now?

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 4:08 pm

drift file deleted by sudo rm /var/lib/ntp/ntp.drift

yes i typed lsof /dev/pss0 and lsof /dev/ttyAMA0. What should happen when i type this?

The output is still the same:
pi@raspberrypi ~ $ ntpq -pn
remote refid st t when poll reach delay offset jitter
==========================================================
127.127.22.0 .PPS0. 1 l - 8 0 0.000 0.000 0.000
127.127.20.0 .GPS0. 1 l - 8 0 0.000 0.000 0.000

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 4:17 pm

I don't understand why it's not working.

You did /dev/pps0 correct? Not /dev/pss0 right?
The lsof commands should show nothing. That means no other program has them open.

Do you have a battery installed on the gps hat? If not, you should. It will allow the GPS to keep it's configuration across power resets.

Let me try this on a Debian system I have tonight. It's not a pi but I should be able to write something up for you to follow.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 4:24 pm

yes there is a battery on the board:)
And yes pps0 with zero...
So you make this and try something and i will set up sd card again on monday morning and work through the tutorial i wrote today, so there won't be any unexpected steps and no gpsd or chrony. Than we will see if it's working:)

If you have something for me just post it:)

By the way, which country are you from?

At a very big thank you for your help and your patience, this is not natural:)

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 4:29 pm

Sounds good. I'm in the US, Colorado.

Actually, I just ordered a Pi2 and the gps hat to test with :)

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 4:52 pm

Ah that's cool:) then we have the same conditions :)
So you also use the adafruit hat?
The raspberry pi is ordered for one week and should arrive on Monday :)

Hope we can reach our aim :)

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Mon Mar 23, 2015 6:48 am

So now I have a big other problem:
I was setting up a new SD card and got the pps. Then i wanted to test the GPS with "cat /dev/ttyAMA0" and got this output:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ stty -F /dev/ttyAMA0 raw 9600 cs8 clocal -cstopb
pi@raspberrypi ~ $ cat /dev/ttyAMA0
V��PMR�``'���c3J��P6pC�yz"b;�Y��M����h�b��   ��,Ib/�
�o�ʩGEE�^XV��h`N���Ec�)JC�^C

What's wrong here? I tried this with a complete new SD card without any settings too, and got the same output.
Did we change something in the GPS Module or something in the Pi?

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Mon Mar 23, 2015 8:13 am

Could it be that we changed the baud of the chip to 115200 which is not changed by setting up the SD Card? Because i did the further steps and changing the baud to 115200 and now i see the normal GPS Output.
How can i set the baud back to 9600, means initial state from factory? Or how can i set the serial ports to initial state?

I tested the following steps too, and the GPS still don't get a fix with ntp...
When i test it with my other SD Card with GPSD i don't get GPS too, maybe something wrong with the GPS init?

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Mon Mar 23, 2015 12:03 pm

When you start ntpd, it'll automatically set the correct baud rate on the port, or you could run the gpsinit command from my tools package.

To set the speed of both the port and the device...
Code: Select all | TOGGLE FULL SIZE
#
./gpsinit -s 115200 /dev/ttyAMA0


To reset the device to factory defaults...
Code: Select all | TOGGLE FULL SIZE
./gpsinit -s 9600 -i factory_reset /dev/ttyAMA0


To set it up for good time keeping...
Code: Select all | TOGGLE FULL SIZE
./gpsinit -s 115200 -i "PMTK314,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0" /dev/ttyAMA0


I tried setting up a Debian system in a virtual machine but the VM causes problems with time setting so that didn't work. My pi and gps hat should be here tomorrow though so I'm certain we can get this working.

In the mean time, what I did find was that instead of using 2 different server/fudge entries, one for PPS and one for GPS, it's better to use 1 single combined entry as follows...

Code: Select all | TOGGLE FULL SIZE
server 127.127.20.0 mode 88 minpoll 3 iburst
fudge 127.127.20.0 stratum 1 flag1 1 flag2 0 flag3 1 flag4 0 time1 0.0 time2 0.0 refid GPS0


"flag1 1" tells ntpd that this is a combined gps and pps device and allows it to discipline them together.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Mon Mar 23, 2015 12:14 pm

The problem i have is that since I changed the baud rate i i'm not longer able to get the time by gps. With or without gpsd, makes no difference. So does your gpsinit change something one the mt3339 chip?
So i will try to set it to factory state and check if the gps time can be used then. If so there is a problem with the init and wie can make further steps:)
So the command is: ./gpsinit -s 9600 -i factory_reset /dev/ttyAMA0 ?
I can try this in 2,5 hours and tell the results to you;)
Then we hope your pi is coming soon, so we can solve this problem:)

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Mon Mar 23, 2015 12:21 pm

Yes, the gpsinit command always sets both the port and the gps unit to the same speed.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Please be positive and constructive with your questions and comments.