15. RTC¶
The full name of RTC is Real Time Clock. It is a hardware device specially used to record time. Generally, it can be integrated inside the soc, or it can be plugged in and communicate with it through i2c.
Then why is RTC needed, because the Linux system time (that is, the wall time we often say) can only be used when the system is running, and the system shutdown time is lost. The RTC can rely on external batteries or other supply after the system is shut down. Keep working to save time.
LubanCat-RK series boards need an RTC battery to enable the RTC function. The selection of the RTC battery is as follows:
Purchase link (for reference only): (Taobao) CR2032 Lenovo IBM notebook desktop motherboard battery 3V button COMS with 2 pins
Purchase link (for reference only): (Taobao) original KTS CR2032 button battery 3V notebook remote control desktop motherboard computer lithium battery with cable
注解
The link is for reference only, if necessary, please search and purchase according to the keywords of the above link
The positive and negative poles of the wiring are as follows:

If the wire sequence is wrong, you can use tweezers to adjust the interface of the RTC battery:

15.1. rk809¶
RK809 is a high-performance PMIC. RK809 integrates 5 high-current DCDCs, 9 LDOs, 2 switches SWITCH, 1 RTC, 1 high-performance CODEC, adjustable power-on sequence and other functions.
LubanCat-RK series boards all use RK809 as pmic, but only LubanCat-1, LubanCat-1N, LubanCat-2, LubanCat-2N actually use the RTC function of RK809
15.2. rx8010¶
The RTC used on the LubanCat-2 gold finger base board and BTB base board is an external rx8010 chip. The rx8010 is easy to use, standard SOP8 package and cost-effective.
15.3. Instructions¶
Linux provides three user-space calling interfaces. The corresponding path in the board is:
SYSFS interface:/sys/class/rtc/rtc0/
PROCFS interface: /proc/driver/rtc
IOCTL interface: /dev/rtc0
SYSFS interface:
1 2 3 4 | root@lubancat:~# cat /sys/class/rtc/rtc0/date
2023-06-19
root@lubancat:~# cat /sys/class/rtc/rtc0/time
03:15:22
|
PROCFS interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 | root@lubancat:~# cat /proc/driver/rtc
rtc_time : 07:06:56
rtc_date : 2023-06-19
alrm_time : 03:18:50
alrm_date : 2023-06-19
alarm_IRQ : no
alrm_pending : no
update IRQ enabled : no
periodic IRQ enabled : no
periodic IRQ frequency : 1
max user IRQ frequency : 64
24hr : yes
root@lubancat:~#
|
IOCTL interface:
1 2 | You can refer to the kernel documentation as an example
tools/testing/selftests/timers/rtctest.c
|
15.4. Some commonly used commands¶
1 2 3 4 | date //Modify the system clock, the specific command can be used under man
hwclock -s //Synchronize hardware time to system time
hwclock -w //Synchronize system time to hardware time
timedatectl //Display system time, etc.
|