手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

fs2410 Linux-2.6.35内核移植中的RTC问题--drivers/rtc/hctosys.c: unable to open rtc device (rtc0)

[日期:2011-02-09] 来源:Linux社区  作者:sustzombie [字体:大 中 小]
下面来验证一下这个想法

# hwclock

Wed Dec 31 23:59:59 1969  0.000000 seconds

# date

Thu Jan  1 00:06:58 UTC 1970

系统时间是通过 date 来设置的, RTC 时间是通过 hwclock 来设置的。开机时系统时间首先通过 RTC 来获得,RTC没有设置时,系统时间也会使用Wed Dec 31 23:59:59 1969。

# hwclock --help

BusyBox v1.9.2 (2008-04-01 21:32:34 CST) multi-call binary

Usage: hwclock [-r|--show] [-s|--hctosys] [-w|--systohc] [-l|--localtime] [-u|--utc] [-f FILE]

Query and set a hardware clock (RTC)

Options:

            -r       Read hardware clock and print result

            -s      Set the system time from the hardware clock

            -w      Set the hardware clock to the system time

            -u      The hardware clock is kept in coordinated universal time

            -l       The hardware clock is kept in local time

            -f FILE      Use the specified clock (e.g. /dev/rtc2)

 

# hwclock -s

hwclock: settimeofday() failed: Invalid argument

# hwclock -w

s3c2410-rtc s3c2410-rtc: rtc only supports 100 years

hwclock: RTC_SET_TIME: Invalid argument

以上错误信息都是因为 year 设置不当引起的。没有设置 RTC , RTC 也不会启动计时。

下面首先设置正确的系统时间,然后将系统时间传递给 RTC 。

# date 040612282008.20

Sun Apr  6 12:28:20 UTC 2008

# hwclock -w

# hwclock

Sun Apr  6 12:29:01 2008  0.000000 seconds

# hwclock

Sun Apr  6 12:30:15 2008  0.000000 seconds

Ok , RTC 开始工作了!

为了使系统时间和 RTC 时间同步,可以在初始化文件中添加命令

Hwclock –s

使每次开机时读取 RTC 时间,并同步给系统时间。

在 etc/init.d/rcS 中添加

/bin/hwclock -s


时间设置的相关命令

    1. 在虚拟终端中使用date 命令来查看和设置系统时间
    查看系统时钟的操作:
    # date

    设置系统时钟的操作:
    # date 091713272003.30

    通用的设置格式:
    # date 月日时分年. 秒

    2. 使用hwclock 或clock 命令查看和设置硬件时钟
    查看硬件时钟的操作:
    # hwclock --show 或
    # clock --show
    2003年 09月 17日 星期三 13 时24 分11 秒 -0.482735 seconds

    设置硬件时钟的操作:
    # hwclock --set --date="09/17/2003 13:26:00"

    或者
    # clock --set --date="09/17/2003 13:26:00"

    通用的设置格式:hwclock/clock --set --date=“ 月/ 日/ 年时:分:秒” 。

    3. 同步系统时钟和硬件时钟

    Linux 系统( 笔者使用的是Red Hat 8.0 ,其它系统没有做过实验) 默认重启后,硬件时钟和系统时钟同步。如果不大方便重新启动的话( 服务器通常很少重启) ,使用clock 或hwclock 命令来同步系统时钟和硬件时钟。

    硬件时钟与系统时钟同步:
    # hwclock --hctosys

    或者
    # clock --hctosys

    上面命令中,--hctosys 表示Hardware Clock to SYStem clock 。

    系统时钟和硬件时钟同步:
    # hwclock --systohc

    或者
    # clock --systohc

    使用图形化系统设置工具设置时间

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款