RTC

This guide will show you how to use rtc0 on the phyCORE-AM62Ax development kit to verify functionality when power is lost. To learn more information about the phyCORE-AM62Ax RTC interface, please see section 12.4 in the Hardware Manual.

RTC Naming

Note

rtc0 is named after the physical IC populated on the SOM at U19.

  • Verify the name of the RTC device by checking the name file in the interface’s sysfs directory:

Target (Linux)
cat /sys/class/rtc/rtc0/name
Expected Output
root@phyboard-lyra-am62axx-1:~# cat /sys/class/rtc/rtc0/name
rtc-rv3028 0-0052

Setting the System Time

  • Set the RTC time by first setting the system time. We can do this manually or leverage the Network Time Protocol (NTP):

Manually

  • Use the following command to set an arbitrary time as the system time in Linux:

Target (Linux)
date 071916142016

Note

The argument in the above command broken down is:

07-19 16:14 2016

date time year

Setting the RTC

  • With the system time set according to the above steps, you can now write this time to the RTC using the following command:

Target (Linux)
hwclock -w -f /dev/rtc0

Reading the RTC

  • The RTC’s time can be read using the following command:

Target (Linux)
hwclock -r -f /dev/rtc0
  • The time set here should persist between boots and times without power as long as the VBAT pin of the SOM is supplied.

Warning

A new SOM with an unprogrammed rtc may throw errors when read:

Expected Output
root@phyboard-lyra-am62axx-1:~# hwclock -r -f /dev/rtc0
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument

Set the RTC time according to the steps above to resolve this.

Expected Output
 root@phyboard-lyra-am62axx-1:~# hwclock -r -f /dev/rtc0
 Tue Jul 19 16:16:34 2016  0.000000 seconds