[time-nuts] x86 CPU Timekeeping and clock generation

Trent Piepho tpiepho at gmail.com
Wed Jan 6 23:36:28 UTC 2021


On Wed, Jan 6, 2021 at 6:26 AM Tom Holmes <tholmes at woh.rr.com> wrote:
>
> Am I missing something or maybe I don't understand
> the situation , but I am under the impression that
> the RTC has it's own battery and crystal unrelated
> to the processor clock. Seems like in that case,
> the 24 MHz won't have any effect on the
> timekeeping drift.

It was like that, but the days of external RTC chips, e.g. from
Dallas, are largely over.  PC now have it integrated into the chipset.
Though it still has a power source and 32.768kHz xtal of its own.

In the embedded SoC world of phones, Raspberry PIs, and the OP's
Tinkerboard, there would virtually always be an RTC available in the
SoC with the CPU, or in the PMIC, or in both.  This would usually have
its own 32.768kHz xtal, but often there is an option to reduce the BoM
and use an internal RC oscillator instead of an external xtal or clock
signal, at greatly reduced accuracy.

The 32k xtal isn't for timekeeping accuracy, but for power savings.
In the lowest power modes the main PLLs will be shut down.  Certain
parts of the SoC will still be able to run using the 32kHz clock
domain and a low power output from the PMIC.

Linux doesn't use the RTC as the system clock.  During boot, the
kernel will usually set the system time from the RTC, and then the RTC
doesn't get used much, if at all.  There is a mode where the system
time is periodically copied back into the RTC, which can be enabled
with NTP.  And software like chrony has the ability to manage the RTC
and keep it in sync more intelligently, though I don't think any
distro uses this by default.

There are a number of sources that Linux can use as the system clock.
An on x86 system, it would usually be tsc, hpet, and acpi_pm.  On an
ARM board, arch_sys_counter.  The kernel subsystems for RTCs and for
clocksources are totally separate and the RTC, e.g. rtc-cmos, isn't a
clocksource.

Using adjtimex, it's possible to see what the current kernel
parameters are for clock adjustment.  The frequency adjustment would
need to be zero.




More information about the Time-nuts_lists.febo.com mailing list