DATE/TIME lost after reboot

  • Hi!
    I'm developing an application with Linux and NETDCU10.
    I've detected that after software reboot (or supply disconnection) then time is lost.
    Is the RTC losing the time or I have to read it from the RTC while rebooting? How?


    Thanks.

  • Hello,
    on hardware side you have to enable the backup battery for RTC (DIP1/4=ON)!
    Solves this the problem?

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • No, it doesn't.


    When I type:
    # hwclock --show
    It always shows:
    Thu Jan 1 00:59:59 1970 0.000000 seconds
    It seems like the RTC were stopped
    hwclock command fails when I try to set the time:
    # hwclock --hctosys
    hwclock: settimeofday() failed: Invalid argument


    How can I know that the RTS is really working?


    Thanks.

  • Quote from "jcollazo"

    hwclock command fails when I try to set the time:
    # hwclock --hctosys
    hwclock: settimeofday() failed: Invalid argument


    I am having the same problem, is there any solution yet?


    Patrick

  • I believe it's the other way round. After having set the time/date with the date command, you have to transfer it to the hwclock too, with --systohc. Then during reboot, the system time should automatically be read from the hwclock, you need not have to call hwclock --hctosys yourself.


    So just remember to store the new time also to the hwclock after a change. What I don't know is how this can be achieved when using the automatic time adjustment via ntp. Maybe just copy the system time to the hardware clock in regular intervals.


    Regards,


    H. Keller

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Thanks a lot! That works for me fine:


    Code
    1. # date +%d%m%Y -s "03112009"
    2. # date +%T -s "12:48:30"
    3. # date
    4. Wed Mar 11 12:48:31 UTC 2009
    5. # hwclock --systohc


    After setting the correct system-time and writing it to hwclock, you only need to load the time on system-boot (hwclock --hctosys).


    Regards,
    Patrick

  • Quote from "hwmbabe"

    After setting the correct system-time and writing it to hwclock, you only need to load the time on system-boot (hwclock --hctosys).


    Doesn't the kernel load the system time from the RTC automatically on start-up? Well, ok, this may have changed since I made the linux kernel for NetDCU3 some years ago. But I think it's no big problem to add such a line to the start-up scripts.


    Regards,


    H. Keller

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.