|
发表于 2020-5-28 16:58:29
8317 浏览 0 回复
linux RTC
RV3028 linux4.9 RTC 调试记录
在注册前需要将device_init_wakeup函数实现,才能alarmtimer_rtc_add_device ;否则alarmtimer_get_rtcdev返回为NULL;
如果不实现device_init_wakeup函数上层调用ioctl: alarm_do_ioctl : ANDROID_ALARM_SET_RTC
由 rtc_dev = alarmtimer_get_rtcdev(); 来判断有没 rtc 设备
如果有 执行 rv = rtc_set_time(rtc_dev, &new_rtc_tm);
没有的话,就不能写时间到 rtc 中。(虽然有 /dev/rtc0)
device_init_wakeup(&client->dev, 1);
注册rtc设备有以下两种方式
rv3028->rtc = devm_rtc_device_register(&client->dev, client->name,
&rv3028_rtc_ops, THIS_MODULE);
rv3028->rtc = rtc_device_register(client->name, &client->dev, &rv3028_rtc_ops, THIS_MODULE);
修改linux的系统时间命令使用date -s [MMDDhhmm[[CC]YY][.ss]]
不过系统重启会会重新和硬件时钟同步。
要想永久修改系统时间,就需要如下命令:hwclock
file:///C:/Users/lrz/AppData/Local/YNote/data/weixinobU7VjmB8_Hp9un0xRra7YhPVUSo/20d3000598864bfab75e4d80e4fb5d88/2ef39ec795a.jpeg
hwclock [function] [option...]Functions: -h, --help show this help text and exit -r, --show read hardware clock and print result --set set the RTC to the time given with --date -s, --hctosys set the system time from the hardware clock -w, --systohc set the hardware clock from the current system time --systz set the system time based on the current timezone --adjust adjust the RTC to account for systematic drift since the clock was last set or adjusted --getepoch print out the kernel's hardware clock epoch value --setepoch set the kernel's hardware clock epoch value to the value given with --epoch --predict predict RTC reading at time given with --date -V, --version display version information and exitOptions: -u, --utc the hardware clock is kept in UTC --localtime the hardware clock is kept in local time -f, --rtc <file> special /dev/... file to use instead of default --directisa access the ISA bus directly instead of /dev/rtc --badyear ignore RTC's year because the BIOS is broken --date <time> specifies the time to which to set the hardware clock --epoch <year> specifies the year which is the beginning of the hardware clock's epoch value --noadjfile do not access /etc/adjtime; this requires the use of either --utc or --localtime --adjfile <file> specifies the path to the adjust file; the default is /etc/adjtime --test do not update anything, just show what would happen -D, --debug debugging mode
hwclock -r 显示硬件时钟时间;
hwclock -s 设置系统时间,使得系统时间变为跟硬件时间同步;
hwclock -w 设置硬件时间,使得硬件时钟变为跟系统时间同步;
|
|
|
|
|
|
|
登录或注册
|