System not staying synced with hardware clock

I have a raspberry pi 4 with an added hardware clock that was working on raspbian. On Manjaro I’ve added the dtoverlay line to config.txt, and hwclock -r shows me the correct time, but if left off for a long time the system time no longer matches the hardware clock.

It looks like the system clock is saving the current time at shutdown and restoring that time on reboot, which is fine if just doing a quick reboot or if it can get a more accurate time from a server during bootup; but in my case I use my pi while traveling, which means long spells shut down and a lot of wifi portals that won’t give me internet access because they throw SSL security errors because my system date is too old.

Thus far I’ve manually run hwclock -s every time I boot up to get system time to match the hardware clock, but shouldn’t this happen automatically? It sounds like fake-hwclock is meant to do what I’m seeing, but its not installed on my system. Is Manjaro ARM also configured in some other way to deal with the usual lack of a hardware clock that I need to undo?

Sounds like you just need to install fake-hwclock and activate it.

1 Like

Ah, I too hadn’t realised that the package needed to be enabled. I take it that’s via systemctl?

Yeah. Seems its sudo systemctl enable --now fake-hwclock.service.

1 Like

I don’t think I made myself clear. My system is behaving as if I have fake-hwclock installed, but I don’t, and I don’t want it to behave this way. I have added a real hardware clock, and I don’t want my system to act like it has to compensate for the lack of one anymore.

I guess my question is; before fake-hwclock was added to the distro, how was manjaro arm configured to compensate for not having a real hardware clock?

After doing some more research it sounds like this might be an old manjaro/arch arm problem having to do with the RTC module not in the kernel (loading with dtparam gets it working, but not early enough in the boot process to act like a traditional RTC).

I don’t want to keep building my own custom kernel, so instead I followed some instructions from this post by fdc with some changes for my setup:

in /boot/config.txt insert

dtoverlay=i2c-rtc,pcf8523

in /etc/mkinitcpio.conf insert

MODULES=(i2c-bcm2835 rtc_pcf8523)
BINARIES=(hwclock)
FILES=(/etc/udev/rules.d/50-rtc-hwclock.rules)

create /etc/udev/rules.d/50-rtc-hwclock.rules

KERNEL==“rtc0”, RUN+="/bin/hwclock -s"

execute

mkinitcpio -p linux-rpi4

reboot

I can change these modules if it will help starting the next kernel build:

CONFIG_I2C_BCM2835=m
CONFIG_RTC_DRV_PCF8523=m

To this:

CONFIG_I2C_BCM2835=y
CONFIG_RTC_DRV_PCF8523=y

That would be great! I think the three most common add-on RTC clocks are based on the following three chips, so building with them as well would probably help the most people:

PCF8523
DS1307
DS3231