NTP PPS


286 posts   Page 7 of 12   1 ... 4, 5, 6, 7, 8, 9, 10 ... 12
by shdosf » Thu Oct 18, 2012 4:54 pm
trying to set this up and having (hopefully) one last problem.

I've recompiled the kernel with the changes specified here. I've confirmed the pps_gpio and pps_core modules load. I've made the changes to the udev config to make the devices. the /dev/gps0 device is created but the /dev/pps0 and /dev/gpspps0 devices are not created.

can someone tell me the major/minor numbers and the type of device?

any other ideas on this?

thanks
Posts: 7
Joined: Thu Oct 18, 2012 4:48 pm
by peterwillcn » Fri Oct 19, 2012 12:20 am
PPS processing can be done in application programs but it makes much more sense when done in the operating system kernel. When polling a time source every 20 minutes, an offset of 5ms is rather small, but when polling a signal every second, an offset of 5ms is very high. Therefore a high accuracy is required for PPS processing. Application programs usually can't fulfil these demands.

The kernel clock model described before also includes algorithms to discipline the clock through an external pulse, the PPS. The additional requirements consist of two mechanisms: Capturing an external event with high accuracy, and applying that event to the clock model. The first is nowadays solved by using the PPS API while the second is implemented mostly in a routine named hardpps(). The latter routine is called every time when an external PPS event has been detected.
Last edited by peterwillcn on Fri Jan 03, 2014 3:27 am, edited 1 time in total.
User avatar
Posts: 21
Joined: Sun Sep 09, 2012 10:21 am
by shdosf » Fri Oct 19, 2012 4:02 am
did that already.

i can see the device in /proc/devices and it has a major number of 251. I have attempted to do a mknod to create it with minor numbers of 0 and 64 with no luck. what is the minor number on your /dev/pps0?
Posts: 7
Joined: Thu Oct 18, 2012 4:48 pm
by peterwillcn » Tue Oct 23, 2012 2:38 am
shdosf wrote:did that already.

i can see the device in /proc/devices and it has a major number of 251. I have attempted to do a mknod to create it with minor numbers of 0 and 64 with no luck. what is the minor number on your /dev/pps0?


run this:
Code: Select all
rpi-update
apt-get update && apt-get upgrade && apt-get dist-upgrade


downgrade the firmware
Code: Select all
apt-get install {libraspberrypi-bin,libraspberrypi-dev,libraspberrypi-doc,libraspberrypi0,raspberrypi-bootloader}=1.20120918-1


You are probably better off building the kernel from this commit:
2843e37f77f0b01001f5659906166c92ba3801d0
(https://github.com/raspberrypi/linux/co ... 92ba3801d0)
Code: Select all
git checkout 2843e37f77f0b01001f5659906166c92ba3801d0


How to build a cross compiler for your Raspberry Pi
http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/

The alternative is to work with latest firmware:
Code: Select all
rpi-update 128 6980ae88cfbc120bea4e9847d1a59c0b11c61047


Hopefully this will all be consistent again soon.
User avatar
Posts: 21
Joined: Sun Sep 09, 2012 10:21 am
by shdosf » Tue Oct 23, 2012 7:11 am
Got it working. Recompiled the kernel about 6 times on the PI, config make, go to bed, go to work, get home test, rinse repeat.

the problem I was having was the pps_ktimer. the first time or two I didn't know I needed it in the kernel. later i built it but it wasn't loading when I was loading the pps_gpio and pps_core modules.

found an old email after a google search that mentioned pps_ktimer. loaded it and it finally made the /dev/pps0 device and I could see the PPS device.

now I am debugging gps and ntp issues. at least this goes faster :)

thanks
Posts: 7
Joined: Thu Oct 18, 2012 4:48 pm
by peterwillcn » Tue Oct 23, 2012 8:58 am
In addition to these direct manipulations, hardpps() also detects, signals, and filters various error conditions. The length of the calibration interval is also adjusted automatically. As the limit for a bad calibration is ridiculously high (about 500 PPM per calibration), the calibration interval normally is always at its configured maximum.
Last edited by peterwillcn on Fri Jan 03, 2014 3:28 am, edited 1 time in total.
User avatar
Posts: 21
Joined: Sun Sep 09, 2012 10:21 am
by chrisprt » Tue Oct 23, 2012 1:17 pm
peterwillcn wrote:hey, shdosf
how to loading the pps_gpio and pps_core modules? can be described in detail?


