Linux 2.6.22.6移植到S3C2440之RTC

來源:互聯網
上載者:User

移植linux2.6.22到s3c2440遇到drivers/rtc/hctosys.c: unable to open rtc device (rtc0)錯誤提示。

網上搜尋找到瞭解決辦法,如下:

解決辦法:

從啟動資訊可以看出沒有載入成功RTC驅動!

TCP cubic registered

NET: Registered protocol family 1

RPC: Registered udp transport module.

RPC: Registered tcp transport module.

drivers/rtc/hctosys.c: unable to open rtc device (rtc0)

IP-Config: Complete:

      device=eth0, addr=192.168.0.69, mask=255.255.255.0, gw=192.168.0.1,

     host=www, domain=, nis-domain=kevin.com,

     bootserver=192.168.0.104, rootserver=192.168.0.104, rootpath=

Looking up port of RPC 100003/2 on 192.168.0.104

 

S3C2440的RTC已經在2.6.22.6
kernel中,但是沒有加入SMDK2440 targetboard,

所以我們只需要將RTC加入初始化的裝置列表中。

 

1.      
menu config中RTC部分使用預設設定。

 

2.      
修改檔案mach-smdk2440.c(/linux2.6.22.6/arch/arm/mach-s3c2440/mach-smdk2440.c),在數組smdk2440_devices[]中添加&s3c_device_rtc.

 

3.      
在/dev目錄下建立rtc裝置檔案rtc.

            mknod rtc c 10 135

 

4.      
重新編譯核心。看看啟動資訊。

            ……

            S3C24XX RTC, (c) 2004,2006 Simtec Electronics

            s3c2440-rtc s3c2440-rtc: rtc disabled, re-enabling

            s3c2440-rtc s3c2440-rtc: rtc core: registered s3c as rtc0

            ……

            以上資訊說明RTC裝置已經加入核心了。

             完事。

 

 

 

錯誤提示:hwclock: settimeofday() failed: Invalid argument

以上資訊說明可能還沒有設定RTC時間,RTC初始時間為
Wed Dec 31 23:59:59 1969。從核心功能int rtc_valid_tm(struct rtc_time *tm),可以看出,當year小於1970時,認為是時間
invalid,函數返回-EINVAL下面來驗證一下這個想法J

 

[username@yc2440]#
[username@yc2440]# hwclock
Wed Dec 31 23:59:59 1969  0.000000 seconds
[username@yc2440]# date
Wed Jul 30 20:34:09 UTC 1975

系統時間是通過date來設定的,RTC時間是通過hwclock來設定的。開機時系統時間首先通過RTC來獲得,RTC沒有設定時,系統時間也會使用Wed
Dec 31 23:59:59 1969。

 

[root@kevin /]# 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)

 

[root@kevin /]# hwclock -s

hwclock: settimeofday() failed: Invalid argument

[root@kevin /]# hwclock -w

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

hwclock: RTC_SET_TIME: Invalid argument

 

以上錯誤資訊都是因為year設定不當引起的。沒有設定RTC,RTC也不會啟動計時。

 

下面首先設定正確的系統時間,然後將系統時間傳遞給RTC。

 

[root@kevin /]# date 040612282008.20

Sun Apr  6 12:28:20 UTC 2008

[root@kevin /]# hwclock -w

[root@kevin /]# hwclock

Sun Apr  6 12:29:01 2008  0.000000 seconds

[root@kevin /]# hwclock

Sun Apr  6 12:30:15 2008  0.000000 seconds

 

Ok,RTC開始工作了!

 

為了使系統時間和RTC時間同步,可以在初始設定檔案中添加命令

Hwclock –s

使每次開機時讀取RTC時間,並同步給系統時間。

 

在etc/init.d/rcS中添加

#+kevin080305

/bin/hwclock -s

 

 

轉載自:http://blog.chinaunix.net/u2/63560/showart_518707.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.