Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Nov 2016 13:31:19 -0700
From:      Ian Lepore <ian@freebsd.org>
To:        Peter =?ISO-8859-1?Q?Ankerst=E5l?= <peter@pean.org>
Cc:        "freebsd-arm@FreeBSD.org" <freebsd-arm@FreeBSD.org>
Subject:   Re: PPS input on GPIO pin RPI2.
Message-ID:  <1479846679.1889.8.camel@freebsd.org>
In-Reply-To: <3FE31F8E-CFDF-4C36-89F8-B90EB8AC2D8D@pean.org>
References:  <56FCEE15.60109@pean.org> <1460061822.1091.314.camel@freebsd.org> <794E7B45-5512-4032-8CBE-7D2BD1533BD4@pean.org> <1479426298.59911.135.camel@freebsd.org> <E2942C0C-D3A6-4163-B794-81CBF98C415B@pean.org> <1479426521.59911.137.camel@freebsd.org> <0D888B68-3231-4611-83FA-47DCD1A75CA5@pean.org> <1479837907.12501.39.camel@freebsd.org> <3FE31F8E-CFDF-4C36-89F8-B90EB8AC2D8D@pean.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 2016-11-22 at 20:57 +0100, Peter Ankerstĺl wrote:
> > 
> > 
> > So without overlay support, you need to modify the dts file for your
> > board to add the pps device.  For my wandboards I added it at the root
> > of the device tree (not as a child of some existing bus).  You can
> > append something like this to the end of your existing dts file:
> > 
> >    / {
> >    	    pps@0     {
> >    	    	    compatible = "pps-gpio";
> >    	    	    gpios = <&gpio3 27 GPIO_ACTIVE_HIGH>;
> >    	    	    status = "okay";
> >    	    };
> >    };
> > 
> > I don't know much about rpi, but I vaguely recall it only has one gpio
> > controller, so probably replace gpio3 with just gpio.  I'm not sure
> > what to do about pin config on an rpi, it just needs to be an input
> > pin, preferably without any pullup or pulldown enabled.  
> > 
> > Oh yeah, and... be careful about voltage... many PPS sources emit a 5v
> > pulse, and rpi pins are 3.3v inputs.  I've gotten around that in the
> > past with passive voltage dividers made from a pair of 50-ohm
> > resistors; the roughly 2.5v pulse you get from tapping the middle of
> > the divider is plenty to get sensed on the gpio pin.
> > 
> > 
> Thanks. I actually have a gps that outputs 3.3v. (adafruit).
> 
> I added this:
>         pps@0  {
>                 compatible = "pps-gpio";
>                 gpios = <&gpio 27 0>;
>                 status = "okay";
>         };
> 
> and it now works fine:
> 
> gpiopps0:  on ofwbus0
> gpiopps0: PPS input on gpio0 pin 27
> 
> added link /dev/pps0 -> gpiopps0
> 
> and have server 127.127.22.0 in ntp.conf.
> 
> root@ntp:~ # ntpq -p
>      remote   refid    st t when poll reach   delay   offset  jitter
> ====================================================================
> oPPS(0)       .PPS.    0 l   17   64  377    0.000    1.803   0.014
> *gbg1.ntp.se  .PPS.    1 u   23   64  377    7.309    1.764   0.054
> +gbg2.ntp.se  .PPS.    1 u    7   64  377    7.173    1.765   0.041

Cool!  I notice we lost the CC to the arm@ list somewhere along the
line.  I've added it back for this reply, so that other folks can see
how to get this all configured.

For those following along... this setup uses a PPS to make the kernel
clock very accurate, but also requires another (network-based) ntp peer
to provide the time-of-day.  The minimum entries you need in ntp.conf
for a configuration like this are:

  server 127.127.22.0 prefer
  fudge  127.127.22.0 stratum 0
  server <any network server> iburst prefer

Of particular importance is that the 'prefer' keyword is needed on the
pps (127.127.22.0) server and any one of the network servers.

For a pure GPS solution that doesn't require another network ntp server
to number the seconds, the 'gpsd' port knows how to talk to most gps
receivers via a serial connection.  That's about all I know about gpsd.

-- Ian




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1479846679.1889.8.camel>