kumquat-readthedocs/docs/interfaces/rtc.md
2024-04-29 22:03:41 +02:00

1.5 KiB

RTC

The Real Time Clock (RTC) on the Kumquat serves the basic purpose of keeping the time of day. The RTC can keep track of the year, month, date, weekday, hour, minute and seconds. This document will guide you on how to use the RTC on the Kumquat.

Device Name Description
/dev/rtc0 DS3232 connected over I2C1 with battery backup on Xn
/dev/rtc1 built in to SoC, disabled by default

Prerequisites

Before you begin, make sure you have the following:

  • Backup Battery connected to Xn in order for the RTC to keep working when the board is powered off.

Accessing the RTC

  • With the following command, check that the RTC is detected correctly
cat /sys/class/rtc/rtc0/device/name
It's output should look something like this:
ds3232
  • If the RTC is detected you can proceed to the next steps.

Setting the Time

  • Write the current system time to the RTC:
hwclock -w -f /dev/rtc0
  • Read back the time stored in the RTC:
hwclock -r -f /dev/rtc0

Testing the Backup Battery

  • Now that you have set the RTC, you may power down the board using the following command:
poweroff
  • Unplug the power supply from the Kumquat

  • After about a minute you can connect the power supply again and boot into Buildroot

  • Running the following command, should show you the accurately advanced time to when the board was powered off

hwclock -r -f /dev/rtc0