Port Linux2.6.24.4 to S3C2410 (nano2410): RTC

Source: Internet
Author: User
Port Linux2.6.24.4 to S3C2410 (nano2410): RTC -- general Linux technology-Linux programming and kernel information. For more information, see the following. [Platform information]
Target Board Nano2410
CPU: S3C2410X
SDRAM: HY57V561620 (32 MB)
FLASH: K9F1208 (64 MB)
NET: CS8900
HOST

Linux Realse Version: Fecora Cor 8 (FC8)
CrossCompiler: gcc-4.1.1/glibc-2.3.2

The startup information shows that the RTC driver is not loaded successfully!

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

The RTC of S3C2410 is already in 2.6.24.4 kernel, but it is not added to the SMDK2410 targetboard,

Therefore, you only need to add RTC to the initialized device list.

1. Use the default settings for the RTC section in menu config.

2. Modify the file mach-smdk2410.c (/linux2.6.24.4/arch/arm/mach-s3c2410/mach-smdk2410.c), and add & amp.

3. Create the rtc Device File rtc in the/etc directory.

Mknod rtc? C 10 135

4. recompile the kernel. Check the startup information.

......
S3C24XX RTC, (c) maid Electronics
S3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
S3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
......

(The above information indicates that the RTC device has been added to the kernel .)

......
S3c2410-rtc s3c2410-rtc: hctosys: invalid date/time
......

The preceding information indicates that the RTC time may not be set. The initial RTC time is Wed Dec 31 23:59:59 1969. From the kernel function int rtc_valid_tm (struct rtc_time * tm), we can see that when year is less than 1970, it is considered as the time invalid, and the function returns-EINVAL. Let's verify this idea. J

[Root @ kevin/] # hwclock
Wed Dec 31 23:59:59 1969 0.000000 seconds
[Root @ kevin/] # date
Thu Jan 1 00:06:58 UTC 1970

The system time is set by date, And the RTC time is set by hwclock. When the system is started, the system time is obtained through RTC. When RTC is not set, Wed Dec 31 23:59:59 1969 is also used for the system time.

[Root @ kevin/] # hwclock -- help

BusyBox v1.9.2 (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

The above error message is caused by incorrect year settings. If no RTC is set, RTC does not start timing.

Next, set the correct system time and pass the system time to RTC.

[Root @ kevin/] # Day 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 is working!

To synchronize system time with RTC time, you can add commands to the initialization file.

Hwclock? S

Enables the RTC time to be read and synchronized to the system at each boot.

Add
# + Kevin080305

/Bin/hwclock-s

If you have any questions, please contact us:
QQ: 21744485
Email: zhang8083@163.com
QQ Group: 7152476 (ARM & Linux Research)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.