Set hardware clock
I'm trying to set the hw clock of a board running a LFS. I tried to run hwclock, but it returns "hwclock: can't open '/dev/misc/rtc': No such device". I've found in /dev a file named rtc, but after create a symbolic link in /dev/misc/rtc the error remains.
What is your hardware - do you know that it has a hardware clock?
What if you bypass the character device, e.g.:
My hardware is a FriendlyARM mini2440. The directisa option is unknown by hwclock. With ls, I see that /dev has a device called rtc, but when I tried 'hwclock -f /dev/rtc', it says '/dev/rtc - no such device'. Using 'find' searching for 'rtc', it returned the following:
Does the character device look right? e.g.:
Is there a kernel module you need to load first, in order to access it? I'm guess it is already loaded, which is where your
# ls -l /dev/misc/rtc
crw-r--r-- 1 root root 10, 135 Jul 13 15:39 /dev/rtc
Is there anything helpful in the syslog or dmesg regarding rtc? e.g.:
dmesg|egrep -i 'rtc|clock'
My device don't have /dev/misc/rtc, only /dev/rtc.
I run the other command, too:
# ls -l /dev/rtc
crw-r----- 1 root root 10, 135 Aug 2 08:34 /dev/rtc
#dmesg | egrep -i 'rtc|clock'
S3C24XX Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
S3C244X: Clock Support, DVS off
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
s3c2410-rtc s3c2410-rtc: setting system clock to 2011-09-08 09:14:22 UTC (1315473262)
I said /dev/misc/rtc because that's where you said it was originally, but /dev/rtc is the normal location anyway, i think.
What version of hwclock are you using? Did you compile it yourself (LFS) or is it busybox, or something else?
Does setting the date first make a difference?
I compiled using Buildroot (that uses Busybox). The --version arg isn't recognized by hwclock.
Busybox v1.18.5 (2011-08-02 09:53:04 BRT) multi-call binary.
Usage: hwclock [-r|--show] [-s|--hctosys] [-w|--systohc] [-l|--localtime] [-u|--utc] [-f FILE]
Query and set hardware clock (RTC)
-r Show hardware clock time
-s Set system time from hardware clock
-w Set hardware clock to system time
-u Hardware clock is in UTC
-l Hardware clock is in local time
-f FILE Use specified device (e.g. /dev/rtc2)
I've had trouble before with busybox applets that replace actual binaries. Is there any chance you can compile hwclock from source yourself, for your platform? It is part of the util-linux (or util-linux-ng) package.
There's a section on it in the LFS installation guide.
Well, I don't have much skills in compiling from source, but I can try. I used the Buildroot to build the whole system because I need some specific libraries to use in the board (I compiled the dependencies with the Buildroot, and then my libraries using the generated toolchain). But the problem seems to be the rtc device, isn't? Although the rtc device is present, it always says "No such device"...
Yeah, I may be way off on that, anyway...just an idea.
Out of curiosity, what is in the /proc/driver/rtc file?
Kernel.org is still down, but I see the util-linux-ng source is here.
Is your toolchain set up (for compiling for the ARM platform)? Hopefully, it will be as straight-forward as:
If cross-compiling, you'll probably need to set some env vars before-hand, or tell configure where your compiler, libs, headers, etc. are.
tar jxf util-linux-ng-2.14.2.tar.bz2
If the make command completes successfully, you'll have hwclock in ./hwclock/hwlock
EDIT: Check out the kernel documentation for rtc, too - do you need /dev/rtc0?