1

Using buildroot 2013.05 (with Freescale i.MX6 CPU).

When I change date/time from console, e.g.: date -s "2013-11-26 02:11", this setting will lost during reboot. I'd learned, that I have to call hwclock -wu afterwards.

But what's the way to configure my buildroot-based linux that the hwclock is set automatically after date/time has been changed (regardless if date/time changed from linux console or via libc call from a C program).

Joe
  • 3,090
  • 6
  • 37
  • 55
  • You need a driver to be configured in the linux kernel for this to work. It should be */dev/rtcXX*. Also, this may exist, but if you have not added a coin battery to your design, the *hwclock* may not be powered and it will always loose the clock. The Linux driver will not know that the coin battery is not present. – artless noise Nov 26 '13 at 17:16
  • All these conditions are met. /dev/rtc… exists and all works well as far as I call hwclock manually after modifying the system date/time. I just desire an automatic call of hwclock. – Joe Nov 26 '13 at 23:21
  • Don't use `date -s`, then. Use `hwclock -s --set --date="2013-11-26 02:11"`. So instead of setting things with the `date` command set both with `hwclock`. Or you want the times to be out of sync until a reboot? – artless noise Nov 26 '13 at 23:29

1 Answers1

4

The standard way to handle the hwclock on linux systems is to save the system time to the hardware clock during reboot, and restore it on boot. This is done through init scripts.

So in buildroot, you would add an init script that ends up in /etc/init.d/Sxxhwclock, typically using a rootfs overlay, or alternatively with a completely custom target skeleton.

See http://buildroot.uclibc.org/downloads/manual/manual.html#rootfs-custom for more info on customizing the target rootfs.

  • Thanks, that helps me to understand the standard way. E.g. my Kubuntu (desktop pc) seems to behave that kind of way. But unfortunally, for embedded systems it often is fact, that they got not a clean reboot but just an immediate poweroff (as well as for my project). Looks that I further have to explicity call hwclock. – Joe Nov 26 '13 at 23:23