2

I have configured Chrony with rtcsync flag, which SHOULD "Enable kernel synchronization of the hardware real-time clock (RTC)", but that is not the case.

Chrony sets the system time correctly with ntp, but the RTC is untouched, and i can't seem to find out why that is. My guess is that the kernel doesn't recognize Chrony's request to sync the RTC, but that is just a guess.

Versions
Kernel: 4.19
Chrony: 3.5

UPDATE:

It appears that the external RTC is registered after the kernel tries to access it and this prevents syncing the RTC with the NTP synced system time. from dmesg:

...
[    6.317060] hctosys: unable to open rtc device (rtc)
...
[   14.303503] rtc-ds1307 9-0068: registered as rtc0
...

I've done a temporary workaround by adding a cronjob that updates the hwclock every 10 minutes.

Varyag
  • 676
  • 12
  • 29
  • Following your update, you probably want to backport commit f9b2a4d6a5f1 ("rtc: class: support hctosys from modular RTC drivers") or compile the ds1307 driver statically in the kernel – Alexandre Belloni Jul 10 '20 at 22:32

1 Answers1

0

To get rtcsync working, you have to set the RTC_SYSTOHC and RTC_SYSTOHC_DEVICE kernel option properly as this simply asks the kernel to sync the system time to the RTC. It does so approximately every 11 minutes.

However, a better way of doing that is to use rtcfile (and rtcdevice) in that case, chrony will handle the RTC. It will even compute the RTC drift that could then be corrected if the RTC supports a trimming mechanism.

Alexandre Belloni
  • 2,244
  • 13
  • 12
  • I've added these lines to ´/etc/chrony.conf´: ´rtcfile /etc/rtc´ and ´rtcdevice /dev/rtc0´, but it still only updates the system time and not the RTC. Do i need something more? The logs show nothing else than it's adjusting system clock – Varyag Jul 08 '20 at 09:46
  • I've also tried to set the options you've mentioned. `RTC_SYSTOHC=y` and `RTC_SYSTOHC_DEVICE="rtc0"` but it still doesn't seem to update the hwclock – Varyag Jul 09 '20 at 08:12