The phyCORE-i.MX7 features two options for hardware real time clocks (RTC) that keep time even when the board has lost power. The optional external RTC populated on the SOM at U10 is interfaced through rtc0 in the device tree and the RTC internal to the processor is interfaced through rtc1. This guide will walk through the use of rtc1 to verify functionality when power is lost.
You can verify the name of the RTC interface by checking the name file in the interface's directory.
rtc0 is named after the physical IC populated on the SOM at U10.
Step-by-Step Guide
Enter the following to set the system time to an arbitrary date (I picked July 19th, 2016 at 16:14):
If your i.MX7 hardware is connected to the internet then it will not allow you to manually set the date and time unless we disable automatic time sync. Use the following command if your phyCORE-i.MX7 is connected to your network:
Target (Linux)
timedatectl set-ntp false
CODE
Target (Linux)
date 071916142016
CODE
The argument in the above command broken down is:
07-19 16:14 2016
date time year
Assign the system time to the hardware clock:
Target (Linux)
hwclock -w -f /dev/rtc1
CODE
Read back the time to ensure it was set properly:
Target (Linux)
hwclock -r -f /dev/rtc1
CODE
Power off the phyCORE-i.MX7, disconnect it from the power supply and wait a minute or so:
Target (Linux)
poweroff
CODE
After the development kit has been powered off for a minute, reboot and login as root.
Use the following command to verify that the phyCORE-i.MX7 has been keeping track of the time when turned off:
Target (Linux)
hwclock -r -f /dev/rtc1
CODE
If you had to disable automatic time sync at the beginning of this guide then you will likely want to re-enable it. Use the following command to do so: