OpenWrt Forum Archive

Topic: i2c help needed for Lafonera

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

Hello,

I didn't explained myself correctly. After "make kernel_menuconfig" I actually ran "make" but the problem is that I still don't have the .o files in the "trunk/build_dir/linux-atheros/linux-2.6.37.6/drivers/gpio" directory.

If the use of GPIOLIB is already enabled by the patch, could it be the case that things are actually compiled without .o files?

Thanks,
Jabss

No, .o files are the result of a successful compilation of the source files, and get later packed together as .ko (loadable modules) or straight into the kernel binary. I will see if I can try compiling it tomorrow, see how it goes.

Well, I built it, it successfully compiled pcf857x and gpiolib. Here is the full buildlog: http://ul.to/n03b5092
In menuconfig I selected the atheros target and in kernel modules > I2C the i2c-gpio-custom and pcf857x.

Hello again,

I've set up everything from scratch. Now, make kernel_menuconfig behaves differently (now I see it downloads some stuff with wget - This wasn't showing before so I believed it was in background). However, it's so different that it doesn't work now... :'(

jabss@blackpearl:/mnt/storage/OpenWrt/trunk$ make kernel_menuconfig
make[1]: Entering directory `/mnt/storage/OpenWrt/trunk/target/linux'
make[2]: Entering directory `/mnt/storage/OpenWrt/trunk/target/linux/atheros'
if [ -s "/mnt/storage/OpenWrt/trunk/build_dir/linux-atheros/linux-2.6.37.6/patches/series" ]; then (cd "/mnt/storage/OpenWrt/trunk/build_dir/linux-atheros/linux-2.6.37.6"; if quilt --quiltrc=- next >/dev/null 2>&1; then quilt --quiltrc=- push -a; else quilt --quiltrc=- top >/dev/null 2>&1; fi ); fi
make[2]: *** [/mnt/storage/OpenWrt/trunk/build_dir/linux-atheros/linux-2.6.37.6/.quilt_checked] Error 127
make[2]: Leaving directory `/mnt/storage/OpenWrt/trunk/target/linux/atheros'
make[1]: *** [menuconfig] Error 2
make[1]: Leaving directory `/mnt/storage/OpenWrt/trunk/target/linux'
make: *** [kernel_menuconfig] Error 2
jabss@blackpearl:/mnt/storage/OpenWrt/trunk$

Anyway, my history of commands:

  557  cd OpenWrt/
  559  svn co svn://svn.openwrt.org/openwrt/trunk/
  560  cd trunk
  561  ./scripts/feeds update -a
  562  ./scripts/feeds install -a
 ...  # Looking for the files where the patch would be applied (example: arch/mips/Kconfig), but I didn't find it (maybe are only created after?)
 ... # Applied the patch anyway:
  602 patch -p1 < OpenWrt-Devel-Move-atheros-platforms-to-sysfs-style-gpio.patch
  604  make kernel_menuconfig  # returned the above error - maybe a problem with the SVN version?
  605  svn update # no update needed
  606  make kernel_menuconfig # still the same error
  610  make defconfig
  611  make prereq
  612  make menuconfig
  613  make kernel_menuconfig # still the same error. I'll try "make" anyway
  614  make -j 3

I'll leave it compiling through the night and will post the results tomorrow.
So far, do you see anything I could have done wrong? (maybe I should have applied the patch in a different step?)

Thanks,
Jabss

forget about the feeds for the moment, and just follow my buildlog. Also post your full buildlog all the way from the beginning.

Hello,

After a walk trough the image compiling garden, here we are back to the real HW hacking :-)

I build a new environment and followed your instructions. I can now see the pcf857x.o and gpiolib.o in the trunk/build_dir/linux-atheros/linux-2.6.37.6/drivers/gpio directory, so I can say I successfully compiled the image with your tremendous help. Now I have flashed into the fonera and things seem to be on the right track.

However, something is still missing, as I can't find the /sys/class/gpio files that should be created by the "echo pcf8574 0x38 > /sys/bus/i2c/devices/i2c-0/new_device" command:

