PPS input on GPIO pin RPI2.
Ian Lepore
ian at freebsd.org
Tue Nov 22 20:31:24 UTC 2016
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 at 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 at 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 at 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
More information about the freebsd-arm
mailing list