Skip to content

RTC

On-board RTC information for Rockchip platforms is as follows:

Board SoC Platform On-board RTC
K1 RK3568 Rockchip Y
K1B RK3568 Rockchip N
K3 RK3562 Rockchip Y
K7 / K7C RK3576 Rockchip Y
K8 RK3588 Rockchip Y

On-board RTC information for Allwinner platforms is as follows:

Board SoC Platform On-board RTC
K2B V1 H618 Allwinner N
K2B V2 H618 Allwinner Y
K2C H618 Allwinner Y
K4B T113 Allwinner Y
K5C A133 Allwinner Y

On-board RTC

The on-board RTC is a real-time clock module integrated onto the motherboard (or embedded baseboard). When the motherboard power is off, the RTC is powered by a coin cell battery to ensure the motherboard's system time continues to run correctly.

Note

The motherboard interface is marked with an RTC silkscreen. The RTC battery interface is typically used to connect a coin cell battery, providing power to the on-board RTC module when the motherboard is powered off.

  • Hardware Installation

K1 Installation Diagram:

image-20251110115114912

External RTC

If the motherboard does not have an on-board RTC, a real-time clock module can be added via an external connection.

1. Identify the I2C pin positions on the expansion header and the power domain of the module. The external RTC module used (hym8563) has a power domain of 3.3V.

image-20251112142527332

2. Check if the module's SDA and SCL pins have pull-up resistors. If not, external pull-up resistors need to be added.

3. Install the module.

Warning

Do not install or remove the module while the motherboard is powered on.

image-20251112142713347

DTS Node Configuration

Rockchip

DTS configuration for the hym8563 module on Rockchip platform:

&i2c2 {
    status = "okay";

    hym8563: hym8563@51 {
        compatible = "haoyu,hym8563";
        reg = <0x51>;
        pinctrl-names = "default";
        pinctrl-0 = <&hym8563_int>;
        interrupt-parent = <&gpio0>;
        interrupts = <RK_PA0 IRQ_TYPE_LEVEL_LOW>;
        wakeup-source;
    };
};

Allwinner

DTS configuration for the hym8563 module on Allwinner platform:

&twi3 {
    status = "okay";

    hym8563: hym8563@51 {
        compatible = "haoyu,hym8563";
        status = "okay";
        reg = <0x51>;
        interrupt-parent = <&pio>;
        interrupts = <PB 8 IRQ_TYPE_LEVEL_LOW>;
        wakeup-source;
    };
};

Testing

  • Check if the RTC device is correctly recognized

Check if the bus is registered:

ls /dev/i2c*

Use i2cdetect to check if the device is successfully detected and recognized. The I2C device address should be visible (the hym8563 RTC module address is 0x51).

i2cdetect -y 3
  • RTC Test Commands
Command Description
date View/Modify system time (see man date for specific usage)
hwclock -s Synchronize hardware RTC time to the system time
hwclock -w Write the system time to the hardware RTC (persistent save)
timedatectl View detailed information like system time, timezone, RTC status, etc.
  • Manually set the time and synchronize to the RTC
# 1. Manually set the current system time (Format: YYYY-MM-DD HH:MM:SS)
sudo date -s "2024-08-14 08:00:00"

# 2. Write the set system time to the hardware RTC (persists after power loss)
sudo hwclock -w

# 3. Verify: Synchronize the RTC time back to the system (ensure consistency)
sudo hwclock -s