i2c works?

139 views
Skip to first unread message

Bill Gatliff

unread,
Nov 18, 2008, 9:54:41 AM11/18/08
to beagl...@googlegroups.com
Anyone using i2c with the beagleboard? Perhaps from userspace, even?

b.g.
--
Bill Gatliff
bg...@billgatliff.com

fta...@gmail.com

unread,
Nov 19, 2008, 10:13:56 AM11/19/08
to Beagle Board
I've been struggling to get i2c working on the Beagleboard, but I've
recently (about 5 minutes ago) gotten it to work. I have successfully
connected from the Beagleboard i2c-2 to a Gumstix Robostix i2c. I'm
using kernel version 2.6.26-r64, with config options CONFIG_I2C_OMAP
and CONFIG_I2C2_OMAP_BEAGLE turned on. To do the level shifting from
the Beagleboards 1.8v to the Robostix 5.0v, I used a small board that
uses the NXP PCA9306 level translator. On the Beagleboard I connected
to the 2nd i2c bus on the expansion connector (pin 23 for sda, pin 24
for scl, pin 1 for 1.8 volts, pin 27 for ground) and on the Robostix
board I connected to the i2c bus on the UART connector (pin 12 for
sda, pin 16 for scl, pin 14 for 5 volts and pin 10 for ground). Most
(all) of my problems were self inflicted, like connecting to the wrong
pins on both the Beagleboard and the Robostix board.

I used i2cdetect (from i2c-tools-3.0.1-r0) on the Beagleboard to probe
the address bus and the Robostix correctly identified itself as 0xb:

root@beagleboard:~# i2cdetect -ya 2
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- 0b -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

I then used a program called i2c-io (from the Gumstix/Robostix
utilities) to read a Robostix register from the Beagleboard:

root@beagleboard:/usr/local/bin# i2c-io --dev /dev/i2c-2 0xb readreg 0
0x02

frank

On Nov 18, 9:54 am, Bill Gatliff <b...@billgatliff.com> wrote:
> Anyone using i2c with the beagleboard? Perhaps from userspace, even?
>
> b.g.
> --
> Bill Gatliff
> b...@billgatliff.com

Frank Agius

unread,
Nov 19, 2008, 1:39:56 PM11/19/08
to discu...@beagleboard.org
Sorry if this is a duplicate append, but my first try didn't seem to make it.

I have successfully connected from beagleboard userspace to a Gumstix robostix board over i2c.  For hardware interconnect between the two boards, I had built a voltage level translation board, which used the NXP PCA9306.  This was needed to level shift the 1.8 v beagleboard i2c to the 5.0 v i2c on the robostix.  On  the beagleboard I connected to the i2c-2 pins on the expansion connector (pin 1 for 1.8v, pin 23 for sdc, pin 24 for scl, pin 27 for ground).  For the robostix board, I connected to the i2c on the UART header (pin 10 for ground, pin 14 for 5v, pin 12 for sda, pin 16 for scl).  For software, on the begaleboard I used linux kernel 2.6.26-r64, with options CONFIG_I2C_OMAP and CONFIG_I2C2_OMAP_BEAGLE set to yes.  For beagleboard userspace code, I used i2cdetect (from  i2c-tools-3.0.1) and i2c-io (from gumstix-robostix utilities).  The robostix board was running code that understood the api for the i2c-io program.  Here is the output:


root@beagleboard:~# i2cdetect -ya 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- 0b -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

root@beagleboard:~# i2c-io --dev /dev/i2c-2 0xb readreg 0
0x02

regards,

Jack Peacock

unread,
Nov 19, 2008, 6:57:38 PM11/19/08
to beagl...@googlegroups.com
> I have successfully connected from beagleboard userspace to a Gumstix
robostix board over i2c.

Is the OMAP set up as bus master? Does the I2C driver support the OMAP as
bus slave? Our CTO tells me that bus slave mode isn't supported under ARM
Linux so I should not design in the OMAP as an I2C slave for low speed
message passing from a front end processor.

Which begs the question, how do the dual I2C links (power and control)
between the OMAP and TWL4030/TPS65950 work under Linux? Does the I2C driver
handle all the messages, especially when powering down individual domains on
the support chip (and where do the power management messages come from,
somewhere in the kernel)?

The programmers tell me all the power management magically happens in the
background, so their only task is turn the LCD backlight on and off. I am
not so sure the kernel has enough information to manage all those power
domains without some extensive knowledge of the application.
Jack Peacock

fta...@gmail.com

unread,
Nov 20, 2008, 6:48:41 AM11/20/08
to Beagle Board
On Nov 19, 6:57 pm, "Jack Peacock" <jpeac...@fortunet.com> wrote:
> > I have successfully connected from beagleboard userspace to a Gumstix
>
> robostix board over i2c.
>
> Is the OMAP set up as bus master?

In my setup, the OMAP is the master and the Robostix board is the
slave.

> Does the I2C driver support the OMAP as
> bus slave? Our CTO tells me that bus slave mode isn't supported under ARM
> Linux so I should not design in the OMAP as an I2C slave for low speed
> message passing from a front end processor.

