0

I have an embedded board (NanoPi R5C) with an RTC battery connector:

enter image description here

On the board it's marked obvious which one is positive and negative. Moreover, checking the documentation:

RTC backup current is 0.25μA TYP (VDD =3.0V, TA =25℃).

Connector P/N: Molex 53398-0271

I have attached a CR1616 battery onto this socket with correct polarity.

When checking startup log, RTC seems initializing, however with an incorrect date (2017):

$ dmesg | grep rtc
[    2.979031] rockchip-drm display-subsystem: [drm] Cannot find any crtc or sizes
[    2.979143] rockchip-drm display-subsystem: [drm] Cannot find any crtc or sizes
[    3.198765] rk808-rtc rk808-rtc: registered as rtc0
[    3.199273] rk808-rtc rk808-rtc: setting system clock to 2017-08-04T09:00:03 UTC (1501837203)
[    6.011447] rtc-hym8563 5-0051: rtc information is valid
[    6.018302] rtc-hym8563 5-0051: registered as rtc1

Timedatectl also reports incorrect RTC date:

$ timedatectl status
               Local time: Sun 2023-07-09 22:52:41 CEST
           Universal time: Sun 2023-07-09 20:52:41 UTC
                 RTC time: Fri 2017-08-04 09:07:44
                Time zone: Europe/**** (CEST, +0200)
System clock synchronized: no
              NTP service: n/a
          RTC in local TZ: no

Sometimes I saw "yes" for "System clock synchronized", however after toggling the power, the RTC loses it's value and resets to this 2017 date.

Voltage on this RTC connector is 2.96V.

What else could I check and fix?

Daniel
  • 339
  • 1
    It turned out it's a Linux issue. As "rtc-hym8563 5-0051" is registered as "rtc1" and Linux is using "rtc0" as default rtc. – Daniel Jul 10 '23 at 06:22

2 Answers2

2

"System clock synchronized" would mean the system clock (i.e. the "Universal time" line of timedatectl status output) is being synchronized to some outside time source. It might have no effect at all regarding the RTC.

(On PC hardware, the "System clock synchronized" seems to mean the kernel's "11-minute mode" is active, causing the RTC to be synchronized to the system clock, but this might not be true on a hardware architecture where the RTC is optional, such as this NanoPi.)

The RTC clock is separate from the system clock: you probably should run timedatectl set-local-rtc 0 or hwclock --systohc --utc to copy the system clock time (as UTC) to the RTC.

telcoM
  • 96,466
0

(Answer moved from question)

The main problem was that system was using rtc0 as default RTC which is not battery-backed up. I managed to get rtc for default with udev rules, however the system still works very strange:

# timedatectl 
               Local time: Mon 2023-07-10 00:04:13 CEST
           Universal time: Sun 2023-07-09 22:04:13 UTC
                 RTC time: Mon 2023-07-10 07:37:16
                Time zone: Europe/*** (CEST, +0200)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

As you can see, now RTC is OK (this is rtc1), but local time is only synced with date! So it seems local time is got its date from RTC (no internet access allowed in the router), but the time was not being set! It always starts from 00:00. Can I somehow enable the timesync FROM rtc as well?

Chris Davies
  • 116,213
  • 16
  • 160
  • 287