RTC Real Time Clock

Hello, I need help accessing the I2C0 for the RTC, I don’t know how to. Please lecture me, I am new using Linux for accessing hardware. Please do be kind. Can this be done with Bash Scripts, thanks.

which connector and pins are you using for the I2C? i’m asking so that we are talking about the same i2c bus
can you run “i2cdetect -y -r bus_number” you should get 68 in the output, if things are working.
“i2cdetect -l” will list the available i2c bus.
your drawing above has no pull-ups on SCL and SDA, these are required.
I’d recommend using i2c-2 for your test, connector P9 pins 19 and 20,
why not use the RTC driver?
as for bash to access the part, it might be possible, but C would be much easier IMO

The drawing is what the vendor (beagleboard) provides for the product (beagleplay)

How do I use the RTC driver. Thanks in advance

See Real Time Clock (RTC) Drivers for Linux — The Linux Kernel documentation

On BeaglePlay:

debian@BeaglePlay:~$ ls /dev/rtc* -l
lrwxrwxrwx 1 root root      4 May 19 16:14 /dev/rtc -> rtc0
crw------- 1 root root 251, 0 May 19 16:14 /dev/rtc0
crw------- 1 root root 251, 1 May 19 16:14 /dev/rtc1

The important device tree entries in src/arm64/k3-am625-beagleplay.dts · v5.10.x-ti-unified · BeagleBoard.org / BeagleBoard-DeviceTrees · GitLab to make rtc0 the external RTC:

    aliases {
		rtc0 = &rtc;
		rtc1 = &wkup_rtc0;


	rtc: rtc@68 {
		compatible = "ti,bq32000";
		reg = <0x68>;
		interrupt-parent = <&main_gpio0>;
		interrupts = <2 IRQ_TYPE_EDGE_FALLING>;

The rtcwake and hwclock utilities might be of interest:

debian@BeaglePlay:~$ rtcwake --list-modes
freeze mem disk off no on disable show 
debian@BeaglePlay:~$ sudo hwclock --verbose
[sudo] password for debian: 
hwclock from util-linux 2.36.1
System Time: 1684720246.777410
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
ioctl(4, RTC_UIE_ON, 0): Invalid argument
Waiting in loop for time from /dev/rtc0 to change
...got clock tick
Time read from Hardware Clock: 2023/05/22 01:50:48
Hw clock time : 2023/05/22 01:50:48 = 1684720248 seconds since 1969
Time since last adjustment is 1684720248 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2023-05-22 01:50:47.262024+00:00

What did you want to do with the RTC?

1 Like

maybe connect the RTC to your beagleplay, then use i2cdetect to verify that it can be seen, the output needs to have 68, else i2cdetect is not seeing it. if i2cdetect finds it, then your ready to move on to what jkridner has posted.
i don’t have a beagleplay, but drivers and dts files should be the same as beaglebone black.

Sorry, my miss understanding. your wanting to access the RTC BQ32002 that is on beagleplay.
I thought you were adding a external RTC.
follow jkridner’s comments.
depending on if the driver is built as a module or built in, “lsmod | grep bq32” will show if the driver is loaded.
also, if the driver is built in, then i2cdetect will have “xx” where the 68 would be if there is no driver loaded.

Thanks this works, I am trying to add the RTC timestamp to readings of sensors.