Real-Time Clock (RTC)
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.
The ConnectCore 6 system-on-module has two RTCs:
- One provided by the Dialog DA9063 PMIC
- Another provided by the i.MX6 Secure Non Volatile Storage (SNVS) device
Digi Embedded Yocto only uses the Dialog DA9063 RTC.
Kernel configuration
You can manage the real-time clock driver support through the following kernel configuration options:
- For the DA9063 RTC, Dialog DA9063 RTC (CONFIG_RTC_DRV_DA9063), which is enabled as built-in on the default ConnectCore 6 SBC kernel configuration file.
- For the SNVS RTC, Freescale SNVS RTC support (CONFIG_RTC_DRV_SNVS), which is also enabled as built-in on the default kernel configuration file.
Platform driver mapping
File | Description |
---|---|
drivers/rtc/rtc-da9063.c | Driver for the DA9063 RTC device |
drivers/rtc/rtc-snvs.c | Driver for the SNVS RTC device |
Device tree bindings and customization
The Dialog DA9063 I2C interface device tree binding is documented at Documentation/devicetree/bindings/mfd/da9063.txt.
The device tree node for the DA9063 RTC and the i.MX6 RTC are defined in the common i.MX6 device tree includes.
Common i.MX6 device tree
rtc { compatible = "dlg,da9063-rtc"; interrupts = <1 2>; interrupts-names = "ALARM" , "TIMER"; interrupt-parent = <&pmic_dialog>; };
Common i.MX6 device tree
snvs-rtc-lp@34 { compatible = "fsl,sec-v4.0-mon-rtc-lp"; reg = <0x34 0x58>; interrupts = <0 19 IRQ_TYPE_LEVEL_HIGH>, <0 20 IRQ_TYPE_LEVEL_HIGH>; };
RTC user space usage
The different RTCs are accessible via the following file descriptors:
- /dev/rtc0 (for the DA9063 RTC)
- /dev/rtc1 (for the SNVS RTC)
The /dev/rtc device is a symbolic link to /dev/rtc0.
For more information, refer to the Linux kernel documentation at Documentation/rtc.txt.
Initializing the RTC
When connected to the Internet, Digi Embedded Yocto uses a 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.
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 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.