Adding an Extra i2c bus to an Embedded ARM board running Linux
Usually having access to one i2c bus on your embedded board is enough,
as you can chain lots of devices off of it. But what happens if you
have two devices with the same i2c ID and you can't change that?
Some of my ECE471 students wanted to create a game for their final project
that involved having two Wii nunchuks (i2c id 0x52). This was not possible
with the gumstix board (or with a Raspberry-pi) as both only export one
i2c bus by default.
After looking into things, I managed to eventually get it to work
by setting up a bit-banged GPIO i2c bus on two spare GPIOs.
What I had to do:
- Download and recompile the linux-omap-3.5 kernel from here:
The config I got from the default kernel in /proc/config.gz
but had to enable I2C_GPIO option as a module.
- Install the kernel. make uImage, make modules_install, copy
the uImage to the proper place on /boot
- On the gumstix, hook up GPIO146 (pin 27) and GPIO147 (pin29)
as i2c. This mostly meant running it through a level converter
so the 1.8V output would come out at 5V.
- Getting the i2c-gpio-param code from here:
Pointing the makefile to the kernel tree, compiling
- Installing the driver:
insmod ./i2c-gpio-param.ko sda=146 scl=147
- If all goes well /dev/i2c-7 was created by the above
and i2cdetect -y -7 will show your devices
Picture of my test-case. Both of those LED displays have i2c id 0x70.
One is on the default gumstix i2c-3 bus, one is on the bitbanged
i2c-7 bus made from GPIOs 146 and 147.
Back to VMW Productions Page