From owner-freebsd-arm@freebsd.org Tue Nov 22 20:31:24 2016 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 58A10C50134 for ; Tue, 22 Nov 2016 20:31:24 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1b.ore.mailhop.org (outbound1b.ore.mailhop.org [54.200.247.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3B70CDA6 for ; Tue, 22 Nov 2016 20:31:23 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: a5845575-b0f2-11e6-94b7-cbe6054a74b1 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.78.92.27 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.78.92.27]) by outbound1.ore.mailhop.org (Halon) with ESMTPSA id a5845575-b0f2-11e6-94b7-cbe6054a74b1; Tue, 22 Nov 2016 20:31:29 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id uAMKVJar001885; Tue, 22 Nov 2016 13:31:20 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1479846679.1889.8.camel@freebsd.org> Subject: Re: PPS input on GPIO pin RPI2. From: Ian Lepore To: Peter =?ISO-8859-1?Q?Ankerst=E5l?= Cc: "freebsd-arm@FreeBSD.org" Date: Tue, 22 Nov 2016 13:31:19 -0700 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> <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> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Nov 2016 20:31:24 -0000 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 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