Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Nov 2019 08:33:13 +0000
From:      James Shuriff <james@opentech.cc>
To:        Per Hedeland <per@hedeland.org>, Ian Lepore <ian@freebsd.org>
Cc:        "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org>
Subject:   RE: rpi3 clock drift
Message-ID:  <MWHPR06MB3134F4C5A908D5123AFC23F0AA440@MWHPR06MB3134.namprd06.prod.outlook.com>
In-Reply-To: <925e99c9-d723-0209-5533-edf8cb7cc6c1@hedeland.org>
References:  <MWHPR06MB3134CD05551D36CC3B45D368AA450@MWHPR06MB3134.namprd06.prod.outlook.com> <c5942861c2aa0929239e59a000ce76407f4fd191.camel@freebsd.org> <MWHPR06MB31341D8CB3BBF98153B55A74AA450@MWHPR06MB3134.namprd06.prod.outlook.com> <486c0bc46deeefb8338f50fe6dfdf7951786e56c.camel@freebsd.org> <A9CDA147-01A1-4A5B-8270-9F986847EA64@kronometrix.org> <925e99c9-d723-0209-5533-edf8cb7cc6c1@hedeland.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--_002_MWHPR06MB3134F4C5A908D5123AFC23F0AA440MWHPR06MB3134namp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I've read that the Pi 4 may have a 54 MHz oscillator and anything prior to =
that would have 19.2 MHz, which agrees with what everyone on this thread is=
 contributing. That makes me think I have a bad FDT. I looked at generic_ti=
mer.c, which creates the ARM MPCore Timecounter and I think it's getting th=
e frequency itself from FDT. Do you know where in particular it's getting t=
his frequency from?

The RPI3 build provided by FreeBSD uses an overlay called "pwm". It grabs i=
t from the Raspberry Pi binary blob repo, in addition to "pi3-disable-bt" a=
nd "mmc". I decompiled it and took a look at the source but there's no refe=
rence to a 54 MHz clock. There is an "assigned-clock-rates =3D <0x5f5e100>;=
". I built my Raspberry Pi 3 B as close to how the FreeBSD image was set up=
 as possible. I build everything from source but I grabbed my config.txt fi=
le from /usr/ports/sysutils/rpi-firmware/files/config_rpi3.txt. You can see=
 the attached file for details on how I set up the FAT partition. I had sta=
rted adding support for the I2C RTC because I was hoping to use that as the=
 timecounter.

Here is config.txt, straight from sysutils/rpi-firmware:

arm_control=3D0x200
dtparam=3Daudio=3Don,i2c_arm=3Don,spi=3Don
dtoverlay=3Dmmc
dtoverlay=3Dpwm
dtoverlay=3Dpi3-disable-bt
device_tree_address=3D0x4000
kernel=3Du-boot.bin

Aside from the VideoCore elfs, the overlays referenced in config.txt, bcm27=
10-rpi-3-b.dtb, and the PSCI Monitor I build everything from source and cop=
y the remaining DTBs from the FreeBSD build. I also configure U-Boot with O=
F_EMBED=3Dn and OF_BOARD=3Dy. OF_EMBED=3Dn tells U-Boot not to embed a Devi=
ce Tree into the image and OF_BOARD=3Dy tells U-Boot to grab the Device Tre=
e from the board itself (if supported). I don't know enough about Device Tr=
ees to determine where it's actually getting FDT from or where the definiti=
on for the clock is.

- James Shuriff

-----Original Message-----
From: owner-freebsd-arm@freebsd.org <owner-freebsd-arm@freebsd.org> On Beha=
lf Of Per Hedeland
Sent: Tuesday, November 26, 2019 7:18 PM
To: freebsd-arm@freebsd.org
Subject: Re: rpi3 clock drift

On 2019-11-27 00:17, Stefan Parvu wrote:
>
>>
>> Can someone else with an rpi3 (which keeps good time) confirm that
>> that's the usual number?
>
>
> this is slightly different model: rpi3+ . I think it does use a different=
 SOC than rpi3.
>
> krmx@k1:~ % sysctl kern.timecounter
> kern.timecounter.fast_gettime: 1
> kern.timecounter.tick: 1
> kern.timecounter.choice: ARM MPCore Timecounter(1000) dummy(-1000000)
> kern.timecounter.hardware: ARM MPCore Timecounter
> kern.timecounter.alloweddeviation: 5
> kern.timecounter.stepwarnings: 0
> kern.timecounter.tc.ARM MPCore Timecounter.quality: 1000
> kern.timecounter.tc.ARM MPCore Timecounter.frequency: 19200000
> kern.timecounter.tc.ARM MPCore Timecounter.counter: 3645432288
> kern.timecounter.tc.ARM MPCore Timecounter.mask: 4294967295

