I2C DS1307
From GumstixDocsWiki
The Dallas Semiconductor DS1307 provides real time clock functionality with an I2C interface.
SparkFun makes a breakout board which can easily be connected to the i2c bus on the robostix. DS1307 is a 5v device, and the robostix provides a 5v i2c bus interface.
So, getting the DS1307 connected physically turned out the be quite simple, connect +5, SDA, SCL and Ground from the appropriate connectors on the breakout board to the same pins on the robostix.
I was able to verify that the DS1307 was on the i2c bus by using the i2c program mentioned on the I2C quick start page. The DS1307 is hard coded to be at address 0x68.
Getting the DS1307 to work under linux turned out to be more of a battle. I found this version of a patch that looked like it held some promise, even though it had been rejected. I was able to get it to work on the gumstix with only a couple of minor changes. The [ds1307.patch file has been updated to work with the gumstix.
Integrating the DS1307 with the gumstix
These instructions are designed for the new version of the 2.6.15 version of buildroot and will require minor changes to work with older versions of buildroot.
- Copy the ds1307.patch into the gumstix-buildroot/target/device/Gumstix/basix-connex/kernel-patches directory.
- Edit the file with the name series in the same directory and add an entry onto the end which has ds1307.patch on it.
- Enable I2C as described on the I2C quick start page. You'll also want to enable the DS1307 (once you're in the I2C menu, you'll find the DS1307 under "Miscellaneous I2C Chip support --->". If you edit your linux.config file directly, you'll want to add an entry which says
CONFIG_SENSORS_DS1307=m
ds1307.linux.config is the config file I used.
- Enable HWCLOCK in busybox. This can be done by changing the line in the busybox.config file (also found in gumstix-buildroot/target/device/Gumstix/basix-connex/) from:
# CONFIG_HWCLOCK is not set
to look like:
CONFIG_HWCLOCK=y
- Edit gumstix-buildroot/target/generic/target_skeleton/etc/modules and add
i2c-dev i2c-pxa ds1307
to the end of the file. The version I used can be found in ds1307.busybox.config.
- Rebuild linux and busybox
rm -rf build_arm_nofpu/linux-2.6.15gum/ rm -rf build_arm_nofpu/busybox-1.01/ make
- Copy S10clock into gumstix-buildroot/target/generic/target_skeleton/etc/init.d
After you've downloaded your new file system, you should be able to use a combination of the date and hwclock commands to manipulate the DS1307. Use the date command to set the current date and time. Use "hwclock -w" to set the DS1307 to match the current date and time (set with the date command). Use the "hwclock -r" command to read the time from the DS1307 and "hwclock -s" to set the linux date and time from the DS1307.

