OpenWrt Forum Archive

Topic: I2C bus, GPIO based, on ar71xx (TP-Link 1043ND)

The content of this topic has been archived on 19 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I'm trying to run GPIO based I2C bus on TP-Link 1043ND (ar71xx).

Went through wiki, soldered mentioned pins in, pull-up resistors. Hardware is good for sure.
Wiki is mentioning some problems with software "Unfortunately the precompiled packages don't seem to work properly, so building from sources is most likely necessary.". I guess I'm dealing with this problem.

My problem is that i can't see my /dev/i2c in the system. I've detached QSS led (GPIO line 5).

root@OpenWrt:~# opkg list_installed |grep i2c
i2c-tools - 3.0.3-1
kmod-i2c-algo-pca - 2.6.32.27-1
kmod-i2c-algo-pcf - 2.6.32.27-1
kmod-i2c-core - 2.6.32.27-1
kmod-i2c-gpio - 2.6.32.27-1
kmod-i2c-gpio-custom - 2.6.32.27-2


root@OpenWrt:~# lsmod |grep i2c
i2c_gpio                1520  0
i2c_algo_pcf            4192  0
i2c_algo_pca            5232  0

For some reason I can't build kmod-i2c-algo-bit.

Any ideas what might be wrong?


Thanks, Andrzej

I2C works fine on my TP-Link 1043ND.

Did you call

insmod i2c-gpio-custom bus0=0,5,20

as mentioned in the Wiki ? According to your lsmod output you did not !

The i2c device becomes only available when this module is loaded.
It is not loaded automatically, you have to use insmod or adapt /etc/modules* settings !

You're right, I got this lsmod result before insmodding. But it's not the case.
Now I got it configured in /etc/modules.d/66-i2c-gpio-custom that contains

i2c-gpio-custom bus0=0,5,20

so it loads at startup.

When booting up, in dmesg I get

i2c /dev entries driver
drivers/i2c/i2c-dev.c: Driver Initialisation failed
i2c-gpio: probe of i2c-gpio.0 failed with error -16

I removed kmod-leds-gpio, kmod-input-gpio-buttons just to be sure that nothing else is taking control of GPIOs.

What Openwrt version do you use? Did you build it yourself or is it regular binary file that you downloaded?

Could you send me results of your routers' opkg list_installed |grep i2c and lsmod |grep i2c?

(Last edited by rycerstwo on 3 Jan 2012, 14:59)

Currently I have no acces to my router, maybe later in the evening.

I'm using the trunk version and my last build I did was about at the end of 11/2011.
As far as I can remember I only went through the wiki step by step and I disabled kmod-leds-gpio & kmod-input-gpio-buttons in my configuration (.config).

Still no success.

I compiled openwrt with all parameters shown in wiki kept precisely.

Still get:

i2c /dev entries driver
Custom GPIO-based I2C driver version 0.1.1
i2c-gpio: probe of i2c-gpio.0 failed with error -16

I'm trying to figure out whether the qss led resource is busy.

I do

root@OpenWrt:/# echo 5 > /sys/class/gpio/export
ash: write error: Device or resource busy

GPIO5 being QSS LED in TP-Link.

Have you done that too?

Some of my  output:

BusyBox v1.19.3 (2011-11-13 00:17:45 CET) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 ATTITUDE ADJUSTMENT (bleeding edge, r28993) ----------



root@tplink:~# lsmod |grep i2c
i2c_gpio_custom          800  0 
i2c_dev                 4016  0 
root@tplink:~# lsmod |grep gpio
i2c_gpio_custom          800  0 
gpio_keys_polled        2080  0 
input_polldev           2064  1 gpio_keys_polled
input_core             19824  8 uvcvideo,usbhid,hid,evdev,button_hotplug,gpio_keys_polled,input_polldev

root@tplink:~# dmesg
[...]
input: gpio-keys-polled as /devices/platform/gpio-keys-polled/input/input0
Button Hotplug driver version 0.4.1
[...]
i2c /dev entries driver
[...]
Custom GPIO-based I2C driver version 0.1.1
i2c-gpio i2c-gpio.0: using pins 5 (SDA) and 20 (SCL)
[...]

my cfg

# 
# I2C support
# 
CONFIG_PACKAGE_kmod-i2c-core=y
CONFIG_PACKAGE_kmod-i2c-algo-bit=y
# CONFIG_PACKAGE_kmod-i2c-algo-pca is not set
# CONFIG_PACKAGE_kmod-i2c-algo-pcf is not set
CONFIG_PACKAGE_kmod-i2c-gpio=y
CONFIG_PACKAGE_kmod-i2c-gpio-custom=y
# CONFIG_PACKAGE_kmod-i2c-mux is not set
# CONFIG_PACKAGE_kmod-i2c-tiny-usb is not set
# CONFIG_PACKAGE_kmod-pca953x is not set
CONFIG_PACKAGE_kmod-pcf857x=y

# 
# LED modules
# 
CONFIG_PACKAGE_kmod-leds-gpio=m

Problem solved!

The only difference that I've had is

CONFIG_PACKAGE_kmod-leds-gpio=y

instead of

CONFIG_PACKAGE_kmod-leds-gpio=m

It wasn't helping when I was removing kmod-leds-gpio package that has been built in .bin file.

Now directly after insmod I get

i2c /dev entries driver
Custom GPIO-based I2C driver version 0.1.1
i2c-gpio i2c-gpio.0: using pins 5 (SDA) and 20 (SCL)

in dmesg.

Problem solved, thank you.

I just encountered the same problem on a TP-Link TL-WR740N. But I did not want to build my own firmware just yet. So I tried around some more and with these, you can also use the I2C without building your own:

rmmod gpio_button_hotplug
rmmod leds-gpio
rmmod ledtrig_default_on
rmmod ledtrig_timer

After that, you just do:

insmod i2c-gpio-custom bus0=0,1,13

(I am using those GPIOs since they are bootstrapped high and thus already have pullups!)

And get the I2C working:

root@OpenWrt:/etc# dmesg |grep i2c
[   13.240000] i2c /dev entries driver
[ 1094.520000] i2c-gpio i2c-gpio.0: using pins 1 (SDA) and 13 (SCL)

(Last edited by locutus on 3 Aug 2013, 18:43)

locutus wrote:

I just encountered the same problem on a TP-Link TL-WR740N. But I did not want to build my own firmware just yet. So I tried around some more and with these, you can also use the I2C without building your own:

rmmod gpio_button_hotplug
rmmod leds-gpio
rmmod ledtrig_default_on
rmmod ledtrig_timer

After that, you just do:

insmod i2c-gpio-custom bus0=0,1,13

(I am using those GPIOs since they are bootstrapped high and thus already have pullups!)

And get the I2C working:

root@OpenWrt:/etc# dmesg |grep i2c
[   13.240000] i2c /dev entries driver
[ 1094.520000] i2c-gpio i2c-gpio.0: using pins 1 (SDA) and 13 (SCL)

type command rmmod leds-gpio on my tplink wr740n not work

 root@OpenWrt:~# rmmod leds-gpio
kmod: module is not loaded

please help me mod LED lan to create I2C!

(Last edited by hoatienii on 31 Jul 2015, 04:54)

The discussion might have continued from here.