From owner-freebsd-arm@freebsd.org Fri Nov 29 18:16:20 2019 Return-Path: Delivered-To: freebsd-arm@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 B94271B7FFB for ; Fri, 29 Nov 2019 18:16:20 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound3d.ore.mailhop.org (outbound3d.ore.mailhop.org [54.186.57.195]) (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 47PjPc0SxHz49xP for ; Fri, 29 Nov 2019 18:16:19 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1575051379; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=by5hoNFoO+fD+Oif9cJ+2FePp9DSrcGgnC1vgQ3elZC5HSyqqJ7CRaSsOEZn9380Yc1q/Qpvl3fgc VTSlweW/Fq/4dSHcFNlFIeKGVTbSjs8i0BudP7RfUfjs9V++qFpFGOu/BXwosGBJiWdJbUj51oSWNG MtvvWfgp+sXZrL1HYKR94u5XZwW0HUoVc/MM6yG7SyFbYP1G/sC4nLzlAxk0qky5+44jgM40W7d5nz 0VjEq7crSuesvcjesn9YLgFkK6ULq3S5/UC8qT4+cBfA/y0ReI6bKVHDic+3+RVu6zlNpLvhArzSoG hwn2gxXctU77n6IZ6ZkIICVNIL1jK9Q== 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:to:from:subject:message-id:dkim-signature:from; bh=2l8o9x7lDN92rXdXoI4SftxwS8RW5Dc6cPUczrOlP7U=; b=rWOsvElwQpTLdW6r6P1uBxvZCB9Whjan4t4DFVgNtYA9ER/BComvABynDAaWwy0qHlyB15J5YQxVP YokEX0ERyC+Q0tmdZftLWSiOgBcj4a0ewj6YHWa0RRzjtmf7HCvXREOBoSCvvDPKjl4EWgS4T7WYx5 1PxNYku689ssKmBY+OlTbp78+df1bSPwfYk0IMc4YUI4CwnaebbGqX6AoQVYacsejMVGZfxBSufjBe oKVecQr3hx3POySIztU7CAwi74SeiMRuJOoeKVCKfavAUgTwHbg6Pu2t+17vNTzq8Sag7ZAxEC6TxH 4Xvfltzazq2HZ3MK044XFg52hu3hKBQ== ARC-Authentication-Results: i=1; outbound3.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:to:from:subject:message-id:from; bh=2l8o9x7lDN92rXdXoI4SftxwS8RW5Dc6cPUczrOlP7U=; b=nqYHuPkgdZjE8vSMWFj1Z0hD9ncnCQMa0ejsN3UcL409+wlEw4m5or1fqjygK2YxNywZv2KomVtAd UE/aNERmkBpGGSl75FECtgUsi16hZQ5oeqz8Nsyz7iDmKUYtfmtQGVHHkZsUpw6Z9xvh/SXxznR30j OJhGelO61tKSEsvDN66ET0OonR0YVumen9oMmj95m0aowx4Ew+0AespJjVCRpuUaL7VoGboh15cgfM LjwkMbCROO47u8rKy8livIuhdF646AUMSSfJA9KjqwKhgxdeiYFP41ePU/BIMTAzHAEqRF2miIbYIk uHL9oQZxF3Cz8bJ+U0Bh38fhLREDKjw== X-MHO-RoutePath: aGlwcGll X-MHO-User: 553be38b-12d4-11ea-b80c-052b4a66b6b2 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 outbound3.ore.mailhop.org (Halon) with ESMTPSA id 553be38b-12d4-11ea-b80c-052b4a66b6b2; Fri, 29 Nov 2019 18:16:17 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id xATIGFcL084995; Fri, 29 Nov 2019 11:16:15 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <731a9e57ba62d5a6ede74fdde3fd82543484813b.camel@freebsd.org> Subject: Re: rpi3 clock drift From: Ian Lepore To: James Shuriff , Ross Alexander , "freebsd-arm@freebsd.org" Date: Fri, 29 Nov 2019 11:16:15 -0700 In-Reply-To: References: <20191129052800.GA37113@server.rulingia.com> <65be6d3628a8d35084f7c98266582090f59b18be.camel@freebsd.org> 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: 47PjPc0SxHz49xP X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-1.80 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.89)[-0.892,0]; NEURAL_HAM_LONG(-0.90)[-0.903,0]; ASN(0.00)[asn:16509, ipnet:54.186.0.0/15, country:US] X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Nov 2019 18:16:20 -0000 On Fri, 2019-11-29 at 18:06 +0000, James Shuriff wrote: > Can you help me determine where the timecounter frequency is being > pulled from? I believe that 54 MHz value is being pulled from the FDT > I just don't know where specifically. My board is supposed to be 19.2 > MHz. I booted up FreeBSD's own RPI3 image and I got 19.2 MHz and > didn't have any drift issues. Only when I use the environment I built > from source do I get 54 MHz, as if an RPI 4 DTB somehow made it into > the build. > You can get a definitive look at the fdt data in use by decompiling it on the running system, like this: sysctl -b hw.fdt.dtb | dtc -I dtb -O dts >/tmp/active.dts That would help you confirm your theory by finding which node has the 54mhz value in it. What to do beyond that, I'm not sure. RPi fdt data always confuses me. I think these days it's loaded from the msdos partition by uboot, but I'm not sure of that. > I'm also interested in getting an RTC hat. I know how to build > support for it in the bootloader and OS but how do you tell FreeBSD > to start using it for system timing once it's connected? > > - James Shuriff > The only thing an RTC does is initially set the system time once at boot. (On systems that support suspend/resume, it also resets the kernel clock on resume from sleep/low-power modes.) There is no way to use an RTC as the system timecounter. To use an RTC to set the time intially at boot, you only need to load its driver via the loader.conf setting and enable the i2c device with an fdt overlay. The device driver registers itself as an RTC, and the kernel automatically sets the time from the registered RTC that has the best resolution. -- Ian