Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Nov 2019 22:36:07 +0000
From:      James Shuriff <james@opentech.cc>
To:        Peter Jeremy <peter@rulingia.com>
Cc:        Ian Lepore <ian@freebsd.org>, "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org>
Subject:   RE: rpi3 clock drift
Message-ID:  <MWHPR06MB313459626ADCE36F829ABDABAA460@MWHPR06MB3134.namprd06.prod.outlook.com>
In-Reply-To: <20191129220311.GD37113@server.rulingia.com>
References:  <MWHPR06MB3134EC22EC3148DA800B2B7DAA440@MWHPR06MB3134.namprd06.prod.outlook.com> <alpine.BSF.2.21.99999.352.1911272214050.28592@autopsy.pc.athabascau.ca> <20191129052800.GA37113@server.rulingia.com> <alpine.BSF.2.21.99999.352.1911282333250.90234@autopsy.pc.athabascau.ca> <65be6d3628a8d35084f7c98266582090f59b18be.camel@freebsd.org> <alpine.BSF.2.21.99999.352.1911291053140.17959@autopsy.pc.athabascau.ca> <MWHPR06MB313445553D73F019FEEAF50EAA460@MWHPR06MB3134.namprd06.prod.outlook.com> <731a9e57ba62d5a6ede74fdde3fd82543484813b.camel@freebsd.org> <MWHPR06MB3134455800AD75C949D86D8FAA460@MWHPR06MB3134.namprd06.prod.outlook.com> <MWHPR06MB3134E3913675771F14E3C4B3AA460@MWHPR06MB3134.namprd06.prod.outlook.com> <20191129220311.GD37113@server.rulingia.com>

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

I was looking at the generic_timer.c code and it probes for "arm,armv8-time=
r" or "arm,armv7-timer". I was thinking of trying to add clock-frequency di=
rectly into "timer". ARM MPCore Timecounter is generic_timer.c. That was my=
 next idea, to try copying over some of the binaries from FreeBSD's RPI3 im=
age one at a time to try identifying where the issue is.

My latest build is U-Boot from the git repo with the v2019.10 tag using rpi=
_3_defconfig with OF_EMBED=3Dn and OF_BOARD=3Dy the former telling U-Boot n=
ot to embed the FDT into the binary and the latter informs U-Boot that the =
FDT will be provided by the board at runtime (start.elf looks for " bcm%d-r=
pi-%s.dtb"). I get config.txt from /usr/ports/sysutils/rpi-firmware/files/c=
onfig_rpi3.txt. I build U-Boot with the Clang and ld.lld (which was no smal=
l effort!). The binary blobs I get from the Raspberry Pi repository. I buil=
d PSCI Monitor from its repo. I get the overlays from the output of my Free=
BSD build. I've attached the script I use to build the FAT partition, if yo=
u're curious.

- James Shuriff

-----Original Message-----
From: Peter Jeremy <peter@rulingia.com>
Sent: Friday, November 29, 2019 5:03 PM
To: James Shuriff <james@opentech.cc>
Cc: Ian Lepore <ian@freebsd.org>; freebsd-arm@freebsd.org
Subject: Re: rpi3 clock drift

On 2019-Nov-29 20:37:36 +0000, James Shuriff <james@opentech.cc> wrote:
>I dumped the FDT from the system I built from source and I cannot find
>any reference to 0x337F980 (54 MHz). I looked at the FreeBSD source
>file generic_timer.c and it looks like it's grabbing the frequency from
>FDT but I cannot figure out where it's getting the 54 MHz from. clk_osc
>in the FDT is still showing 0x124f800 (19.2 MHz) on the system with the
>bad clock.

I've been rummaging around on my (early) RPi2.  The timer code seems to be =
the same, even if the SoC is different (I have armv7, RPi3 is armv8).

In my FDT, I have:
        timer {

                compatible =3D "arm,armv7-timer";
                interrupt-parent =3D <0x3>;
                interrupts =3D <0x0 0x1 0x3 0x2>;
                always-on;
        };
There's no clock-frequency clause there and no (obvious) link to:
        clocks {
                compatible =3D "simple-bus";
                #address-cells =3D <0x1>;
                #size-cells =3D <0x0>;
                clock@3 {
                        compatible =3D "fixed-clock";
                        reg =3D <0x3>;
                        #clock-cells =3D <0x0>;
                        clock-output-names =3D "osc";
                        clock-frequency =3D <0x124f800>;
                        phandle =3D <0x4>;
                };
...
        };

The relevant dmesg should look like:
generic_timer0: <ARMv7 Generic Timer> irq 0,1,2,3 on ofwbus0 Timecounter "A=
RM MPCore Timecounter" frequency 19200000 Hz quality 1000 Event timer "ARM =
MPCore Eventtimer" frequency 19200000 Hz quality 1000

At least on my RPi2, I have:
Using DTB provided by EFI at 0x7ff8000.
and

FreeBSD/arm EFI loader, Revision 1.1
   Command line arguments: l
   EFI version: 2.70
   EFI Firmware: Das U-Boot (rev 8216.2304)
   Console: efi (0)
   Load Path: /\efi\boot\bootarm.efi

Are you building a 32-bit or 64-bit FreeBSD?
Where are you getting your boot code from?
Have you tried using the boot code from the FreeBSD RPi3 image with your ke=
rnel?

--
Peter Jeremy
________________________________
 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_MWHPR06MB313459626ADCE36F829ABDABAA460MWHPR06MB3134namp_
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
L2Jvb3QvZHRiL292ZXJsYXlzLwplbHNlCiBzZXQgQk9PVEZTPS9tbnQvYm9vdGZzLwoKIHNldCBN
QUtFT0JKRElSUFJFRklYPS91c3Ivb2JqCiBzZXQgU1JDRElSPSIvdXNyL3NyYy5oZWFkIgogc2V0
IEtFUk5DT05GPU9UQ0MKCiBzZXQgVUVGSV9MT0FERVJfUEFUSCA9ICRNQUtFT0JKRElSUFJFRklY
LyRTUkNESVIvYXJtNjQuYWFyY2g2NC9zdGF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heXMvCmVuZAoKIyBEVEIKbWtkaXIgLXAgJEJPT1RGUy9kdGIvYWxsd2lubmVy
ICRCT09URlMvZHRiL292ZXJsYXlzCmZvcmVhY2ggeCAoJERUQl9BV19GSUxFUykKCWNwICREVEJf
QVdfUEFUSC8keCAkQk9PVEZTL2R0Yi9hbGx3aW5uZXIvCmVuZApmb3JlYWNoIHggKCREVEJfT0xf
RklMRVMpCgljcCAkRFRCX09MX1BBVEgvJHggJEJPT1RGUy9kdGIvb3ZlcmxheXMvCmVuZAoKIyBF
RkkKIyBsb2FkZXJfbHVhLmVmaSBpcyBhIGhhcmQgbGluayB3aXRoIGxvYWRlci5lZmkKbWtkaXIg
LXAgJEJPT1RGUy9FRkkvQk9PVApjcCAkVUVGSV9MT0FERVJfUEFUSCAkQk9PVEZTL0VGSS9CT09U
L2Jvb3RhYTY0LmVmaQo=

--_002_MWHPR06MB313459626ADCE36F829ABDABAA460MWHPR06MB3134namp_--



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