注意:确保板子上已经安装了纽扣电池,并且电池电压正常
RTC 测试,主要通过使用 date 和 hwclock 工具设置软、硬件时间,测试当板子断电再上电的时候,软件时钟读取 RTC 时钟是否同步 时间设置
root@3506-buildroot:/# date -s "2022-12-12 17:23:00"
Mon Dec 12 17:23:00 UTC 2022
将软件时间同步到硬件时间
root@3506-buildroot:/# hwclock -w
显示硬件时间
root@3506-buildroot:/# hwclock -r
Mon Dec 12 17:23:23 2022 0.000000 seconds
然后给板子断电后等3秒后再上电,进入系统后读取系统时间,可以看到时间已经同步。
root@3506-buildroot:/# date
Mon Dec 12 17:26:10 UTC 2022