DS1307 r1161
From GumstixDocsWiki
This page shows how to get a DS1307 working under buildroot 1161 (2.6.18gum).
Contents |
Overview
If I am not mistaken, r1161 (2.6.18gum) is the last stable version of buildroot. I gathered different pieces from various places in order to make DS1307 to work on r1161. References are quoted.
I assume:
1) readers have basic understanding how gumstix works 2) a Linux-based system is used as the host 3) buildroot (r1161) is installed at /usr/local/gumstix-buildroot 4) readers have root access on host
I hope this page helps.
Procedure Outline
1) Build your 1st fileimage 2) Add I2C and DS1307 support to the kernel, rebuild 3) Configure your gumstix to support robostix, I2C, and DS1307
Hardware requirements
These are the hardware I used:
connex wifistix robostix tweener (line modified to work with robostix and connex) DS1307 on breakout board from Sparkfun (available from [1])
Hardware preperation
Connect two jumpers on the robostix; the tweener board has been modified.
The RTC should be connected directly to the robostix. Four pins on the RTC are connected to four pins on the robostix:
RTC <---> robostix 5V <---> Atmel I2C V GND <---> Atmel I2C G SCL (serial clock input) <---> Atmel I2C Rx SDA (serial data input/output) <---> Atmel I2C Tx
Prepare the 1st fileimage
On host (i.e. your computer):
$ su $ cd /usr/local $ svn co -r1161 http://svn.gumstix.com/gumstix-buildroot/trunk gumstix-buildroot $ cd gumstix-buildroot $ ln -s ../dl-cache dl $ make menuconfig (select and deselect your own packages, remember to select "modutils" and "uisp") $ make
Update the fileimage with I2C and DS1307 support
Once you have made the 1st file image, on host:
$ cd /usr/local/gumstix-buildroot/build_arm_nofpu/linux-2.6.18gum $ make ARCH=arm menuconfig
Device Drivers --->
I2C support --->
<M> I2C support
<M> I2C device interface
I2C Hardware Bus support --->
<M> Intel PXA2XX I2C adapter (EXPERIMENTAL)
Real Time Clock --->
<M> RTC class
--- RTC interfaces
<M> sysfs
<M> proc
<M> dev
--- RTC drivers
<M> Dallas/Maxim DS1307 and similar I2C RTC chips
$ cd /usr/local/gumstix-buildroot/target/device/Gumstix/basix-connex $ cp linux.config linux.config.orig $ cd - $ cp .config /usr/local/gumstix-buildroot/target/device/Gumstix/basix-connex/linux.config
Note: there is no need to handle the CONFIG_I2C_PXA_SLAVE setting in linux.config.
Next, configure the kernel to include the DS1307 module. First, you need to apply this patch [2]:
Edit "ds1307.patch", replace all "2.6.15" with "2.6.18" $ mv ds1307.patch /usr/local/gumstix-buildroot/target/device/Gumstix/basix-connex/kernel-patches
Add an additional line which contains the words "ds1307.patch" (without the double quotes) to this file: /usr/local/gumstix-buildroot/target/device/Gumstix/basix-connex/kernel-patches/series
Configure busybox: $ cd /usr/local/gumstix-buildroot/target/device/Gumstix/basix-connex $ cp busybox.config busybox.config.orig Edit "busybox.config", change "# CONFIG_HWCLOCK is not set" to "CONFIG_HWCLOCK=y" Make a new fileimage: $ cd /usr/local/gumstix-buildroot $ rm -rf build_arm_nofpu/linux-2.6.18gum/ $ rm -rf build_arm_nofpu/busybox-1.1.2/ $ rm -rf build_arm_nofpu/root/lib/modules/.cf8385 (important for wifistix!) $ rm -rf rootfs.arm_nofpu.jffs2 $ make
If being asked: Dallas Semiconductor DS1307 Real-Time Clock (SENSORS_DS1307) [N/m/?] (NEW) Select "n" (important! Otherwise you will end up with compilation errors) $ du -sh rootfs.arm_nofpu.jffs2 (make sure it's less than 14M bytes)
Now transfer the fileimage to the gumstix
Test the new fileImage
On gumstix, make sure these commands are working:
$ iwconfig (you should see mwlan0) $ uisp -h $ hwclock -h
To configure the modules to be loaded at bootup, edit "/etc/modules" to include:
# I2C and DS1307 support i2c-dev i2c-pxa # RTC support rtc-ds1307 rtc-sysfs rtc-proc rtc-dev rtc-core
You should now setup some form of network connections between your host and your gumstix, we will need to transfer a few executable files from host to gumstix.
$ reboot
Configure gumstix
You will need the following file and executable program on the gumstix:
* S10clock (from [3]) * the i2c program (from [4])
Configure init.d:
$ mv S10clock /etc/init.d $ cd /retc/init.d $ chmod a+rx S10clock
Install the i2c program:
$ mv i2c /bin $ chmod a+rx /bin/i2c
You should now get robostix and I2C running (i.e. the S10robostix and I2C stuff from [5] and [6] respectively)
Test DS1307 via the i2c program
On your gumstix, set the clock to the current time and date (say 15-02-09 Sun 22:25:06):
$ i2c --count=8 0x68 wb 0x0 0x0625220715020900 $ i2c --count=8 0x68 readbyte 0 The format of the string in the "wb" command is: sec:min:hr:weekday:day:month:year:control_byte Note: weekday (7 = Sun, 1 = Mon, 2 = Tues... etc.) The "readbyte" command means "read 8 bytes from addres 0x68", which is the RTC's address on the I2C bus.
Test DS1307 using hwclock
On gumstix, make sure the required modules were loaded at bootup:
$ lsmod | grep rtc_ds1307 Module Size Used by rtc_dev 5224 0 rtc_proc 3556 0 rtc_sysfs 2912 0 rtc_ds1307 5644 0 rtc_core 6836 4 rtc_dev,rtc_proc,rtc_sysfs,rtc_ds1307 i2c_pxa 5984 0 i2c_dev 7492 0 i2c_core 16560 3 rtc_ds1307,i2c_pxa,i2c_dev
On gumstix, configure /dev:
$ cd /dev Either /dev/rtc0 or /dev/rtc should already exist
If neither /dev/rtc0 nor /dev/rtc exit: $ mknod /dev/rtc0 c 10 135 or $ mknod /dev/rtc c 10 135
Create a symbolic link (needed by hwclock): $ ln -s /dev/rtc0 /dev/rtc or $ ln -s /dev/rtc /dev/rtc0
Now update DS1307 using the local system clock:
$ hwclock -r (read DS1307's current time) Mon Feb 16 00:44:41 2009 0.000000 seconds $ hwclock -w (set DS1307 to the local system clock, I would manually set the local system clock to the current time first using the "date" command) $ hwclock -r $ hwclock -s (set the local system clock using DS1307's time)

