The MCA implements a real-time clock (RTC) in its firmware. On the ConnectCore 6UL the internal CPU RTC is disabled on the ConnectCore 6UL 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 6UL Micro Controller Assist RTC (CONFIG_RTC_DRV_MCA_CC6UL)
This option is enabled as built-in on the default ConnectCore 6UL 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-cc6ul-rtc.txt.
RTC inside the MCA
mca_cc6ul: mca@7e {
...
rtc {
compatible = "digi,mca-cc6ul-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.
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.
Setting 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
Example 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 then 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 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.