I don't see support for slave mode in the OMAP i2C driver. However,
the PXA CPU's (ARM processors) do have a configurable kernel option to
support slave mode communication, so slave mode support is processor
dependent and not architecture dependent.

> Which begs the question, how do the dual I2C links (power and control)
> between the OMAP and TWL4030/TPS65950 work under Linux? Does the I2C driver
> handle all the messages, especially when powering down individual domains on
> the support chip (and where do the power management messages come from,
> somewhere in the kernel)?

Someone who knows the drivers for those chips will have to answer
those questions.

frank agius

James Chen ???

unread,
Nov 20, 2008, 7:04:07 AM11/20/08
to beagl...@googlegroups.com
Hi ftagius:

Did you use the Expansion connect as your I2C interface?

How did you setup it.

Can you give me a example?

Thanks

fta...@gmail.com

unread,
Nov 20, 2008, 11:00:51 AM11/20/08
to Beagle Board
On Nov 20, 7:04 am, "James Chen ???" <james....@msa.hinet.net> wrote:
> Hi ftagius:
>
> Did you use the Expansion connect as your I2C interface?

Yes, I used the expansion connector on the Beagleboard to access the
second i2c bus (i2c-2)

>
> How did you setup it.
>

I had built a voltage level translation board, which used the NXP
PCA9306. The circuit is the same as show in Figure 9, page 9 of the
PCA9306 datasheet (http://www.nxp.com/acrobat_download/datasheets/
PCA9306_3.pdf).
On the beagleboard I connected to the i2c-2 pins on the expansion
connector (pin 1 for 1.8v, pin 23 for sdc, pin 24 for scl, pin 27 for
ground). For the robostix board, I connected to the i2c on the UART
header (pin 10 for ground, pin 14 for 5v, pin 12 for sda, pin 16 for
scl).

> Can you give me a example?

An example of what?

frank agius

John Stowers

unread,
Nov 23, 2008, 7:42:29 AM11/23/08
to beagl...@googlegroups.com, fta...@gmail.com
On Wed, Nov 19, 2008 at 7:39 PM, Frank Agius <fta...@gmail.com> wrote:
Sorry if this is a duplicate append, but my first try didn't seem to make it.

I have successfully connected from beagleboard userspace to a Gumstix robostix board over i2c.  For hardware interconnect between the two boards, I had built a voltage level translation board, which used the NXP PCA9306.  This was needed to level shift the 1.8 v beagleboard i2c to the 5.0 v i2c on the robostix.  On  the beagleboard I connected to the i2c-2 pins on the expansion connector (pin 1 for 1.8v, pin 23 for sdc, pin 24 for scl, pin 27 for ground).  For the robostix board, I connected to the i2c on the UART header (pin 10 for ground, pin 14 for 5v, pin 12 for sda, pin 16 for scl).  For software, on the begaleboard I used linux kernel 2.6.26-r64, with options CONFIG_I2C_OMAP and CONFIG_I2C2_OMAP_BEAGLE set to yes.  For beagleboard userspace code, I used i2cdetect (from  i2c-tools-3.0.1) and i2c-io (from gumstix-robostix utilities).  The robostix board was running code that understood the api for the i2c-io program.  Here is the output:

Hi,

When attempting to recreate this (using linux-omap2, 2.6.26-r64)  I get the following error printed to the console

i2c_omap i2c_omap.2: controller timed out

I suspect this might have something to do with not setting the pin mux for the expansion header correctly. Do you have to do anything else, like explicitly set the pin mux to something?

According to http://www.hy-research.com/omap3_pinmux.html I might need to call omap_cfg_reg with something like

AF15_34XX_I2C2_SCL,
AE15_34XX_I2C2_SDA,

But this is unusual if you did not have to do this. Alternatively, what version of UBoot are you running, as it may also be involved in setting the pin mux to an initial state.

Regards

John

fta...@gmail.com

unread,
Nov 23, 2008, 7:44:19 PM11/23/08
to Beagle Board


> Hi,
>
> When attempting to recreate this (using linux-omap2, 2.6.26-r64) I get the
> following error printed to the console
>
> i2c_omap i2c_omap.2: controller timed out
>
> I suspect this might have something to do with not setting the pin mux for
> the expansion header correctly. Do you have to do anything else, like
> explicitly set the pin mux to something?
>

John,

If you enable I2C2_OMAP_BEAGLE, you need to connect something that has
pullups to the i2c2 pins or you will get timeout messages. From the
help for kernel config I2C2_OMAP_BEAGLE:

Say Y here if you want to enable I2C bus 2 at OMAP3 based
BeagleBoard. I2C2 at BeagleBoard is connected to expansion
connector, i.e. unused
if nothing is connected to this connector. As internal OMAP3 pull up
resistors are not strong enough, enabled but unused I2C2 bus results
in error messages (e.g. I2C timeouts). Enable this only if you have
something connected to I2C2 at board's expansion connector and this
extension has additional pull up resistors for I2C2 bus.

frank agius

John Stowers

unread,
Nov 24, 2008, 9:48:57 AM11/24/08
to beagl...@googlegroups.com

Yeah, I got it working now.

Thanks
 


frank agius



Reply all
Reply to author
Forward
0 new messages