Transferred from: http://os.chinaunix.net/a2008/0526/981/000000981211.shtml
These two days have been doing an i²c device driven understanding, so rarely updated articles.
Because the RTC hardware clock is very important for the meter, and its precision design requirements are high, in BusyBox, the current system time can be set through the Date command, and then the current system time is written to the hardware clock by Hwclock. But BusyBox's date command has a flaw, which is not accurate to the second, which is not tolerated in our design, here we feel that the open source is very good for us.
To modify the Buxybox coreutils/date.c file:
Static struct TM *date_conv_time (struct TM *tm_time, const char *t_string)
{
int nr;
Char *CP;
NR = sscanf (t_string, "%2d%2d%2d%2d%2d%d", & (Tm_time->tm_mon),
& (Tm_time->tm_mday), & (Tm_time->tm_hour), & (Tm_time->tm_min),& (tm_time->tm_sec),
& (Tm_time->tm_year));
if (nr 6) {
Bb_error_msg_and_die (Bb_msg_invalid_date, t_string);
}
Make the above function as modified as above, then you can be accurate to the second!
The format is date followed by the month of the year
Note that the year is 4 years, for example: October 26, 2007 10:00:30
Date 10261000302007
Then use Hwclock-w to write the current system time into the RTC hardware clock!!
RTC Hardware Clock Settings Modify "Go"