Platform: RK3399
OS: Android 7.1
Kernel: v4.4.83
现象:
使用busybox hwclock -r读取rtc时间是提示:
hwclock: ioctl 0x80247009 failed: Invalid argument
kernel log提示:
[ 65.931824] rtc rtc0: read_time: fail to read: -22
原因:
硬件RTC的月份时间默认是返回-1,导致rtc_valid_tm判断失败返回错误。
rtc_valid_tm():
int rtc_valid_tm(struct rtc_time *tm)
{
if (tm->tm_year < 70
|| ((unsigned)tm->tm_mon) >= 12
|| tm->tm_mday < 1
|| tm->tm_mday > rtc_month_days(tm->tm_mon, tm->tm_year + 1900)
|| ((unsigned)tm->tm_hour) >= 24
|| ((unsigned)tm->tm_min) >= 60
|| ((unsigned)tm->tm_sec) >= 60)
return -EINVAL;
return 0;
}
解决方法:
diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c