Kernel does not use RTC

This forum is for topics dealing with problems with software specifically in the ARMv7h repo.

Kernel does not use RTC

Postby zebul666 » Sat Aug 25, 2018 6:52 pm

I have a PiFace RTC clock that I have setup on a rpi2.

But the kernel does not seem to use it to update the system clock.

It is only systemd-timesyncd that restores time from saved timestamp. And then later on sync the time with SNTP if I have a network available.

The idea of having a RTC is to have a correct time even if there is no network.

But this is not used at all.

How do I tell the kernel to use the RTC to update system clock at boot ? or only if there is no internet connection ?

the archlinux wiki is rather vague about this:$this->bbcode_second_pass_quote('', ' ')During kernel startup, at the point when the RTC driver is loaded, the system clock may be set from the hardware clock. Whether this occurs depends on the hardware platform, the version of the kernel and kernel build options. If this does occur, at this point in the boot sequence, the hardware clock time is assumed to be UTC and the value of /sys/class/rtc/rtcN/hctosys (N=0,1,2,..) will be set to 1.


here /sys/class/rtc/rtc0/hctosys is 0

only mention of rtc in the log is
$this->bbcode_second_pass_code('', 'kernel: rtc-ds1307 1-006f: registered as rtc0')
no time change after that except with systemd-timesyncd.
zebul666
 
Posts: 48
Joined: Fri Jul 10, 2015 4:55 pm

Re: Kernel does not use RTC

Postby mkfg » Sat Aug 25, 2018 7:08 pm

timesyncd also restores clock from /dev/rtc on boot, if it's available (as well as syncing time to/from it later), so make sure to have that available at the moment timesyncd starts and it should be fine.

If that ds1307 module finishes initializing after timesyncd starts (likely), adding a .service or .target that'd have DefaultDependencies=no, After=dev-rtc0.device (check systemctl --all for proper name here) and Before=systemd-timesyncd.service can be one way to do it.
Note that it might seem weird that kernel loads rtc after starting timesyncd and such, but remember that devices and drivers for them are supposed to be plugged in and out at any time, so it's actually pretty normal.
mkfg
 
Posts: 2
Joined: Thu Sep 21, 2017 4:33 pm


Return to ARMv7h

Who is online

Users browsing this forum: No registered users and 9 guests