Jump to content

Wrong RTC in Rock3A


Kalobok

Recommended Posts

Hi all!

 

There's a dedicated RTC chip in Rock3A (HYM8563TS), but unfortunately it doesn't work right with the standard Armbian image.

The chip is correctly identified, but the problem is with the RK809 PMIC, which also contains an RTC.

During boot RK809 is labeled as rtc0, and HYM8563TS as rtc1, and by default kernel uses rtc0 for hwclock manipulations.

Since RTC battery is connected to HYM8563TS, after power cycle RK809 is reset to 2017-08-05 09:00:00.

 

|  _ \ ___   ___| | __ |___ /  / \
| |_) / _ \ / __| |/ /   |_ \ / _ \
|  _ < (_) | (__|   <   ___) / ___ \
|_| \_\___/ \___|_|\_\ |____/_/   \_\

Welcome to Armbian 23.11.1 Bookworm with Linux 6.1.63-current-rockchip64

System load:   12%              Up time:       0 min
Memory usage:  6% of 1.93G      IP:
CPU temp:      41°C             Usage of /:    13% of 15G

Last login: Thu Nov 30 01:59:45 CET 2023 on ttyS2
root@rock-3a:~# timedatectl
               Local time: Thu 2023-11-30 02:02:23 CET
           Universal time: Thu 2023-11-30 01:02:23 UTC
                 RTC time: Sat 2017-08-05 09:00:58
                Time zone: Europe/Brussels (CET, +0100)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no
root@rock-3a:~# hwclock -r --rtc=/dev/rtc0
2017-08-05 11:01:08.022461+02:00
root@rock-3a:~# hwclock -r --rtc=/dev/rtc1
2023-12-17 18:25:06.420734+01:00
root@rock-3a:~# ls -l /dev/rtc*
lrwxrwxrwx 1 root root      4 Nov 30 02:01 /dev/rtc -> rtc0
crw------- 1 root root 252, 0 Nov 30 02:01 /dev/rtc0
crw------- 1 root root 252, 1 Nov 30 02:01 /dev/rtc1
root@rock-3a:~# dmesg | grep rtc
[    2.602457] rk808-rtc rk808-rtc: registered as rtc0
[    2.605220] rk808-rtc rk808-rtc: setting system clock to 2017-08-05T09:00:08 UTC (1501923608)
[    2.617968] rtc-hym8563 5-0051: registered as rtc1

 

There is a parameter in kernel configuration file which specifies RTC to use:

CONFIG_RTC_HCTOSYS=y
CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
CONFIG_RTC_SYSTOHC=y
CONFIG_RTC_SYSTOHC_DEVICE="rtc0"

 

Straightforward solution would be to compile kernel with above parameters set to rtc1.

It worked:

 ____            _      _____   _
|  _ \ ___   ___| | __ |___ /  / \
| |_) / _ \ / __| |/ /   |_ \ / _ \
|  _ < (_) | (__|   <   ___) / ___ \
|_| \_\___/ \___|_|\_\ |____/_/   \_\

Welcome to Armbian 23.11.1 Bookworm with Linux 6.1.66-current-rockchip64

System load:   28%              Up time:       0 min
Memory usage:  6% of 1.93G      IP:
CPU temp:      45°C             Usage of /:    16% of 15G

Last login: Thu Aug 31 19:25:12 CEST 2023 on ttyS2
root@rock-3a:~# timedatectl
               Local time: Sun 2023-12-17 18:27:43 CET
           Universal time: Sun 2023-12-17 17:27:43 UTC
                 RTC time: Sun 2023-12-17 17:27:42
                Time zone: Europe/Amsterdam (CET, +0100)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no
root@rock-3a:~# hwclock -r --rtc=/dev/rtc0
2017-08-05 11:01:01.778545+02:00
root@rock-3a:~# hwclock -r --rtc=/dev/rtc1
2023-12-17 18:28:07.062160+01:00
root@rock-3a:~# ls -l /dev/rtc*
lrwxrwxrwx 1 root root      4 Dec 17 18:27 /dev/rtc -> rtc1
crw------- 1 root root 252, 0 Dec 17 18:27 /dev/rtc0
crw------- 1 root root 252, 1 Dec 17 18:27 /dev/rtc1
root@rock-3a:~# dmesg | grep rtc
[    2.609825] rk808-rtc rk808-rtc: registered as rtc0
[    2.622573] rtc-hym8563 5-0051: registered as rtc1
[    2.623661] rtc-hym8563 5-0051: setting system clock to 2023-12-17T17:27:04 UTC (1702834024)

 

But maintaining custom kernel is not the ideal solution.

 

Could anybody suggest how to force the system to detect HYM8563TS as rtc0?

 

Link to comment
Share on other sites

Started with this. Somehow timedatectl and hwclock ignore /dev/rtc symlink and use rtc0.

For hwclock I can use command-line argument --rtc=/dev/rtc1, but didn't find how to change default settings for timedatectl.

Link to comment
Share on other sites

Looks like somebody fixed it in the latest release:

 ____            _      _____   _
|  _ \ ___   ___| | __ |___ /  / \
| |_) / _ \ / __| |/ /   |_ \ / _ \
|  _ < (_) | (__|   <   ___) / ___ \
|_| \_\___/ \___|_|\_\ |____/_/   \_\

Welcome to Armbian-unofficial 24.5.0-trunk Bookworm with Linux 6.6.21-current-rockchip64

No end-user support: built from trunk

System load:   2%               Up time:       1:25
Memory usage:  10% of 1.87G     IP:            
CPU temp:      52°C             Usage of /:    2% of 233G
RX today:      1.0 MiB

root@Rock3A:~# dmesg | grep rtc
[    1.013050] rtc-hym8563 5-0051: registered as rtc0
[    1.014152] rtc-hym8563 5-0051: setting system clock to 2024-03-08T14:02:28 UTC (1709906548)
[    2.552805] rk808-rtc rk808-rtc.4.auto: registered as rtc1

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines