Adding Real Time Clock to Rpi4 with Rocky 9.3

My Rpi4 / Rock 9.3 boots up with the date set to Aug 21, 2023. It doesn’t take long for chronyd to set the clock but in the meantime logs are using the wrong date.

I bought an Adafruit PCF8523 RTC that just pops on the GPIO bus. Unfortunately, all of the docs/tutorials I can find for this clock assume that the Pi4 is running raspian and to use raspi-config to enable the i2c bus.

How would I do this with Rocky 9?

Thanks!
Jeff Ross

I haven’t tested this but you can create config.txt if doesn’t exists already, more info here:

https://forums.raspberrypi.com/viewtopic.php?f=117&t=208748

and

Thanks for the links!

I guess the trick is going to be figuring out what values the 6 pins used by the RTC module need to be set.

So far I haven’t seen any low level info covering this. What I am finding is “import these python3 modules and set the time”.

What I see in reality is that those python scripts don’t even see the RTC module on the GPIO bus so that’s why I asked about enabling that bus as raspi-config would do. I do have a 3B+ still on Ubuntu so maybe I can take a peek at that and glean some information.

Thanks again!

Jeff

No problem, keep us posted!

I found this on reddit:

https://www.reddit.com/r/RockyLinux/comments/11ys7bf/how_to_enable_i2c_on_rpi4/

jross@rpi4:~$ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

So at least I can see the i2c now!

Jeff

Unfortunately, that’s all the farther I’ve gotten. The rpm mentioned in the reddit thread adds sections to /boot/config.txt like this:

# Start managed by rpi4-i2c-userspace rpm
dtparam=i2c_arm=on
i2c-bcm2708
# End managed by rpi4-i2c-userspace rpm

# Start managed by rpi4-i2c-userspace-i2c1 rpm
dtparam=i2c1=on
# End managed by rpi4-i2c-userspace-i2c1 rpm

Rebooting to enable that does nothing that I can see. i2cdetect -y 1 still shows a 68 instead of a UU to show that the clock is working.

hwclock finds no clock:

jross@rpi4:~$ sudo hwclock --verbose -r
hwclock from util-linux 2.37.4
System Time: 1705006319.086912
Trying to open: /dev/rtc0
Trying to open: /dev/rtc
Trying to open: /dev/misc/rtc
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.

So I’m stopped for now unless someone has a clue by four to help me out :wink:

Jeff

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.