The Real-Time Clock (RTC) is a hardware component that tracks wall clock time and is battery backed so it works even with system power off. Such clocks will normally not track the local time zone or daylight saving time but will instead be set to Coordinated Universal Time.

On the ConnectCore MP25:

  • The STM32MP25 SoC provides one RTC

On the ConnectCore MP25 Development Kit:

  • One RV3028 RTC chip is connected to I2C1

Kernel configuration

You can manage the real-time clock driver support through the following kernel configuration options:

  • STM32 On-Chip Real Time Clock (CONFIG_RTC_DRV_STM32)

  • Micro Crystal RV3028 (CONFIG_RTC_DRV_RV3028)

These options are enabled as built-in on the default ConnectCore MP25 Development Kit kernel configuration file.

Kernel driver

File Description

drivers/rtc/rtc-stm32.c

Driver for the STM32 RTC device

drivers/rtc/rtc-rv3028.c

Driver for the RV3028 RTC device

Device tree bindings and customization

Internal RTC

The STM32MP25 RTC interface device tree binding is documented at Documentation/devicetree/bindings/rtc/st,stm32-rtc.yaml.

The device tree for the STM32MP25 RTC is defined in the STM32MP25 device tree include file:

STM32MP25 device tree
	rtc: rtc@46000000 {
		compatible = "st,stm32mp25-rtc";
		reg = <0x46000000 0x400>;
		clocks = <&scmi_clk CK_SCMI_RTC>,
			 <&scmi_clk CK_SCMI_RTCCK>;
		clock-names = "pclk", "rtc_ck";
		interrupts-extended = <&exti2 17 IRQ_TYPE_LEVEL_HIGH>;
		status = "disabled";
	};

The ConnectCore MP25 SOM device tree include defines RTC RTC_OUT1 as the alarm output. This pin is internally connected to the PMIC wakeup signal.

ConnectCore MP25 device tree
&rtc {
	st,alarm = <RTC_OUT1>;
	pinctrl-0 = <&ccmp25_rtc_out1_pins>;
	pinctrl-names = "default";
	status = "okay";
};

The wireless device tree overlay defines RTC RTC_OUT2_RMP as a clock output. This pin is internally connected to the wireless chip low power oscillator input (on wireless variants):

Wireless device tree overlay
	/* Enable External 32kHz Low-Power Oscillator */
	fragment@3 {
		target = <&rtc>;
		__overlay__ {
			st,lsco = <RTC_OUT2_RMP>;
			pinctrl-0 = <&ccmp25_rtc_out1_pins &ccmp25_rtc_out2_pins>;
			pinctrl-names = "default";
		};
	};

External RTC

The Micro Crystal RV3028 I2C interface device tree binding is documented at Documentation/devicetree/bindings/rtc/microcrystal,rv3028.yaml.

The smallest alarm interval on the external RV3028 RTC is one minute.

The device tree for the RV3028 RTC is defined in the ConnectCore MP25 Development Kit.

ConnectCore MP25 Development Kit device tree
ext_rtc: ext_rtc@52 {
	compatible = "microcrystal,rv3028";
	reg = <0x52>;
	interrupt-parent = <&gpioa>;
	interrupts = <4 IRQ_TYPE_EDGE_FALLING>;
	wakeup-source;
};

RTC user space usage

The different RTCs are accessible via the following file descriptors:

  • /dev/rtc0 (for the STM32MP25 RTC)

  • /dev/rtc1 (for the external RV3028 RTC)

The /dev/rtc device is a symbolic link to /dev/rtc0.

For more information, refer to the Linux kernel documentation at Documentation/devicetree/bindings/rtc/rtc.yaml.

Initializing the RTC

When connected to the Internet, Digi Embedded Yocto uses an NTP (Network Time Protocol) daemon to set the RTC time and keep the system time up to date. You must initialize the RTC the first time you power the board after unpacking the kit and whenever power is completely lost (including RTC backup battery). When not initialized, or if the date is set to a value before the year 1970, the Linux system reports the following error message:

system time... hwclock: settimeofday() failed: Invalid
Linux cannot handle dates before the year 1970.

To initialize the RTC from the Linux shell, set a correct system time using the date command and then issue hwclock -w to write the system time into the RTC. For instance to set June, 3rd 2025 at 15:30:

# date -s "2025-06-03 15:30"
Tue Jun  3 15:30:00 UTC 2025
# hwclock -w -f /dev/rtcX

where X is the index of the RTC device you want to initialize.

RTC test application

Digi Embedded Yocto provides a basic RTC test application. Build the package dey-examples-rtc in your Yocto project to install the test application rtc_test.

The RTC test application allows you to read the current time from the RTC; set it using the system time; and read, set, and test the alarm interrupt.

Syntax

To display the application syntax, run:

# rtc_test -h

Examples

Test the alarm interrupt with the specified seconds:

# rtc_test -e -s 20

In this case, the test sets the RTC alarm to 20 seconds from the current time and then waits for the alarm interrupt to occur.