1

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

I have edited /boot/config.txt to add

dtparam=i2c=on
dtoverlay=i2c-rtc,mcp7941x=0x6f

I have added i2c-dev and i2c:mcp7941x modules to /etc/modules-load.d/raspberrypi.conf

But the kernel does not seem to use it to update the system clock. I can see the rtc driver is loaded:

 kernel: rtc-ds1307 1-006f: registered as rtc0

and there is a /dev/rtc0 device. But the kernel does not update system clock with it.

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

The idea of having a RTC is to have correct time 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 ?

  • Enable RTC in Device Tree – Milliways Aug 25 '18 at 19:11
  • Could you be more specific ? – solsTiCe Aug 25 '18 at 20:53
1

Well, an ugly hack is to make a hwclock.service like this

[Unit]
Description=Synchronize system clock from RTC

[Service]
ExecStart=/usr/bin/hwclock --hctosys
Type=simple

[Install]
WantedBy=time-sync.target

And enable it with

sudo systemctl enable hwclock.service

It will step on systemd-timesyncd's toes when network is available but should do no harm.

In the hope of a better solution ?

Another way to do it, is to use an udev rule that trigger hwclock.

in /etc/udev/rules.d/i2c-rtc.rules

KERNEL=="rtc0", SUBSYSTEM=="rtc", SUBSYSTEMS=="i2c", TAG+="systemd", ENV{SYSTEMD_WANTS}="hwclock.service"

in /etc/systemd/system/hwclock.service

[Unit]
Description=Synchronize system clock from RTC

[Service]
ExecStart=/usr/bin/hwclock --hctosys --utc
Type=oneshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.