How to enable I2C bus?


#1

Hi all,

Recently when I run the mangOH GPIO expander service from GpioExpander, I got this error message in target log:

Jan 6 00:05:41 swi-mdm9x15 user.err Legato: =ERR= | gpioExpanderService[1029]/gpioExpanderCommon T=main | gpioExpander.c I2cAccessBusAddr() 913 | Could not open file /dev/i2c-6 or /dev/i2c/6: No such file or directory
Jan 6 00:05:41 swi-mdm9x15 user.err Legato: =ERR= | gpioExpanderService[1029]/gpioExpanderCommon T=main | gpioExpander.c SmbusWriteReg() 994 | failed to open i2c bus 6 for access to address 63

How can I manage to solve this?


#2

Hi lyao,

The mangOH Green has an i2c switch chip on it. What the chip does is take one upstream i2c bus and then route the signal to a configurable set of the 8 downstream i2c buses. Originally we just turned on all the ports simultaneously when the gpioExpanderService app started. Later we found that this caused some reliability issues at the electrical level. More recently, we have begun building a Linux kernel module to manage the i2c switch rather than controlling it explicitly from userspace. The kernel driver creates virtual i2c buses. So the one primary i2c bus is /dev/i2c-0 and the buses provided by the expander are /dev/i2c-1 through /dev/i2c-8. The gpioExpanderService app was updated to use the virtual buses provided by the kernel module. I suspect that you don’t have the kernel module loaded. Are you building the mangOH Green SDEF or are you trying to build the gpioExpanderService app on its own? You really need to build the SDEF which includes the mangoh kernel module which registers the i2c switch device in the Linux kernel.


#3

Hi dfrey,

I use a WP8548 on a mangOH Green board, and I experience I2c issues when I connect my Renfell I2C/SPI/GPIO/UART IoT card to an Iot slot. The I2c GPIO explanders work fine when there’s no Iot card in the slot.
I assume this is caused by the extra ports on the I2c switch.
I searched in the mangoh github for your changes in the gpioExpanderService app, related to the virtual I2c buses in the kernel module.
I think your commits have been entered on 30/6/2017, but, I can’t build them for legato 16.4.

The .sdef file can’t include another .sdef, and the .mdef files don’t recognize a cflags section and sources section. I think these are legato 17.xx changes, so, they don’t match with my Legato package R15.

Can you give me your advice, please?

greetings,
annaertd


#4

Hi @annaertd,

You will run into issues trying to run current mangOH code on older releases of Legato. I suggest running Legato 18.04.0 unless you have a reason not to.


#5

Hi,

can I run Legato 18.04.0 on our WP8548 targets?

Greetings,
annaertd


#6

It should work with 18.04