TS-7250-V3 Supervisory RTC
From embeddedTS Manuals
The supervisory microcontroller also provides a real time clock to backup system time when power is lost. This RTC features:
- Unsigned 32-bit counter (currently keeps time until 2106)
- Alarm to wake the board up from power off
- Alarm can be configured to reboot the system (eg, a slow wdt)
- Battery detection.
- Offset support to tune rtc in ppb
- Can retain time for ~8 years with the CR1632 battery
The typical RTC features are provided by the rtc-tssupervisor driver present in our kernels. This includes setting/getting the latest epoch time. On most distributions this requires no user interaction and systemd will sync the hardware clock when it syncs to a network time protocol (NTP) server.
To manually interact with the RTC the hwclock command is typically used:
# Set the RTC from the system time
hwclock --systohc
# Set the system time from the RTC
hwclock --hctosys
# Just print the RTC time, do not set either clock
hwclock --show
Our RTC also has several sysfs entries to support the nonstandard features:
### VBATT:
## Returns 0 or 1 to indicate if VBATT is > 1.8-2.0V
## Does not indicate a sufficient voltage to keep time, but can be used to detect
## no battery or a malfunctioning battery
cat /sys/class/rtc/rtc0/device/batt_present
### RTC Alarm Wake up:
## The RTC can be used to wake the system after shutting down.
# The hwclock call can be skipped if system time is already set:
hwclock --systohc
# Takes the current time and adds 60 seconds
echo $(($(date +%s)+60)) > /sys/class/rtc/rtc0/device/alarm
echo 1 > /sys/class/rtc/rtc0/device/alarm_en
### RTC Alarm Watchdog:
## If its not being used for waking the system, the RTC alarm can be used to
## Reset the system if the time is not updated. This can be used as a very slow watchdog, setting
## a reset time of minutes/hours/days ahead instead of a typical 128 seconds a typical
## watchdog allows as the largest timer, but it is slower to feed so it should not be fed quickly.
## Keep in mind this reset is immediate and can corrupt any filesystems mounted read/write when the watchdog
## trips.
# The hwclock call can be skipped if system time is already set:
hwclock --systohc
# Takes the current time and adds 10 seconds
echo $(($(date +%s)+10)) > /sys/class/rtc/rtc0/device/alarm
echo 1 > /sys/class/rtc/rtc0/device/alarm_cause_reboot
echo 1 > /sys/class/rtc/rtc0/device/alarm_en