Here's some code I wrote in the beginning to make sure the module was loaded and the symlinks were made for the GPS_NMEA() clock in NTPD.
Code: Select all
    echo "Checking to see that pps-gpio is loaded "
    res=`lsmod | grep pps_gpio`
    if [ -z "$res" ]
        then echo "pps-gpio is not loaded, loading now.."
        modprobe pps-gpio
    fi
    echo "Checking for symbolic links"
    if ! [ -c /dev/gps0 ]
        then echo "Adding GPS symlink"
        ln -s /dev/ttyAMA0 /dev/gps0
    fi
    if ! [ -c /dev/gpspps0 ]
        then echo "Adding GPS PPS symlink"
        ln -s /dev/pps0 /dev/gpspps0
    fi
Posts: 44
Joined: Fri Jul 13, 2012 6:07 pm
by shdosf » Tue Oct 23, 2012 3:24 pm
first thing to find out is if the pps stuff was built as modules or drivers into the kernel. when i rebuilt my kernel they were all built as modules. you can search in the /lib/modules/<kernel> for the modules. mine were in the form of 'pps_gpio.ko'.

to check if they are loaded you can do a 'cat /proc/modules' and you should get output looking something like this:
Code: Select all
nfsd 236425 2 - Live 0xbf07c000
ipv6 271235 32 - Live 0xbf025000
pps_ktimer 1164 1 - Live 0xbf021000
pps_gpio 2186 0 - Live 0xbf01d000
pps_core 7800 3 pps_ktimer,pps_gpio, Live 0xbf017000
spidev 5136 0 - Live 0xbf00d000
spi_bcm2708 4401 0 - Live 0xbf008000
i2c_bcm2708 3681 0 - Live 0xbf000000


you can also look at 'cat /proc/devices' or 'less /proc/devices' and see if you see a listing for 'pps' it will be listed by major device number.

to load a specific device you use the command 'modprobe' so it would be 'modprobe pps_gpio' and 'modprobe pps_ktimer' to load all the pps modules you need. once that is done and you have verified everything is there you can edit the file /etc/modules and add pps_gpio and pps_ktimer to the file - that will load the modules at boot time.

good luck
Posts: 7
Joined: Thu Oct 18, 2012 4:48 pm
by peterwillcn » Fri Oct 26, 2012 4:07 am
hey all,
I successful make a first support PPS kernel, it work very well.
Download_URL:
kernel: http://wp.openxid.com/wp-content/gallery/me/pi-kernel/kernel.tbz
module: http://wp.openxid.com/wp-content/gallery/me/pi-kernel/modules.tbz

Finally: Thanks aquarat :) and chrisprt :).

Join the pool.ntp.org project
Thanks for your interest. Usage of the pool has grown enormously and the only way we can keep it easy for everyone to run a pool server is to also grow the number of servers participating.
Join url : http://www.pool.ntp.org/en/join.html
manage url : https://manage.ntppool.org/manage

This is my ntp Server in ntp pool status
Code: Select all
Your Servers
Add a server
Hostname: ntp.openxid.com
IP: 222.35.119.30
Current score: 19.5
Stratum: 1
Zones: @ asia cn
Last edited by peterwillcn on Fri Jan 03, 2014 3:30 am, edited 1 time in total.
User avatar
Posts: 21
Joined: Sun Sep 09, 2012 10:21 am
by DungBeetle » Fri Oct 26, 2012 2:41 pm
A big thanks to chrisprt for the modified kernel and aquarat for the guide. I have managed to get this working with a sparkfun gps http://www.coolcomponents.co.uk/catalog/venus-with-connector-p-941.html
Nice things about this unit are 3.3V working which meant I could interface and power directly with the Pi and the ability in the setup software (windows) to sync the NMEA word with the PPS output.
Now to my newbie question. The binaries resulting from the build process are placed in the /usr/local/bin directories and do not replace the old ntp binaries in /usr/sbin and /usr/bin. What do I need to do to get the binaries to replace the earlier version and make them run at startup.

