Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 57

Thread: Real time clock with Oleg's firmware

  1. #16
    Join Date
    Feb 2005
    Location
    Germany - Frankfurt
    Posts
    1,548
    Let me have a try

    EDIT:

    Added to HowTo. Still problems saving time to rtc:
    [admin@blechbuechse root]$ write /dev/rtc string:2007:04:23:1:15:05:27
    /dev/rtc: File is too small (22 bytes)
    Next try:
    echo "string:2007:04:23:1:15:05:27" > /dev/rtc
    This results in a disconnect of ssh
    Last edited by wengi; 23-04-2007 at 14:18.

  2. #17
    Join Date
    May 2007
    Location
    Germany - Stuttgart
    Posts
    20
    Since I also had some trouble with the proprietary rtcdrv.o module, I simply wrote my own one. If you trust me enough , try the attached rtc.o module. I have compiled it for OpenWrt (WhiteRussian 0.9). It has the same interface as rtcdrv.o, plus support for an ordinary hwclock utility. The only difference is, that it uses the standard 10/135 major/minor numbers for /dev/rtc, whereas rtcdrv.o uses 12/0. The source code is available too, but I didn't want to throw in an 8k big file at once.

    UPDATE: attachment removed because it doesn't work with Oleg's firmware.
    Last edited by andi; 26-05-2007 at 15:40. Reason: attachment removed

  3. #18
    Join Date
    Feb 2005
    Location
    Germany - Frankfurt
    Posts
    1,548
    Thanks andi,

    but how can i set the time now?

    wengi

  4. #19
    Join Date
    May 2007
    Location
    Germany - Stuttgart
    Posts
    20
    First make sure that you have the correct device entry. It might be that you have the wrong entry from the rtcdrv.o module.
    root@OpenWrt:~# ls -l /dev/rtc
    crw-r--r-- 1 root root 10, 135 Jan 1 2000 /dev/rtc
    If not, create the correct device node first:
    mknod /dev/rtc c 10 135
    Then a simple
    root@OpenWrt:~# cat /dev/rtc
    2007:05:20:0:19:17:00
    should print the current date and time and
    echo "2007:05:20:0:19:17:00" > /dev/rtc
    should set the RTC. If changing the time does not work, please check the kernel log for any error message.

    A better solution would be to use a real hwclock utility, but this requires recompilation of busybox.

    UPDATE:
    Or even easier: use the following script:
    Code:
    #!/bin/sh
    
    [ -c /dev/rtc ] || {
            echo "/dev/rtc missing"
            exit 1
    }
    
    case "$1" in
            --show)
                    /bin/cat /dev/rtc
                    ;;
            --hctosys)
                    /bin/cat /dev/rtc|(IFS=:;read Y M D d h m s;/bin/date -s $M$D$h$m$Y.$s)
                    ;;
            --systohc)
                    /bin/date +%Y:%m:%d:%w:%H:%M:%S > /dev/rtc
                    ;;
            *)
                    echo "Usage: $0 {--show|--systohc|--hctosys}" >&2
                    ;;
    esac
    Last edited by andi; 20-05-2007 at 18:53.

  5. #20
    Join Date
    Feb 2005
    Location
    Germany - Frankfurt
    Posts
    1,548
    hmmm. it does not seem to work with olegs firmware
    i can load the module:
    Code:
    May 21 11:14:39 kernel: WL-HDD Real Time Clock Driver loaded
    mknod works and there is a /dev/rtc.
    But then:
    Code:
    [admin@blechbuechse root]$ cat /dev/rtc
    /dev/rtc: Bad address
    Any idea?

    wengi

  6. #21
    Join Date
    May 2007
    Location
    Germany - Stuttgart
    Posts
    20
    Hmm, too bad . There's still one attempt left. I have attached a previous version of the module, which doesn't use the kernel supplied interface to the gpio pins, but directly accesses them through memory mapped I/O (same method as the proprietary rtcdrv.o). However, I abandoned it, because of the hardwired addresses used and some problems I had with implementing the write routine (I wasn't able to write all RTC registers in one go). Perhaps you have more luck with this one.

    Note that I have added a debug option to this module. You can load it with
    insmod rtc2.o rtc_debug=1
    and then the kernel log should tell you something about the traffic on the i2c bus.

    If this still doesn't work, I currently don't have an idea how to proceed.

    UPDATE: attachment removed, because it does not work with Oleg's firmware.
    Last edited by andi; 26-05-2007 at 15:37. Reason: removed attachment

  7. #22
    Join Date
    May 2007
    Location
    Germany - Stuttgart
    Posts
    20
    Ok, here is my last attempt for now. This time I have compiled the file using different compiler flags and the asus toolchain instead of the OpenWrt SDK. I'll keep my fingers crossed...


    UPDATE: See this post for the module.
    Last edited by andi; 26-05-2007 at 18:57. Reason: buggy attachment removed

  8. #23
    Join Date
    Feb 2005
    Location
    Germany - Frankfurt
    Posts
    1,548
    Hi andi,

    thanks for your help. i am very busy atm. i will test the rtc within the next days.
    Sorry

    wengi

  9. #24
    Join Date
    Feb 2005
    Location
    Germany - Frankfurt
    Posts
    1,548
    Hi andi,

    rtc3 made my day!!!

    this is the rtc part of my post-boot:
    Code:
    # activate RTC. Remove this if not using WL-HDD!
    # remove /dev/rtc with old parameters
    rm /dev/rtc
    # mknod with new parameters
    mknod /dev/rtc c 10 135
    # insert module
    insmod /opt/lib/modules/2.4.20/rtc3.o
    # set time from RTC
    if [ `date +%s` -lt 10000 ]; then
    #we are before Jan 1 1970, 3am, the clock has not been set up
    cat /dev/rtc|(IFS=:;read Y M D dow h m s
    # dow is day of week, 0=sunday
    date $M$D$h$m$Y.$s)
    fi
    and this is my pre-shutdown:
    Code:
    #!/bin/sh
    # write a log line:
    echo "rtc-time is set to `/bin/date '+%Y:%m:%d:%w:%H:%M:%S'`" | logger -t pre-shutdown
    # set time:
    /bin/date +%Y:%m:%d:%w:%H:%M:%S > /dev/rtc
    Thank you so much!

    wengi

  10. #25
    Join Date
    May 2007
    Location
    Germany - Stuttgart
    Posts
    20
    Great! Now, after the module is working, could you please try the attached one. It fixes two bugs. Only one of it is relevant for you: because of a bug in the 12h<->24h calculations, the module produces wrong times from 8pm til 10pm . This time I have tested the module more thoroughly, so I hope its now bug free.

    Please note that the first time you load the module, the driver now puts the RTC into 24h mode. Since it probably was running in 12h mode before, this will result in garbage times when doing this after 12pm. The fix is to run your pre-shutdown script (or 'hwclock --systohc') manually once.

    Sorry for the inconvenience.
    Attached Files Attached Files

  11. #26
    Join Date
    Feb 2005
    Location
    Germany - Frankfurt
    Posts
    1,548
    Its done and working fine
    And the code is exactly 8000 byte. I am going to drink a beer because of this

    Thanks so much

    wengi

  12. #27
    Is there a change to get that WLHDD gives time to dbox by rdate?

    If I do it from dbox rdate <IP_of_WL-HDD> I get an error message.

    rdate seems to be supported by the dbox.

  13. #28
    Join Date
    May 2007
    Location
    Germany - Stuttgart
    Posts
    20
    Is there a change to get that WLHDD gives time to dbox by rdate?
    Theoretically, yes. You need an inetd running which supports the time service. If you don't have inetd on your WL-HDD, you need to recompile busybox with inetd (and the time service) enabled. If you haven't built your system yourself, it might be safer to just create a special busybox binary containing only this daemon instead of replacing the system's busybox.
    Last edited by andi; 08-09-2007 at 18:56.

  14. #29
    Quote Originally Posted by andi View Post
    Theoretically, yes. You need an inetd running which supports the time service.
    Would the inetutils resp. xinetd that comes with ipkg do the task?

    F.

  15. #30
    Join Date
    May 2007
    Location
    Germany - Stuttgart
    Posts
    20
    Quote Originally Posted by fredlcore View Post
    Would the inetutils resp. xinetd that comes with ipkg do the task?
    Yes, of course a standalone (x)inetd will also work. In case of xinetd, the file /etc/xinetd.d/time (or wherever your xinetd has its configuration file(s)) with the following content should do the job:
    Code:
    service time
    {
       type        = INTERNAL
       id          = time-stream
       socket_type = stream
       protocol    = tcp
       user        = root
       wait        = no
       disable     = no
    }

Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. oleg's firmware vs openwrt
    By sophana in forum WL-500g Custom Development
    Replies: 5
    Last Post: 15-07-2005, 17:46
  2. Hoe is filestructuur van OLEG's firmware?
    By newbie in forum Dutch Discussion - Nederlands
    Replies: 4
    Last Post: 24-06-2005, 14:23
  3. Real-time bandwidth use
    By gwl in forum WL-500g Q&A
    Replies: 8
    Last Post: 12-01-2005, 03:16
  4. Flashing Oleg's Firmware in WL HDD
    By hugo in forum WL-HDD Custom Development
    Replies: 29
    Last Post: 21-10-2004, 14:55

Tags for this Thread

Posting Permissions

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