RockPi S how to configure RTC clock

I am using DS3231 as RTC for rockpi s.
Enabled rk3308-i2c1, i2c1-hym8563 in overlay.
mraa-i2c detect 01 confirms that rtc clock on i2c is detected.
Also able to read the rtc date time using the DS3231 library.

unable to sync the RTC time using hwclock.

hwclock --debug returns the following error

hwclock from util-linux 2.31.1
System Time: 1517156664.248024
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.

hwclock --rtc /dev/i2c-1 gives the following error

hwclock: ioctl(RTC_RD_TIME) to /dev/i2c-1 to read the time failed: Inappropriate ioctl for device

Try this (last comment) :


The module to load is ds1307

This option did not work.Can someone please provide the instructions to setup RTC DS3231 on rockpi S

root@rockpis:/home/rock# dmesg | grep rtc

[ 1.339207] rtc -hym8563 1-0051: could not init device, -6

[ 1.573347] hctosys: unable to open rtc device ( rtc 0)

apt install i2c-tools
armbian-config: activate I2C-0
i2cdetect -y 0
(modprobe) rtc-ds1307 ==> /etc/modules

root@rockpi # more /etc/modules
g_serial
rtc-ds1307

in /etc/rc.local:

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
hwclock -s

Once correct you can write the system date and time to the RTC module using :

sudo hwclock -w

You should be able to read the date and time back from the RTC using :

sudo date; hwclock -r

compare hwclock

sudo hwclock -c

Updating time via ntp from ptbtime3.pt.de

ntpdate -q ptbtime3.ptb.de

writing actual time to hwclock…

hwclock -w

reading actual time from hwclock…

date; hwclock -r

Still not working. Here is more information from dmesg

rock@rockpis:~$ ls /dev/i2c-0
/dev/i2c-0
rock@rockpis:~$ dmesg | grep rtc0
[ 1.599355] hctosys: unable to open rtc device (rtc0)
rock@rockpis:~$ dmesg | grep ds13*
[ 19.096975] i2c i2c-0: new_device: Instantiated device ds1307 at 0x68
rock@rockpis:~$ hwclock --debug
hwclock from util-linux 2.31.1
System Time: 1625548836.440004
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.
rock@rockpis:~$ timedatectl
Local time: Tue 2021-07-06 10:51:12 IST
Universal time: Tue 2021-07-06 05:21:12 UTC
RTC time: n/a
Time zone: Asia/Kolkata (IST, +0530)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no

root@rockpis:/home/rock# i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – -- – -- – -- – -- – -- – -- –
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – -- – -- – -- – --
30: – -- – -- – -- – -- – -- – -- – -- – --
40: – -- – -- – -- – -- – -- – -- – -- – --
50: – -- – -- – -- – 57 – -- – -- – -- – --
60: – -- – -- – -- – -- 68 – -- – -- – -- –
70: – -- – -- – -- – --

I am using DS3231 RTC.

Please use I2C1, PIN 3 & 5 on 26P header1. How do you connect DS3231?

@jack thanks for the followup. I am still not able to get it working. hwclock throws the same error.

I had connected to pin 23(SDA) & 24 (SCL) as per the instructions given today to work with i2C-0.
Now I have gone back to i2c-1

Here are my pin connections:
GND - pin 6
VCC - pin 4
SDA - pin 3
SCL - pin 5

I have enabled i2c-1 in overlays i2c1-hym8563. Is this required in overlays or should I give rk3308-i2c1. Still does not seem to work.

I can see that i2c-1 is detected.

root@rockpis:/home/rock# 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: – -- – -- – -- – 57 – -- – -- – -- – --
60: – -- – -- – -- – -- 68 – -- – -- – -- –
70: – -- – -- – -- – --

(modproble) rtc-ds1307 ==> /etc/modules is giving error.
root@rockpis:/home/rock# modprobe rtc-ds1307 ==> /etc/modules

modprobe: FATAL: Module rtc-ds1307 not found in directory /lib/modules/4.4.143-61-rockchip-g1f77a85486f7

Not sure if this is the issue.

So have added them manually in /etc/modules
root@rockpis:/home/rock# more /etc/modules

g_serial
rtc-ds1307

in /etc/rc.local:
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
#hwclock -s

hwclock -s is giving error so commented out.

root@rockpis:/home/rock# dmesg | grep rtc0

[ 1.617044] hctosys: unable to open rtc device ( rtc0 )

root@rockpis:/home/rock# dmesg | grep ds13*

[ 18.944222] i2c i2c-1: new_device: Instantiated device ds13 07 at 0x68

Has it got to do with clocksource:

dmesg | grep clocksource

[ 0.000000] clocksource : arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns

[ 0.083648] clocksource : jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns

[ 0.162298] clocksource : Switched to clocksource arch_sys_counter

Any update please on this issue?