rpi3 clock drift
Ian Lepore
ian at freebsd.org
Fri Nov 29 18:16:20 UTC 2019
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
More information about the freebsd-arm
mailing list