The same on what is a 3B w/o '+' AFAIR, keeping very good time:

pi3 2> sysctl kern.timecounter
kern.timecounter.fast_gettime: 1
kern.timecounter.tick: 1
kern.timecounter.choice: ARM MPCore Timecounter(1000) dummy(-1000000)
kern.timecounter.hardware: ARM MPCore Timecounter
kern.timecounter.alloweddeviation: 5
kern.timecounter.stepwarnings: 0
kern.timecounter.tc.ARM MPCore Timecounter.quality: 1000 kern.timecounter.t=
c.ARM MPCore Timecounter.frequency: 19200000 kern.timecounter.tc.ARM MPCore=
 Timecounter.counter: 27058350 kern.timecounter.tc.ARM MPCore Timecounter.m=
ask: 4294967295

and

pi3 3> cat /var/db/ntp/ntpd.drift
-5.333

pi3 4> uname -a
FreeBSD pi3.hedeland.org 12.0-STABLE FreeBSD 12.0-STABLE r345358 GENERIC  a=
rm64

--Per Hedeland
_______________________________________________
freebsd-arm@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-arm
To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org"
________________________________
 DISCLAIMER: This message and any attachments are intended solely for the u=
se of the recipient and may contain confidential information. If you have r=
eceived this message in error please delete it and promptly notify the send=
er, James Shuriff (james@opentech.cc<mailto:james@opentech.cc>).

--_002_MWHPR06MB3134F4C5A908D5123AFC23F0AA440MWHPR06MB3134namp_
Content-Type: text/plain; name="sdboot.txt"
Content-Description: sdboot.txt
Content-Disposition: attachment; filename="sdboot.txt"; size=2294;
	creation-date="Wed, 27 Nov 2019 08:24:50 GMT";
	modification-date="Wed, 27 Nov 2019 08:24:50 GMT"
Content-Transfer-Encoding: base64

Iy9iaW4vdGNzaAoKaWYgKGB1bmFtZSAtbWAgPT0gYXJtNjQpIHRoZW4KIHNldCBCT09URlM9L2Jv
b3QvZmlybXdhcmUvCgogc2V0IFVFRklfTE9BREVSX1BBVEggPSAvYm9vdC9sb2FkZXJfbHVhLmVm
aQogc2V0IERUQl9BV19QQVRIPS9ib290L2R0Yi9hbGx3aW5uZXIvCiBzZXQgRFRCX09MX1BBVEg9
L2Jvb3QvZHRiL292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Q0lfTU9O
X1BBVEggJFVCT09UX0JJTl9QQVRIICRCT09URlMKY3AgJEZJUk1XQVJFX0NPTkZJR19QQVRIICRC
T09URlMvY29uZmlnLnR4dAoKIyAvb3ZlcmxheXMKbWtkaXIgLXAgJEJPT1RGUy9vdmVybGF5cwpm
b3JlYWNoIHggKCRGSVJNV0FSRV9PTF9GSUxFUykKCWNwICRGSVJNV0FSRV9PTF9QQVRILyR4ICRC
T09URlMvb3ZlcmxheXMvCmVuZAoKIyBEVEIKbWtkaXIgLXAgJEJPT1RGUy9kdGIvYWxsd2lubmVy
ICRCT09URlMvZHRiL292ZXJsYXlzCmZvcmVhY2ggeCAoJERUQl9BV19GSUxFUykKCWNwICREVEJf
QVdfUEFUSC8keCAkQk9PVEZTL2R0Yi9hbGx3aW5uZXIvCmVuZApmb3JlYWNoIHggKCREVEJfT0xf
RklMRVMpCgljcCAkRFRCX09MX1BBVEgvJHggJEJPT1RGUy9kdGIvb3ZlcmxheXMvCmVuZAoKIyBF
RkkKIyBsb2FkZXJfbHVhLmVmaSBpcyBhIGhhcmQgbGluayB3aXRoIGxvYWRlci5lZmkKbWtkaXIg
LXAgJEJPT1RGUy9FRkkvQk9PVApjcCAkVUVGSV9MT0FERVJfUEFUSCAkQk9PVEZTL0VGSS9CT09U
L2Jvb3RhYTY0LmVmaQo=

--_002_MWHPR06MB3134F4C5A908D5123AFC23F0AA440MWHPR06MB3134namp_--



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