root@OpenWrt:/# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@OpenWrt:/#
root@OpenWrt:/# echo pcf8574 0x38 > /sys/bus/i2c/devices/i2c-0/new_device
pcf857x 0-0038: gpios 248..255 on a pcf8574
i2c i2c-0: new_device: Instantiated device pcf8574 at 0x38
root@OpenWrt:/#
root@OpenWrt:/dev# dmesg | tail
NET: Registered protocol family 24
nf_conntrack version 0.5.0 (211 buckets, 844 max)
i2c /dev entries driver
Custom GPIO-based I2C driver version 0.1.1
i2c-gpio i2c-gpio.0: using pins 4 (SDA) and 3 (SCL)
device eth0 entered promiscuous mode
br-lan: port 1(eth0) entering forwarding state
br-lan: port 1(eth0) entering forwarding state
pcf857x 0-0038: gpios 248..255 on a pcf8574
i2c i2c-0: new_device: Instantiated device pcf8574 at 0x38
root@OpenWrt:/dev#

... # looks good! let's check the files to control the PCF bits: 

root@OpenWrt:/sys/class/gpiodev# cd gpio/
root@OpenWrt:/sys/devices/virtual/gpiodev/gpio# ls
dev        subsystem  uevent
root@OpenWrt:/sys/class# cd i2c-dev/
root@OpenWrt:/sys/class/i2c-dev# ls
i2c-0
root@OpenWrt:/sys/class/i2c-dev# cd i2c-0/
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/i2c-dev/i2c-0# ls
dev        device     name       subsystem  uevent
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/i2c-dev/i2c-0# cd device/
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0# ls
0-0038         delete_device  i2c-dev        name           new_device     subsystem      uevent
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0# cd i2c-dev/
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/i2c-dev# ls
i2c-0
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/i2c-dev# cd i2c-0/
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/i2c-dev/i2c-0# ls
dev        device     name       subsystem  uevent
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/i2c-dev/i2c-0# cd ..
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/i2c-dev# cd..
/bin/ash: cd..: not found
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/i2c-dev# cd ..
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0# ls
0-0038         delete_device  i2c-dev        name           new_device     subsystem      uevent
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0# cd 0-0038/
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/0-0038# ls
driver     modalias   name       subsystem  uevent
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/0-0038# cat name
pcf8574
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/0-0038#

... # Nooop. Couldn't find it, Maybe anything missing?

root@OpenWrt:/sys/class# lsmod | grep -i gpio
i2c_gpio                1328  0
i2c_gpio_custom          800  0
i2c_algo_bit            4128  1 i2c_gpio
i2c_core               11904  4 i2c_gpio,i2c_algo_bit,pcf857x,i2c_dev
root@OpenWrt:/sys/class# lsmod | grep -i i2c
i2c_gpio                1328  0
i2c_gpio_custom          800  0
i2c_algo_bit            4128  1 i2c_gpio
i2c_dev                 4000  0
i2c_core               11904  4 i2c_gpio,i2c_algo_bit,pcf857x,i2c_dev
root@OpenWrt:/sys/class# opkg list-installed | grep i2c
i2c-tools - 3.0.3-1
kmod-i2c-algo-bit - 2.6.37.6-1
kmod-i2c-core - 2.6.37.6-1
kmod-i2c-gpio - 2.6.37.6-1
kmod-i2c-gpio-custom - 2.6.37.6-2
root@OpenWrt:/sys/class# opkg list-installed | grep gpio
gpioctl - 1.0-1
kmod-i2c-gpio - 2.6.37.6-1
kmod-i2c-gpio-custom - 2.6.37.6-2
root@OpenWrt:/sys/class#

Any idea?

Thanks!
Jabss

(Last edited by jabss on 11 Nov 2011, 01:32)

I would expect a directory called /sys/class/gpio/ to be existing. please do a ls -R inside /sys/. Otherwise you may ask the patch author how the gpiodevices are supposed to appear. There should be another one of your soc.

Hello,

ITS WORKING!

There was a special parameter that it was mandatory in the "make kernel_menuconfig". Something like "include /sys/class" - now it's obvious :-)
There is some unstability in the I2C bus, that I'll still need to troubleshoot (frequently the PCF address cames wrong), but that will be the easy part.

