From owner-freebsd-usb@freebsd.org Mon Aug 5 14:42:38 2019 Return-Path: Delivered-To: freebsd-usb@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78890C53EF for ; Mon, 5 Aug 2019 14:42:38 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 462L8Z2dY1z3Gf5 for ; Mon, 5 Aug 2019 14:42:38 +0000 (UTC) (envelope-from ian@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 58641C53EB; Mon, 5 Aug 2019 14:42:38 +0000 (UTC) Delivered-To: usb@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5813BC53E9 for ; Mon, 5 Aug 2019 14:42:38 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound2m.ore.mailhop.org (outbound2m.ore.mailhop.org [54.149.155.156]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 462L8Y6nvkz3Gf3 for ; Mon, 5 Aug 2019 14:42:37 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1565016155; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=SR/2jEPaC8rnwFjD76KGUO7Zuc6fhwsugZRLy8tNNzLjQnSR67Jn1ezZFerB7Ckxmczi3BRdafvpT EiZP0/8DF8nVz8kM4Hul3BMX9Xqh/2geenBi7N7/8cSSdlMhQoaQh1xXMfst9qcNyyK3z/Bj9LqLcl uetPMFIiz3GtRmljdrnAL896q1Y8fBoQB/ExSho6Iyut670sU81T7A/mS51XdqpoNsQxCTC20MgPvf yl+Z+1WDlRQl4OY0IyEagqkUXsMiFqfqs1X+5lBXec2uKxS9+Ptdb9ISlo1yn+2WHBtdWMrHHisNdV c49ENDvl6Q/CyK5eh92AzJleNu+Vw2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:dkim-signature:from; bh=c71SP4R8yGAivSaYiL6Q5t3pdnaILEc7M5cjzdREcNQ=; b=MdW0DSkpqZjkz7tVJHb7Fx7AB11/LNaLL1oJKiIfC0eK2s3UZvaPFAwhZbkMqRPLP1eQSSM/LPoOX JF7iYQiq3WafWNk5CCXrqoRtWFLtOwRFp00FuHdYmTbIEPCrjvh2TSG5++anUNlUvMrEJPuz6n6RoK p5pUInGSdBQsxkA7cHFOrbmY85DIF0slVk+o3roo39eTo2IlGirc4V8rGJygKAxnyiFML10IJyM4bn TZLdTbQpD6/5uWg/PpfOEfbaPJjm3veBboZGBN8fj0b12pg3Th9U9T/aHhzyPbKSrW7iWEJ0AnHiXf lPdw8h08bDZvKEYa/hmNV0YONUBPmsQ== ARC-Authentication-Results: i=1; outbound4.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:from; bh=c71SP4R8yGAivSaYiL6Q5t3pdnaILEc7M5cjzdREcNQ=; b=mLEGneShySupY5Oi0rhwxiD/moMkS6wIFvJqtuhlrdvI01vpiWk6l8Ge8ke2F4VmkF/wE35DLiaBw IxFKXKZZRA1zlP/sP/NYHQBxHErvwYLgwPVtw2G3DXwy5Y1oA/hFb2xVb4hPLRpCc3pyRohKAYVRVz SXZVeUxjYwkc1KnPLc2nUGNxBVuxTdBbXjXjYNbEP/7xZcqkzQgtUcDtCIhFzg+fK1FPf9BvIPKrjn fkBbeeJuyVdFzaflaZh6TEEZ3wyzfeVAUAB9BMf+tLL9ikJrDpufvvu32AD3YZ+KghufCI4dNsopJJ UNypwvpn5spMOGcE+SQI8UzelrWYXPA== X-MHO-RoutePath: aGlwcGll X-MHO-User: 41d5c614-b78f-11e9-85ec-13b9aae3a1d2 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound4.ore.mailhop.org (Halon) with ESMTPSA id 41d5c614-b78f-11e9-85ec-13b9aae3a1d2; Mon, 05 Aug 2019 14:42:34 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id x75EgVHu017258; Mon, 5 Aug 2019 08:42:32 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: Subject: Re: Is it a good idea to use a usb-serial adapter for PPS input? Yes, it is. From: Ian Lepore To: "O'Connor, Daniel" Cc: "usb@freebsd.org" , "freebsd-arm@FreeBSD.org" Date: Mon, 05 Aug 2019 08:42:31 -0600 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 462L8Y6nvkz3Gf3 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-1.56 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.81)[-0.807,0]; NEURAL_HAM_SHORT(-0.75)[-0.754,0]; ASN(0.00)[asn:16509, ipnet:54.148.0.0/15, country:US] X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Aug 2019 14:42:38 -0000 On Mon, 2019-08-05 at 15:28 +0930, O'Connor, Daniel wrote: > Hi Ian, > > Firstly, this is a very cool test - thank you for running it :) > > > On 3 Aug 2019, at 06:46, Ian Lepore wrote: > > PPS(2) is an FTDI 232R, a USB 1.1 serial adapter, connected to a port > > on a USB 2.0 hub that's connected to a USB 2.0 host port on the > > Wandboard. > > > > PPS(3) is an FTDI 4232H, a USB 2.0 serial adapter, connected to a port > > on the same USB hub as PPS(2). > > > > > Most people are not worried about their kernel clock being 200 > > microseconds off from UTC, even if they're using the PPS signal from a > > GPS receiver. So I think most people should feel completely at ease > > using a USB serial adapter as the input device for a PPS signal. > > Does the USB clock derive from the 10MHz Rb clock? If so that would mean you would see a lot less jitter than a 'normal' user where the USB clock is not locked too GPS. > No, usb is derived from the same 24mhz crystal that clocks the cpus. I think usb and its need for clocks at 48 and 480mhz is why so many small arm systems use a 24mhz main clock. > Do you have a more detailed write up of things like the NTP configuration file? I think I could replicate your test here although I have a Beaglebone Black, not a Wanboard so I will need to check if it can take an external clock. (We have GPS modules & Rb oscillators at work to create reference clock for bi-static meteor applications). > The same setup should be possible on a BBB. There is a TCLKIN pin mentioned in the manual. Some searching on the web yields a few clues that it might be possible to mux that to a pin on the P9 header [1]. There is already a dmtpps capture driver for TI, but I'm afraid it may have bitrotted over the past couple years. Also, even when it last worked, it just barely worked, because the reduction of kernel timecounters from 10 to 2 timehands causes the PPS capture to almost always get lost on single-core processors which are in cpu_idle() at the time the hardclock interrupt happens. (But that's fixable by just increasing the number of timehands, I think at least 4 are required.) So all in all, it's doable, but it'll take a bit of work. I can help with the driver stuff. The ntp config is pretty simple, it uses instances of the "atom" clock, which is a bare-PPS refclock which needs to be paired with any network peer to operate. The network peer is used to obtain the initial time of day, then the PPS signal is used to steer phase. The network peer must be marked 'prefer' for some reason, it's just an ntp rule. In my test setup I forced ntp to steer to the "perfect" pps signal by marking all the others as "noselect", otherwise any of the atom clocks would be eligible to be the system peer. server iburst prefer server 127.127.22.0 minpoll 4 maxpoll 4 fudge 127.127.22.0 stratum 0 refid gpt server 127.127.22.1 minpoll 4 maxpoll 4 noselect fudge 127.127.22.1 stratum 0 refid gpio server 127.127.22.2 minpoll 4 maxpoll 4 noselect fudge 127.127.22.2 stratum 0 refid usb1 server 127.127.22.3 minpoll 4 maxpoll 4 noselect fudge 127.127.22.3 stratum 0 refid usb2 [1] http://e2e.ti.com/support/processors/f/791/t/406121?AM335x-TCLKIN-on-Linux-3-19 -- Ian