Setting Beagleboard system time from a RTS (DS1307)

Hi All,

OS: Ubuntu 10.10

I have been struggling for some time to understand how to use the
DS1307 connected to my BB.

Currently the BB will set the system time using NTP when connected to
the network, but I want to set the time when not connected to the
network, so I have connected a DS1307 (RTC) via the I2C port.

I can successfully dump the contents of the DS1307 using ‘i2cdump 2
0x68’ so I know the device is working communicating via the I2C port.

I have 2 version of the kernel one with the rts-ds1307 module in-built
to the kernel the other as a loadable module. When I list the /dev I
can see a rts0 device.
When I boot the system (not connected to the network) the system time
seems to be a date when I perhaps built the kernel. When I use the
‘hwclock –r’ command and dump the time from the ds1307 I get 3
different times listed.

Could someone explain how I should be using the ds1307 to set the
system time? Do I need to write a program to read the ds1307 and then
set the system time or can it be set up to do it automatically at boot


There is a configuable option when you enter kernel menuconfig, you
can enable hwclock there when kernel start to boot.

We had developed a customerized i2c RTC device for both beagle board
and pandaboard board, the linux system time works fine when we enable
this build option.