Now, in order to resume all the help I got from MBS and Karl (the GPIO patch developer), I'll post here a list of actions to get this working, so all the community could use it as a reference:

1 - Prepare the HW - Mainly based on http://code.google.com/p/fonera-i2c/wiki/FoneraHacks
1.1 - Identify GPIO lines
http://www.est.ipcb.pt/pessoais/alexand … inouts.jpg
1.2 - "Remove caps" - actualy means to take out the capacitors of each GPIO line. Not so obvious for the non-native speakers - took me a while to understand that.
1.3 - Build the circuit with the PCF8475. I followed MBS's suggestion to use a level-shifter with a mosfet (like 2N7000). Page 10 of http://ics.nxp.com/support/documents/in … n97055.pdf shows how to do it.

2. Preparing the SW
2.1 - Create the openwrt build environment
http://wiki.openwrt.org/doc/howto/buildroot.exigence

2.2 - Build the images
http://wiki.openwrt.org/doc/howto/build
Special tips:
GPIO Patch is needed. Download it from http://patchwork.openwrt.org/patch/1452/ and apply with "patch -p1 < /tmp/patchfile.diff" command.
When running "make menuconfig" search for the I2c and GPIO options (within the Kernel modules section) select them with asterisk " * ", because with "M" will only build a package to be installed after.
Run "make kernel_menuconfig" and make sure the GPIO options are selected (drivers->gpio) and the "/sys/class" - very important!
Compiling will take a couple of hours

3 - Flash the fonera with the images
http://wiki.openwrt.org/toh/fon/fonera

4 - Configure I2C/GPIO stuff
4.1 - I2C part
#echo i2c-gpio-custom bus0=0,4,3 > /etc/modules.d/58-i2c-gpio-custom
(this example configures gpio pin 3 as SCLK and pin 4 as SDA, but anything else can be choosed according to the available pins)

Reboot and probe I2C bus:

root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/0-003f/gpio/gpio251# cd
root@OpenWrt:~# i2cdetect -l
i2c-0   i2c             i2c-gpio0                               I2C adapter

