RTC
RTC stands for Real Time Clock, a dedicated hardware device for recording time. It can generally be integrated inside the SOC or choose external equipment, communicating via I2C.
So why is RTC needed? Because Linux system time (commonly known as wall time) can only be used while the system is running; it is lost when the system shuts down. However, RTC can continue to work after the system is shut down, relying on an external battery or other power supply. This is how time is preserved.
1. RTC Usage
Taking M5-R1 as an example, this board uses an external RTC (hym8563), and the rk809 rtc function is disabled by default.
When using the external RTC, a button battery needs to be connected.
2. RTC User Interface Call
date // Modify system clock, see man for specific command usage
hwclock -s // Sync hardware time to system time
hwclock -w // Sync system time to hardware time
date "2023-08-14 08:00:00" // Manually set time
hwclock -w // Sync system time to hardware RTC
hwclock -s // Sync hardware RTC to system
# After manually setting time or syncing time from network above, -w writes system time to hardware RTC, -s then writes RTC time back to system. This way, every time the board restarts, RTC time will be synced to system time.