Thanks.
Posts: 5
Joined: Fri Sep 28, 2012 3:59 pm
by shdosf » Fri Oct 26, 2012 3:21 pm
DungBeetle

assuming your are using the debian/raspbian distribution. make a backup of your /etc/ntp.conf file and then run 'apt-get remove ntp' or 'sudo apt-get remove ntp' to remove the default package. then after having run 'make install' from the ntp sources that will place the binaries into /usr/local/bin you need to edit '/etc/init.d/ntp' and all you need todo is add '/usr/local/bin' to the path statement. then it will see your new ntpd executable and use it when you start the application.
Posts: 7
Joined: Thu Oct 18, 2012 4:48 pm
by DungBeetle » Fri Oct 26, 2012 4:45 pm
shdosf

Thanks for your help. Unfortunately if I do as you suggest I get a message at startup.
"startpar: service(s) skipped, program is not installed: ntp"
If I try /etc/init.d/ntp start then no result is output and the service is not run.
sudo ntpd works.
If I modify the line in /etc/init.d/ntp DAEMON=/usr/sbin/ntpd to DAEMON=/usr/local/bin/ntpd and then try /etc/init.d/ntp restart the following is output
[ ok ] Stopping NTP server: ntpd.
[....] Starting NTP server: ntpd/usr/local/bin/ntpd: The ``user'' option has been disabled -- built without --enable-clockctl or --enable-linuxcaps
ntpd - NTP daemon program - Ver. 4.2.7p313
USAGE: ntpd [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \
[ <server1> ... <serverN> ]

Thanks again for the help.
Posts: 5
Joined: Fri Sep 28, 2012 3:59 pm
by shdosf » Fri Oct 26, 2012 5:35 pm
OK ran into that myself. The problem you have is that your ntp was not compiled to run as a daemon on Linux. You need to recompile your NTP with the prameters --enable-clockctl and --enable-linuxcaps. here is the command I used to compile (and start) my ntp.

Code: Select all
 ./configure --disable-all-clocks --disable-parse-clocks
--enable-NMEA --enable-LOCAL-CLOCK --enable-ATOM --enable-clockctl
--enable-linuxcaps && make all && make install && /etc/init.d/ntp
restart


if you have already compiled ntp in there you can do this instead.
Code: Select all
make clean && ./configure --disable-all-clocks --disable-parse-clocks
--enable-NMEA --enable-LOCAL-CLOCK --enable-ATOM --enable-clockctl
--enable-linuxcaps && make all && make install && /etc/init.d/ntp
restart


if you have different clock needs change it to meet your needs.
Posts: 7
Joined: Thu Oct 18, 2012 4:48 pm
by deltalima » Fri Oct 26, 2012 7:25 pm
I have a Sure GPS board connected via serial to the Pi.

Connections are as follows

GPS PI
GND GND (Pin 6)
TX RX (Pin 10)
RX TX (Pin 8)
PPS PPS (Pin 16)

Receiving NMEA data OK and ntpd running.

I can't get a PPS signal via the GPIO.

I have built custom kernels but the default now seems to have pps built in.

If I modprobe pps-ktimer, /dev/pps0 and /dev/gpspps0 are created and ntp synchs to the test PPS signal, however if I dont use pps-ktimer the devices are not created all I see is

[ 9.612050] pps_core: LinuxPPS API ver. 1 registered
[ 9.613702] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
in dmesg

I have

KERNEL=="ttyAMA0", SYMLINK+="gps0"
KERNEL=="pps0", OWNER="root", GROUP="tty", MODE="0777", SYMLINK+="gpspps0"

in /etc/udev/rules.d/09.pps.rules and

pps-gpio in /etc/modules

Am I missing something?
Posts: 5
Joined: Thu Oct 25, 2012 8:05 pm
by shdosf » Fri Oct 26, 2012 7:50 pm
you need to load the pps-ktimer module for pps to load. you can update the file /etc/modules and put pps-ktimer on it's own line and then it will load on reboot.
Posts: 7
Joined: Thu Oct 18, 2012 4:48 pm
by chrisprt » Fri Oct 26, 2012 7:51 pm
deltalima wrote:If I modprobe pps-ktimer, /dev/pps0 and /dev/gpspps0 are created and ntp synchs to the test PPS signal, however if I dont use pps-ktimer the devices are not created all I see is
...

pps-gpio in /etc/modules

Am I missing something?


modprobe pps-gpio, not pps-ktimer.
Posts: 44
Joined: Fri Jul 13, 2012 6:07 pm
by deltalima » Fri Oct 26, 2012 7:55 pm
chrisprt wrote:
deltalima wrote:If I modprobe pps-ktimer, /dev/pps0 and /dev/gpspps0 are created and ntp synchs to the test PPS signal, however if I dont use pps-ktimer the devices are not created all I see is
...

pps-gpio in /etc/modules

Am I missing something?


modprobe pps-gpio, not pps-ktimer.


Yes, when I do modprobe pps-gpio I don't see /dev/pps0 created

I did modprobe pps-ktimer as a test, that created /dev/pps0 and ntp synchs, but this is a test and the PPS is not synched to the pulse coming from the GPS unit.
Posts: 5
Joined: Thu Oct 25, 2012 8:05 pm
by deltalima » Fri Oct 26, 2012 7:58 pm
shdosf wrote:you need to load the pps-ktimer module for pps to load. you can update the file /etc/modules and put pps-ktimer on it's own line and then it will load on reboot.


Isn't pps-ktimer a test and not synched to the PPS coming fro the GPS?
Posts: 5
Joined: Thu Oct 25, 2012 8:05 pm
by chrisprt » Fri Oct 26, 2012 8:00 pm
peterwillcn wrote:hey all,
thanks everyone
I successful make a first support PPS kernel, it work very well.
[code]


Awesome! congrats!

peterwillcn wrote:Join the pool.ntp.org project
Thanks for your interest. Usage of the pool has grown enormously and the only way we can keep it easy for everyone to run a pool server is to also grow the number of servers participating.
Join url : http://www.pool.ntp.org/en/join.html
manage url : https://manage.ntppool.org/manage


Agree. If my ISP wasn't terrible and I had a static IP I'd be in the pool for sure. Thanks for contributing!
Posts: 44
Joined: Fri Jul 13, 2012 6:07 pm
by chrisprt » Sat Oct 27, 2012 3:41 pm
deltalima wrote:Yes, when I do modprobe pps-gpio I don't see /dev/pps0 created

I did modprobe pps-ktimer as a test, that created /dev/pps0 and ntp synchs, but this is a test and the PPS is not synched to the pulse coming from the GPS unit.



Hmm, that is odd. check dmesg and tail all of the log files. There should be some error, because after I modprobe pps-gpio it immediately shows up. I actually run this on bootup to make sure all the links are setup correctly:
Code: Select all
case "$1" in
  start)
    echo "Checking to see that pps-gpio is loaded "
    res=`lsmod | grep pps_gpio`
    if [ -z "$res" ]
        then echo "pps-gpio is not loaded, loading now.."
        modprobe pps-gpio
    fi
    echo "Checking for symbolic links"
    if ! [ -c /dev/gps0 ]
        then echo "Adding GPS symlink"
        ln -s /dev/ttyAMA0 /dev/gps0
    fi
    if ! [ -c /dev/gpspps0 ]
        then echo "Adding GPS PPS symlink"
        ln -s /dev/pps0 /dev/gpspps0
    fi
    ;;
  *)
    echo "Usage: /etc/init.d/blah {start|stop}"
    exit 1
    ;;