(we have a I2C bus - Let's see what is inside)

root@OpenWrt:~# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3f
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@OpenWrt:~#
(when putting all the address pins at "1" in the PCF8574, its address becomes 3F. That's correct!)

At this stage it should be possible to set the pins of the PCF chip with the I2Cset command (didn't try if its possible to read - i2cget - but it should work fine as well).
However, the value to send to it is from 0 to 255, which will allways impact all the bits of the chip. If you need to change bit by bit, continue reading :-)

4.2. - I2C as GPIO
Given the address of the PCF chip (in my case 3f), issue the following command:
#echo pcf8574 0x3F > /sys/bus/i2c/devices/i2c-0/new_device

This will create a directory called "/sys/class/gpio/gpiochip0".
Now, check dmesg and search for something similar to "pcf857x 0-003f: gpios 248..255 on a pcf8574"
The 248...255 is the important part!  Immagine that somehow the system attributed a "virtual independent GPIO" for each bit of the PCF8574, and their addresses are in the 248...255 range. But how can we use it? Simple. For each "virtual independent GPIO" issue the command like "echo 248 > /sys/class/gpio/export". This is the example for port 248. You need to repeat the command for each other GPIO 248, 249, 250... until 255

By issuing these commands, one directory will be created for each pin. Each directory will have a couple of files that, when changed, will change the status of the pins.

root@OpenWrt:/sys/class/gpio# ls /sys/class/gpio/
export       gpio248      gpio249      gpio250      gpio251      gpiochip0    gpiochip248  unexport
root@OpenWrt:/sys/class/gpio# ls /sys/class/gpio/gpio248/
active_low  device      direction   edge        subsystem   uevent      value
root@OpenWrt:/sys/class/gpio#

From this point onwards it should be easy. I'll give a quick example:
Check the direction of the pins (input, output):
#cat direction

Change the direction of the pins:
#echo out > direction
or
#echo in > direction

If set to "out", you can change the status of the pin with:
#echo 1 > vaule
or
#echo 0 > vaule

If set to "in", you can read the status of the pin with:
#cat value

And that's it. With these steps you should be have it working in much less time than I did :-)

BTW, keep in mind that the chapter 4.2 needs to be re-done in every reboot of the fonera, so it should be a good idea to have implemented it in scripts.

Thanks MBS and Karl (the GPIO patch developer) for all of your tremendous support and extreme patience! ;-)

Jabss

Now the next step will be in adding 1-Wire interface to the fonera! :-D
I'll use the fonera to read the temperature via a DS18B20 (1-wire interface) and to turn on/off heaters and fans with the PCF8574 (I2C) through a power circuit.

(Last edited by jabss on 13 Nov 2011, 02:04)

Sweet - after all. I didn't expect that this patch wouldn't cover the gpio in sysfs stuff. The easiest way to do that is adding the line "CONFIG_GPIO_SYSFS=y" to the file config-2.6.37 in target/linux/atheros. Would you inform Karl about that?
Actually, there are even nice i2c temperature sensors supported by late kernels. ADT7410 for example - although it can just be configured in kernel-menuconfig at the moment.

BTW: some of the links you mentioned are a bit messed up. Please edit them.

MBS: He knows smile  I found out when I tried rebuilding this from scratch on a different computer to test it out for João.  I'll be trying to update the patch this week.  Now that it's had someone else test it, it should be easier to get it applied permanently.

Cheers,
Karl P

By the way, I took the next step in my project: I added a PCF8591 (I2C ADC/DAC converter) to the I2C BUS.

It was surprisingly easy. Just monted the circuit from " http://www.tau.ac.il/~stoledo/lego/i2c-8591-lis3l02as4/ " and it worked with the standard I2C commands:

root@OpenWrt:/# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

# The chip is identified in address 48. Let's send an address byte 
# 0x90 = 1001 (fixed address) + 0000 (configurable address) + 0 ( R/W bit)

root@OpenWrt:/# i2cset -y 0 0x48 0x90

# Now we need to send a control byte:
# 0x00 = 0 (DAC output disabled) + 00 (four single analog inputs) + 0 (fixed) + 0 (auto-increment disabled) + 00 (channel 0)
# the datasheet has all the info

root@OpenWrt:/# i2cset -y 0 0x48 0x00

# now let's check the value. Due to ADC internal clock, it's needed to "ask" the value twice

root@OpenWrt:/# i2cget -y 0 0x48
0x0c
root@OpenWrt:/# i2cget -y 0 0x48
0x09
root@OpenWrt:/#

Hope someone find this usefull. This can be used for adding some physical sensors to the router like, for instance, a LM35 temperature sensor. In my case, I'll use a current sensor in order to know when the resistor of an electrical boiler is on and will publish it on the router webpage.

Cheers,
Jabss

(Last edited by jabss on 27 Nov 2011, 02:41)

There is also a driver for pcf8591 in the kernel. Unfortunately not yet in openwrt, so you need to go the make kernel_menuconfig way. Find it in drivers > hwmon. I haven't done this yet, so don't know what will appear.

I have been following this thread with some iterest.
Thanks to MBS, jabss and others for a great how to get this i2c going.


To keep it short:
I have prototyped a DS1621 as a closed loop temperature controller on a Airlink AR430 (ar2317 as a test bed) using the i2c GPIO interface work you have contributed.
I have used the Tout pin to drive an optocoupler and fan.
Using the T high and T low setpoints allows for tuning the temperature and range of hysterysis.
This can be set up and run autonomous removing any cpu load once configured.


If any one wants I will give details in a separate post.

thanks
~john

nice one. looks like a little brother of the adt7410 (which has a kernel driver, that is currently in staging).

I got i2c working on the Meraki Mini (which is basically the same hardware). I was never able to include the i2c-gpio but just including the header file in my project has worked well for some time. But definitely this is a lot cleaner if you just need to config the kernel.

Anybody realized that Karls patch got into trunk during the last days? So no need for compiling any more, just download a snapshot image will work quite well.

MBS wrote:

Anybody realized that Karls patch got into trunk during the last days? So no need for compiling any more, just download a snapshot image will work quite well.

Would it be included in Backfire 10.03.1 final ?

I'm trying the procedure again (compiling from trunk, but without applying the patch) but can't have it working. Maybe I'll try backfire 10.03.1 final...

The thing is that even choosing all the I2C modules from menuconfig and including the /sys/class from kernel_menuconfig I only get 2 modules installed in the image. Then I try to install all the missing packages from the server where I have compiled but reach a dependency that I cannot solve.... Kernel-3.3.8-1-3ce16ba1a832aa4aaace48620d7e9b54.


root@OpenWrt:/# lsmod  | grep i2c
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/# opkg list-installed | grep i2c
i2c-tools - 3.0.3-1
kmod-i2c-gpio-custom - 3.3.8-2
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/# wget http://192.168.2.10/kmod-i2c-core_3.3.8-1_atheros.ipk
Connecting to 192.168.2.10 (192.168.2.10:80)
kmod-i2c-core_3.3.8- 100% |*******************************|   736   0:00:00 ETA
root@OpenWrt:/# opkg install kmod-i2c-core_3.3.8-1_atheros.ipk
Installing kmod-i2c-core (3.3.8-1) to root...
Configuring kmod-i2c-core.
root@OpenWrt:/#
root@OpenWrt:/# wget http://192.168.2.10/kmod-i2c-gpio-custom_3.3.8-2_atheros.ipk
Connecting to 192.168.2.10 (192.168.2.10:80)
kmod-i2c-gpio-custom 100% |*******************************|  2519   0:00:00 ETA
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/# opkg install kmod-i2c-gpio-custom_3.3.8-2_atheros.ipk
Installing kmod-i2c-gpio-custom (3.3.8-2) to root...
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-i2c-gpio-custom:
 *      kmod-i2c-gpio *
 * opkg_install_cmd: Cannot install package kmod-i2c-gpio-custom.
root@OpenWrt:/# wget http://192.168.2.10/kmod-i2c-mux-gpio_3.3.8-1_atheros.ipk
Connecting to 192.168.2.10 (192.168.2.10:80)
kmod-i2c-mux-gpio_3. 100% |*******************************|  2919   0:00:00 ETA
root@OpenWrt:/# opkg install kmod-i2c-mux-gpio_3.3.8-1_atheros.ipk
Installing kmod-i2c-mux-gpio (3.3.8-1) to root...
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-i2c-mux-gpio:
 *      kmod-i2c-mux *
 * opkg_install_cmd: Cannot install package kmod-i2c-mux-gpio.
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/# wget http://192.168.2.10/kmod-i2c-mux_3.3.8-1_atheros.ipk
Connecting to 192.168.2.10 (192.168.2.10:80)
kmod-i2c-mux_3.3.8-1 100% |*******************************|  2411   0:00:00 ETA
root@OpenWrt:/# opkg install kmod-i2c-mux_3.3.8-1_atheros.ipk
Installing kmod-i2c-mux (3.3.8-1) to root...
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-i2c-mux:
 *      kernel (= 3.3.8-1-3ce16ba1a832aa4aaace48620d7e9b54) *
 * opkg_install_cmd: Cannot install package kmod-i2c-mux.
root@OpenWrt:/#

Any ideia?

Thanks in advance,
Jabss

it got removed in r32855. one quick and dirty way to get around this would be to check out r32854.

Hi,

How can I do that? I've been doing

make dirclean
svn co -r r32854 svn://svn.openwrt.org/openwrt/packages
make kernel_menuconfig
make menuconfig
make &

and I'm always getting the

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

What am I doing wrong?

Thanks,
Jabss

(Last edited by jabss on 3 Aug 2012, 15:52)

jabss wrote:
svn co -r r32854 svn://svn.openwrt.org/openwrt/packages

Thats the wrong url. Actually, you would not even need to mention a url, svn should know it already. Anyway, as I mentioned on your other thread that day, the i2c-gpio stuff got back in. So svn up would be all you need to do.

Ok,

So if I understand correctly, the latest from trunk should have the missing I2C/GPIO stuff as well as Karl's patch. With the correct choices from menuconfig, should be ready to fly, I assume smile.
I'll update my build environment to the latest trunk and will compile it during the night.

But by the way, just to learn something new, what would be the correct way for downloading a old release from trunk ?

Thanks,
Jabss

Basically what you tried, just with the correct url for trunk: svn://svn.openwrt.org/openwrt/trunk/

Or this way (from http://wiki.openwrt.org/doc/howto/buildroot.exigence): svn co svn://svn.openwrt.org/openwrt/trunk/@<rev#>

(Last edited by MBS on 3 Aug 2012, 23:52)

Hi again,

It seems trunk (r32956) is broken for I2C.

root@OpenWrt:~# opkg list-installed | grep i2c
i2c-tools - 3.0.3-1
kmod-i2c-algo-bit - 3.3.8-1
kmod-i2c-gpio - 3.3.8-1
kmod-i2c-gpio-custom - 3.3.8-2
root@OpenWrt:~# wget http://192.168.2.10/packages/kmod-i2c-core_3.3.8-1_atheros.ipk
Connecting to 192.168.2.10 (192.168.2.10:80)
kmod-i2c-core_3.3.8- 100% |*******************************|   733   0:00:00 ETA
root@OpenWrt:~# opkg install kmod-i2c-core_3.3.8-1_atheros.ipk
Installing kmod-i2c-core (3.3.8-1) to root...
Configuring kmod-i2c-core.
echo i2c-gpio-custom bus0=0,4,3 > /etc/modules.d/58-i2c-gpio-custom
root@OpenWrt:~# reboot
(...)
root@OpenWrt:~# opkg list-installed | grep i2c
i2c-tools - 3.0.3-1
kmod-i2c-algo-bit - 3.3.8-1
kmod-i2c-core - 3.3.8-1
kmod-i2c-gpio - 3.3.8-1
kmod-i2c-gpio-custom - 3.3.8-2
root@OpenWrt:~# lsmod | grep i2c
i2c_gpio                1328  0
i2c_gpio_custom          800  0
i2c_algo_bit            5840  1 i2c_gpio
root@OpenWrt:~# cat /etc/modules.d/58-i2c-gpio-custom
i2c-gpio-custom bus0=0,4,3
root@OpenWrt:~# cat /etc/banner
  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 ATTITUDE ADJUSTMENT (Bleeding Edge, r32956)
 -----------------------------------------------------
  * 1/4 oz Vodka      Pour all ingredients into mixing
  * 1/4 oz Gin        tin with ice, strain into glass.
  * 1/4 oz Amaretto
  * 1/4 oz Triple sec
  * 1/4 oz Peach schnapps
  * 1/4 oz Sour mix
  * 1 splash Cranberry juice
 -----------------------------------------------------
root@OpenWrt:~# dmesg | grep i2c
[    0.140000] i2c-core: driver [dummy] registered
[    0.850000] i2c-core: driver [pcf857x] registered
[    4.440000] i2c /dev entries driver
[    4.550000] i2c-core: driver [pcf8591] registered
[   31.150000] i2c-gpio: probe of i2c-gpio.0 failed with error -16
root@OpenWrt:~# i2cdetect -l
root@OpenWrt:~#

I'll clean up everything and try to compile r28863, which is the version I had it working before.

Thanks,
Jabss

Just to be sure: the gpios you want to use are not already bound to other modules?

Hi,

Yes, they are bound to something else, but it should be something coming by default in the image, as I didn't add anything else.

root@OpenWrt:/# dmesg | grep gpio
[    0.000000] gpiochip_add: registered GPIOs 0 to 21 on device: ar2315-gpio
[    0.000000] ar2315-gpio: registered 22 GPIOs
[    2.280000] gpiodev: gpio device registered with major 254
[    4.560000] Registered led device: gpio1
[    4.560000] Registered led device: gpio3
[    4.560000] Registered led device: gpio4
[    4.570000] Registered led device: gpio7
[   31.040000] gpio_request: gpio-4 (sda) status -16
[   31.040000] i2c-gpio: probe of i2c-gpio.0 failed with error -16

Is there a way to un-register these led devices?

Thanks,
Jabss

The discussion might have continued from here.