The MCA implements a real-time clock (RTC) in its firmware.
On the ConnectCore 95 the internal CPU RTC is disabled because the MCA implementation handles power consumption more efficiently.
| To keep the date during power-off you must connect a coin cell battery to the board. |
Kernel configuration
You can manage the MCA RTC driver support through the following kernel configuration option:
-
Digi ConnectCore SOMs Micro Controller Assist RTC (
CONFIG_RTC_DRV_MCA)
This option is enabled as built-in on the default ConnectCore 95 kernel configuration file.
Kernel driver
The MCA GPIO driver is located at:
| File | Description |
|---|---|
MCA RTC driver |
Device tree bindings and customization
The MCA RTC device tree binding is documented at Documentation/devicetree/bindings/rtc/digi,mca-rtc.yaml.
RTC inside the MCA
mca_cc95_smarc: mca@20 {
[...]
rtc {
compatible = "digi,mca-rtc";
};
};
Using the RTC
The MCA RTC is accessible via the file descriptor /dev/rtc0.
The /dev/rtc device is a symbolic link to /dev/rtc0.
Set system time in Linux
On boot-up, Linux sets the system time from the data kept on the RTC.
If a more recent time-stamp exists in /etc/timestamp then it uses that time-stamp instead.
The file /etc/timestamp is initially sourced with the image build timestamp and updated with the system time on a clean reboot/poweroff process.
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.
Set a date
To set the system time, use the date command:
# date -s "2017-02-23 11:30:00"
To write the system time to the RTC, use the hwclock command:
# hwclock -w
Enable RTC wake alarm
You can enable the RTC device as a wake-up source. See RTC alarm resume for more information.
Run the 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
-
read, set, and test the alarm interrupt
To display the application syntax, run:
# rtc_test -h
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.