esac


So it expects /dev/pps0 to be there right away.

You should see something like this in dmesg:
Code: Select all
[   19.122502] pps_core: LinuxPPS API ver. 1 registered
[   19.122528] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[   19.132139] pps pps0: new PPS source pps-gpio.-1
[   19.132212] pps pps0: Registered IRQ 194 as PPS source
Posts: 44
Joined: Fri Jul 13, 2012 6:07 pm
by chrisprt » Sat Oct 27, 2012 3:43 pm
deltalima wrote:Isn't pps-ktimer a test and not synched to the PPS coming fro the GPS?


Yes. Found in pps-ktimer.c:
Code: Select all
/*
 * pps-ktimer.c -- kernel timer test client
Posts: 44
Joined: Fri Jul 13, 2012 6:07 pm
by deltalima » Sat Oct 27, 2012 4:31 pm
chrisprt wrote:
deltalima wrote:Yes, when I do modprobe pps-gpio I don't see /dev/pps0 created

I did modprobe pps-ktimer as a test, that created /dev/pps0 and ntp synchs, but this is a test and the PPS is not synched to the pulse coming from the GPS unit.



Hmm, that is odd. check dmesg and tail all of the log files. There should be some error, because after I modprobe pps-gpio it immediately shows up. I actually run this on bootup to make sure all the links are setup correctly:
Code: Select all
case "$1" in
  start)
    echo "Checking to see that pps-gpio is loaded "
    res=`lsmod | grep pps_gpio`
    if [ -z "$res" ]
        then echo "pps-gpio is not loaded, loading now.."
        modprobe pps-gpio
    fi
    echo "Checking for symbolic links"
    if ! [ -c /dev/gps0 ]
        then echo "Adding GPS symlink"
        ln -s /dev/ttyAMA0 /dev/gps0
    fi
    if ! [ -c /dev/gpspps0 ]
        then echo "Adding GPS PPS symlink"
        ln -s /dev/pps0 /dev/gpspps0
    fi
    ;;
  *)
    echo "Usage: /etc/init.d/blah {start|stop}"
    exit 1
    ;;
esac


So it expects /dev/pps0 to be there right away.

You should see something like this in dmesg:
Code: Select all
[   19.122502] pps_core: LinuxPPS API ver. 1 registered
[   19.122528] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[   19.132139] pps pps0: new PPS source pps-gpio.-1
[   19.132212] pps pps0: Registered IRQ 194 as PPS source


Thanks,

Repatched the kernel and did a rebuild, all working now!

pi@raspberrypi ~ $ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
oGPS_NMEA(0) .GPS. 0 l 3 16 377 0.000 -0.047 0.004
-ntp1.as34288.ne .MRS. 1 u 9 64 377 50.924 -3.681 0.288
+ntps1-1.eecsit. .GPS. 1 u 9 64 377 60.219 -5.148 0.563
+zeit.fu-berlin. .PPS. 1 u 37 64 377 58.699 -5.064 0.169
*ntp1.rrze.uni-e .DCFp. 1 u 42 64 377 48.929 -4.634 0.168
-erquy.linocomm. .PPS. 1 u 28 64 377 42.776 -3.818 0.211
pi@raspberrypi ~ $
Posts: 5
Joined: Thu Oct 25, 2012 8:05 pm
by abbadabbatech » Wed Oct 31, 2012 7:25 pm
aquarat wrote:Pic : (hosted on a pi)
Image

Wondered if you did a technote on or would share the pin connection from pi to ultimate gps and maybe a code example of pulling data?

Thanks
Posts: 1
Joined: Wed Oct 31, 2012 7:19 pm
by deltalima » Sat Nov 03, 2012 9:52 pm
After a week of running it looks good. Here's what RRDTool shows.

The GPS puck is indoors so maybe would get better signal (more sats and less multipath) if mounted outside. The pi is in the kitchen the big positive offset match cooking times so I'm guessing are temperature related.

ntpoff-day.png
ntpoff-day.png (10.46 KiB) Viewed 2317 times
Posts: 5
Joined: Thu Oct 25, 2012 8:05 pm
by aquarat » Tue Nov 06, 2012 9:01 am
Code: Select all
 11:01:29 up 53 days, 19:39,  2 users,  load average: 1.56, 1.60, 1.82

Image
It's the most accurate time server I've ever had... and it's proving to be very reliable :) .
EOF
User avatar
Posts: 73
Joined: Thu Jul 26, 2012 2:32 pm
Location: Cape Town, South Africa