Using the rasclock RTC module with OSMC

Hi, i’m trying to set up my rasclock rtc module with OSMC via ssh, but i keep on getting this error:

hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --debug option to see the details of our search for an access method.

Is the rasclock compatible with OSMC? if so, how do i set it up and make it work? It worked fine on Raspbian, but it won’t work on OSMC.

I suspect there’s a device tree overlay you need to enable

You will also want to enable disable fake-hwclock:

sudo systemctl disable fake-hwclock


Try adding the following lines to /boot/config.txt


And /etc/tmpfiles.d/pcf2127.conf

w /sys/class/i2c-adapter/i2c-1/new_device - - - - pcf2127 0x51

And /etc/modules


As it turns out the NTP server in OSMC (RC2) doesn’t play well with RasClock RTC. I’m not sure why, perhaps it starts too early.
If no NTP server is needed it can be replaced with the lightweight systemd NTP client, which does seem to behave correctly:

osmc@osmc:~$ sudo systemctl stop ntp
osmc@osmc:~$ sudo systemctl disable ntp
osmc@osmc:~$ sudo timedatectl set-ntp true
osmc@osmc:~$ sudo timedatectl

And then as mentioned by @DBMandrake and @sam_nazarko

sudo systemctl disable fake-hwclock

1 Like

I followed the instructions from the both of you above and i seem to be able to use the hwclock command now, but upon reboot, both the system and hwclock resets to the default time and date of Wed Dec 31 1969 17:01:09 and this happens on each reboot. Any ideas on how to fix this?

If you’re adding an actual hardware clock you probably want to disable the fake-hwclock service:

sudo systemctl disable fake-hwclock

That may not be the only issue, but it definitely needs doing.

i disabled fake-hwclock and it’s still not behaving right… it still wants to reset both the hardware clock and the system clock back to December 1969 at 5pm when i reboot the pi. And yes, i am trying to add an actual hardware clock.

So I received my RasClock today and can confirm your findings. After setup I can do this:

osmc@osmc:~$ sudo hwclock
Wed 31 Dec 1969 04:00:18 PM PST -0.546601 seconds
osmc@osmc:~$ sudo hwclock -w
osmc@osmc:~$ sudo hwclock
Thu 16 Apr 2015 09:57:30 AM PDT -0.824338 seconds

But after reboot, hwclock returns 1969 again.

I then deleted /etc/tmpfiles.d/pcf2127.conf so the clock device isn’t setup at boot and then after boot I manually connected the device with

osmc@osmc:~$ su
root@osmc:/home/osmc# echo pcf2127 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
root@osmc:/home/osmc# hwclock
Thu 16 Apr 2015 10:01:26 AM PDT -0.406451 seconds

As you can see it does keep time, so the system must be writing the system time (1969) back to the RTC device during boot.

That’s where I got to for now…

EDIT: So we could put initialization in etc/rc.local but that kind of defies the purpose of having RTC so boot logs have accurate time as well.

i tried that line and i got this error:

echo: write error: Invalid argument

EDIT: nevermind, a reboot fixed that problem.

EDIT 2: ok, i entered the command above after rebooting and i was able to access the hwclock but upon another reboot, i was no longer able to access it, unless i entered that command again…

So I’ve fixed it by replacing NTPD with the lightweight systemd time client. I suspect NTPD ran before WiFi was fully up, couldn’t get new time but proceeded to write the still incorrect system time back to the RTC.

To do this, make sure /etc/tmpfiles.d/pcf2127.conf is installed as in my initial post, so RTC is enabled at boot. Then:

osmc@osmc:~$ sudo systemctl stop ntp
osmc@osmc:~$ sudo timedatectl set-ntp true
osmc@osmc:~$ sudo timedatectl

Another fix might be to force the NTP service to start after network is online, but I didn’t need the server part anyway.

Many Thanks! That fixed the problem on my end. How would i force NTP to start after network is online, if there is a network attached to the pi?

As the ntp service (/etc/init.d/ntp) has a $network requirement, in theory it should wait for the network to come up if you enable “wait for network” in the networking GUI.

This will cause Kodi to wait for the network before starting as well however.

I already use the “wait for network” option so I guess that’s not the reason why it doesn’t work with NTPD but it’s fine with systemd NTP. I don’t know what goes wrong then.

Bear in mind @CaptSmokey6; the systemd NTP client also updates the time from the network once it’s online and it adjusts your RTC so it’s always accurate, it just doesn’t provide a time server for the rest of your network.

Updated my first post with complete instructions.

@hyperchaotic Oh, ok. I have no use for a time server anyways because i have all my computers and devices set to, so i’m fine with that. Thanks again for your assistance!