Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
Hello! 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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! striker07's Avatar
    Join Date
    Jul 2010
    Location
    Santa Rita do Sapucaí, Brazil
    Posts
    47

    Set hardware clock


    Hello!

    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.

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    What is your hardware - do you know that it has a hardware clock?

    What if you bypass the character device, e.g.:
    Code:
    hwclock --directisa

  3. #3
    Just Joined! striker07's Avatar
    Join Date
    Jul 2010
    Location
    Santa Rita do Sapucaí, Brazil
    Posts
    47
    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:

    Code:
    /dev/rtc
    /sys/devices/platform/s3c2410-rtc/rtc
    /sys/class/rtc
    /proc/driver/rtc

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Does the character device look right? e.g.:
    Code:
    # ls -l /dev/misc/rtc
    crw-r--r--  1 root root 10, 135 Jul 13 15:39 /dev/rtc
    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

    /sys/devices/platform/s3c2410-rtc/rtc

    comes from.

    Is there anything helpful in the syslog or dmesg regarding rtc? e.g.:
    Code:
    dmesg|egrep -i 'rtc|clock'

  6. #5
    Just Joined! striker07's Avatar
    Join Date
    Jul 2010
    Location
    Santa Rita do Sapucaí, Brazil
    Posts
    47
    My device don't have /dev/misc/rtc, only /dev/rtc.

    Code:
    # ls -l /dev/rtc
    crw-r-----    1 root    root    10, 135 Aug  2 08:34 /dev/rtc
    I run the other command, too:
    Code:
    #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)

  7. #6
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    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?
    Code:
    hwclock --version
    Does setting the date first make a difference?

  8. #7
    Just Joined! striker07's Avatar
    Join Date
    Jul 2010
    Location
    Santa Rita do Sapucaí, Brazil
    Posts
    47
    I compiled using Buildroot (that uses Busybox). The --version arg isn't recognized by hwclock.

    Code:
    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)
    
    Options:
            -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)

  9. #8
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    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.

  10. #9
    Just Joined! striker07's Avatar
    Join Date
    Jul 2010
    Location
    Santa Rita do Sapucaí, Brazil
    Posts
    47
    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"...

  11. #10
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Yeah, I may be way off on that, anyway...just an idea.

    Out of curiosity, what is in the /proc/driver/rtc file?

    Code:
    cat /proc/driver/rtc
    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:
    Code:
    wget http://somesite/util-linux-ng-2.14.2.tar.bz2
    tar jxf util-linux-ng-2.14.2.tar.bz2
    cd util-linux-ng-2.14.2
    ./configure
    make
    If cross-compiling, you'll probably need to set some env vars before-hand, or tell configure where your compiler, libs, headers, etc. are.

    If the make command completes successfully, you'll have hwclock in ./hwclock/hwlock

    good luck!

    EDIT: Check out the kernel documentation for rtc, too - do you need /dev/rtc0?
    Last edited by atreyu; 09-09-2011 at 02:53 PM. Reason: kernel doc

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •