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'm trying to get i2c working on a fonera with Backfire (10.03.1-RC5, r27608). Basically I need to drive a PCF8574 (GPIO expander), but I'm having no success at all...

The instructions around are a bit old and mention packages that don't exist in the current release. (I'm assuming everything have evolved since then and that the packages available are enough).

I installed all the packages I could (some were not possible because of dependencies), but even so I'm lacking something.
For instance, how can we configure wich GPIOs will be the SDA and SCK pins?
Where can I find documentation (readme files or something equivelent) for each of these packages?

root@OpenWrt:/etc# opkg list-installed | grep i2c
i2c-tools - 3.0.3-1
kmod-i2c-algo-pcf - 2.6.30.10-1
kmod-i2c-core - 2.6.30.10-1

root@OpenWrt:/etc# lsmod | grep i2c
i2c_algo_pcf            4432  0
i2c_dev                 4496  0
i2c_core               13808  2 i2c_algo_pcf,i2c_dev

root@OpenWrt:/etc# i2cdetect -l

Could anyone possible bring some light to the shadow?

Thanks in advance,
Jabss

Thank you!

I don't know how I have missed now. I know I had tried to install it before (the link was with the "re-visited" colour) but I was unsucessfull. Now I understand why: There is a precedence for the packages. I though opkg was like yum or apt-get that also installs dependences but that don't seems to be the case. My suggestion to whom tries the same in the future is to keep trying all possible combinations of the packages untill you get this:

root@OpenWrt:/# opkg list-installed | grep i2c
i2c-tools - 3.0.3-1
kmod-i2c-algo-bit - 2.6.30.10-1
kmod-i2c-algo-pcf - 2.6.30.10-1
kmod-i2c-core - 2.6.30.10-1
kmod-i2c-gpio - 2.6.30.10-1
kmod-i2c-gpio-custom - 2.6.30.10-2

I had seen that page before but it wasn clear what packages would be "Install kernel modules that allow to use GPIO as I2C bus". With your help, I succeed! Maybe the page could be updated to be a bit more clear? Something like telling which packages to install...

Anyway, some tips for who may try this in the future:

In the instrucions page ( http://code.google.com/p/fonera-i2c/wiki/FoneraHacks ). The mentioned caps to be removed are the tiny smd capacitors that are connected to the GPIO ports - on the upper face of the board, it's possible to see 4 tracks between the GPIOs 3 and 4 (first and second solder points of sw1), 1 and 7 (fift and seventh solder points of sw1) and a set of 4 small smd's. Take those out, as suggested. Mine only worked after I took them out.

Even if my PCF8574 is feed at 5v and fonera works at 3,3v, I'm able to work with PCF and change the port bits - I was using a 7400 as a driver (to boost up 3,3 to 5), but it didn't worked. Tried direct connection and it works.

The pullup resistors are really needed and the ones I'm using are around 5,5kohms (actually a 10k + 1k in parallel). It works.

Well that's it! It works!

Thank you! I really apreciate your help!
Jabss

echo pcf8574 0x20 > /sys/bus/i2c/devices/i2c-1/new_device

MBS wrote:

echo pcf8574 0x20 > /sys/bus/i2c/devices/i2c-1/new_device

:-D

Maybe you just guessed my next obstacle :-)  : I'm able to change the ports of the PCF8574 as an entire byte, but I'm still not able to do it bit by bit. I mean, for my specific purpose I need to turn on and off each bit independently. Otherwise, I have to somehow calculate the current status and send the byte that doesn't interfere with the other bits. I tried to play around with the mask switch but it doesn't seem to work. (some output below).

root@OpenWrt:/sys/bus/i2c/devices# i2cdetect -l
i2c-0   i2c             i2c-gpio0                               I2C adapter
root@OpenWrt:/sys/bus/i2c/devices# i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     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:/sys/bus/i2c/devices# i2cset -y 0 0x38 0x01
root@OpenWrt:/sys/bus/i2c/devices# (led gets on)
root@OpenWrt:/sys/bus/i2c/devices# i2cset -y 0 0x38 0x00
root@OpenWrt:/sys/bus/i2c/devices# (led gets off)
root@OpenWrt:/sys/bus/i2c/devices# i2cset -y -m 0x01 0 0x38 0x01
root@OpenWrt:/sys/bus/i2c/devices# (led gets on - I wanted the mask swith to "mask" it, but it didn't work)
root@OpenWrt:/sys/bus/i2c/devices# i2cset -y -m 0xfe 0 0x38 0x00
root@OpenWrt:/sys/bus/i2c/devices# (led gets off - I wanted the mask swith to "mask" it, this time I tried with the mask "inverted". It didn't work.)


Anyway, the command you gave didn't work. What is supposed to happen with that command?  :-)

root@OpenWrt:/sys/bus/i2c/devices# echo pcf8574 0x20 > /sys/bus/i2c/devices/i2c-1/new_device
/bin/ash: can't create /sys/bus/i2c/devices/i2c-1/new_device: nonexistent directory
root@OpenWrt:/sys/bus/i2c/devices#
root@OpenWrt:/sys/bus/i2c/devices# mkdir i2c-0
mkdir: cannot create directory 'i2c-0': No such file or directory
root@OpenWrt:/sys/bus/i2c/devices# touch new_device
touch: new_device: No such file or directory


Thanks!
jabss

(Last edited by jabss on 22 Oct 2011, 16:24)

In your case: echo pcf8574 0x38 > /sys/bus/i2c/devices/i2c-0/new_device
Maybe you need a more recent openwrt-image (or compile your own). There is a kernel driver for the pcf857x series, so after issuing the above command, it should create a file called /sys/class/gpio/gpiochipXX (dmesg will show the value of XX). Then issuing echo XX > /sys/class/gpio/export will create a subdir named gpioXX. In there you will find files like value, where you can read/write the value of the gpio-pin, and direction, where you can set in or out.
So, no messing with any bits necessary :-)

(Last edited by MBS on 23 Oct 2011, 10:11)

Dear MBS,

Thanks for replying once again. You have been a tremendous help and I have been very afortunate to have your help...  :-)

I also had tried that command with the parameters I suspected it would be correct for my system (0x38 as the chip address and 0 as i2c driver instance). Unfortunatelly it didn't work either.

root@OpenWrt:/# echo pcf8574 0x38 > /sys/bus/i2c/devices/i2c-0/new_device
/bin/ash: can't create /sys/bus/i2c/devices/i2c-0/new_device: nonexistent directory


Now, in terms of finding a solution for this problem:

I believe I already have the latest release (10.03.1-RC5). Could it happed it got broken meanwhile? What do you think if I downgrade the router to one release that possibly has that?

root@OpenWrt:/# cat /etc/banner
  _______                     ________        __
|       |.-----.-----.-----.|  |  |  |.----.|  |_
|   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
|_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
Backfire (10.03.1-RC5, r27608) --------------------------
  * 1/3 shot Kahlua    In a shot glass, layer Kahlua
  * 1/3 shot Bailey's  on the bottom, then Bailey's,
  * 1/3 shot Vodka     then Vodka.
---------------------------------------------------
root@OpenWrt:/#


I don't know much about development, but could it be that the "kernel driver for the pcf857x series" you mention would be the "i2c_algo_pcf"? I have that one installed and loaded.

root@OpenWrt:/sys/bus/i2c/devices# lsmod | grep i2c
i2c_gpio                2272  0
i2c_gpio_custom          896  0
i2c_algo_pcf            4432  0
i2c_algo_bit            4480  1 i2c_gpio
i2c_dev                 4496  0
i2c_core               13808  4 i2c_gpio,i2c_algo_pcf,i2c_algo_bit,i2c_dev

root@OpenWrt:/sys/bus/i2c/devices# opkg list-installed | grep i2c
i2c-tools - 3.0.3-1
kmod-i2c-algo-bit - 2.6.30.10-1
kmod-i2c-algo-pcf - 2.6.30.10-1
kmod-i2c-core - 2.6.30.10-1
kmod-i2c-gpio - 2.6.30.10-1
kmod-i2c-gpio-custom - 2.6.30.10-2

root@OpenWrt:/sys/bus/i2c/devices# opkg files kmod-i2c-algo-pcf
Package kmod-i2c-algo-pcf (2.6.30.10-1) is installed on root and has the following files:
/etc/modules.d/55-i2c-algo-pcf
/lib/modules/2.6.30.10/i2c-algo-pcf.ko

Maybe the way of enabling a PCF chip has changed? Where can we find more information about these packages? A readme would be great....

Any idea?

Thanks!
Jabss

OK, I finally fired up my test station (TL-WR1043) to get exact syntax:

 _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 ATTITUDE ADJUSTMENT (bleeding edge, r28352) ----------
  * 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:~# i2cdetect -l
i2c-0   i2c             i2c-tiny-usb at bus 001 device 002      I2C adapter
root@OpenWrt:~# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: 20 -- 22 -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@OpenWrt:~# echo pcf8575 0x20 > /sys/bus/i2c/
devices/           drivers_autoprobe  uevent
drivers/           drivers_probe
root@OpenWrt:~# echo pcf8575 0x20 > /sys/bus/i2c/devices/i2c-0/new_device 
root@OpenWrt:~# dmesg | tail
br-lan: port 2(wlan0) entering forwarding state
br-lan: port 2(wlan0) entering forwarding state
device wlan0 left promiscuous mode
br-lan: port 2(wlan0) entering forwarding state
device wlan0 entered promiscuous mode
br-lan: port 2(wlan0) entering forwarding state
br-lan: port 2(wlan0) entering forwarding state
ar71xx-wdt: enabling watchdog timer
pcf857x 0-0020: gpios 48..63 on a pcf8575
i2c i2c-0: new_device: Instantiated device pcf8575 at 0x20

The kernel module is called pcf857x (the package should be called kmod-pcf857x) and is included in trunk since this month. Although it was sometimes already selected by default for certain platforms (like mine), where it is built already into the kernel (no module). I don't know about your platform, I haven't seen the package there (maybe it is already included in the kernel). Anyways, you probably need to upgrade to trunk (http://downloads.openwrt.org/snapshots/trunk/atheros/), this way of instanciating was added to the pcf857x driver about one year ago, while your kernel version seems to be much older.
i2c-algo-pcf is not needed in your case. This is another i2c-adapter, but you are using i2c-gpio-custom adapter.

Hello,

I have installed the latest trunk:

root@OpenWrt:/sys/class# cat /etc/banner
  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 ATTITUDE ADJUSTMENT (bleeding edge, r28504) ----------
  * 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:/sys/class# uname -a
Linux OpenWrt 2.6.37.6 #1 Sat Oct 22 02:27:11 MST 2011 mips GNU/Linux

and the I2c packages

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

I was now able to issue the desired command and get some propper answer:

root@OpenWrt:~# echo pcf8574 0x38 > /sys/bus/i2c/devices/i2c-0/new_device
i2c i2c-0: new_device: Instantiated device pcf8574 at 0x38

Great! But I'm not able to find any "export" directory within /sys/class to issue the next command (echo 0x38 > /sys/class/gpio/export ):

root@OpenWrt:/sys/class# ls /sys/class/
bdi         gpiodev     leds        misc        pci_bus     tty
block       i2c-dev     mdio_bus    mtd         ppp
firmware    ieee80211   mem         net         spi_master
root@OpenWrt:/sys/class# ls /sys/class/gpiodev/
gpio
root@OpenWrt:/sys/class# ls /sys/class/gpiodev/gpio/
dev        subsystem  uevent
root@OpenWrt:/sys/class# ls /sys/class/gpiodev/gpio/subsystem/
gpio
root@OpenWrt:/sys/class# ls /sys/class/gpiodev/gpio/subsystem/gpio/
dev        subsystem  uevent
root@OpenWrt:/sys/class# cat /sys/class/gpiodev/gpio/subsystem/gpio/dev
254:0
root@OpenWrt:/sys/class# cat /sys/class/gpiodev/gpio/subsystem/gpio/uevent
MAJOR=254
MINOR=0
DEVNAME=gpio
root@OpenWrt:/sys/class#

/sys/class/gpio/export doesn't exist...  Maybe I'm missing some GPIO package?

root@OpenWrt:/sys/class# opkg list-installed | grep -i gpio
gpioctl - 1.0-1
kmod-i2c-gpio - 2.6.37.6-1
kmod-i2c-gpio-custom - 2.6.37.6-2

I also looked into /sys/class/i2c-dev:

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         i2c-dev        new_device     uevent
delete_device  name           subsystem
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0# cat new_device
cat: can't open 'new_device': Permission denied
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
modalias   name       subsystem  uevent
root@OpenWrt:/sys/devices/platform/i2c-gpio.0/i2c-0/0-0038#

I feel I'm close, but I'm missing just a bit...

Any suggestion?

Thanks!
Jabss

jabss wrote:
root@OpenWrt:~# echo pcf8574 0x38 > /sys/bus/i2c/devices/i2c-0/new_device
i2c i2c-0: new_device: Instantiated device pcf8574 at 0x38

If that's the whole message you get, it means the gpiodevice has not yet been created. I remeber a posting in the mailing list two days ago, mentioning to get support for gpiolib on atheros platform. I guess that is the reason. From what I understand, pcf857x depends on gpiolib, so it probably has not been compiled for your platform. I only see a chance for the moment, that you build your own image from trunk with the patch from the following posting applied:
http://patchwork.openwrt.org/patch/1452/

Hello again,

Maybe I'm runnig the risk of geeting a little bit out of topic, but I'm afraid I have no idea how to add a patch...
Well, to be honest, I neither know how to build my own image.

I'm good in troubleshooting and configuring within Unix/linux, but I'm null when programing and compiling.... sad

Will I need a VMWare environment?

By the way, do you use any buffer in your device? Something like 7405? I've read somewhere that it's good to protect the router GPIO's and to step up the 3.3v to 5v...
If that's the case, where would you place the I2c pull-up resistors? After or before the buffer? Maybe in both?

Thanks!
Joaoabs

Building an image is pretty easy (but can take some hours compiling). You probably need some Unix/Linux environment. Then follow http://wiki.openwrt.org/doc/howto/buildroot.exigence
Enter the top level directory of your build environment (normally called trunk) and issue

patch -p0 < /tmp/patchfile.diff

(change /tmp/patch.diff to the location of your patch file).
Then continue building with http://wiki.openwrt.org/doc/howto/build
I don't do levelshifting at the moment, my bus runs at 5V. Although, from what I read, you can easily shift the voltage level using just a regular MOSFET (like 2N7000). Page 10 of http://ics.nxp.com/support/documents/in … n97055.pdf shows how to do that.

Hello,

Still no luck....
Created a kind of vm machine based on pendriveinux with portable ubuntu and created the compiling environment.

What next?

mkdir ~/openwrt
cd openwrt
svn co svn://svn.openwrt.org/openwrt/trunk/
cd trunk
./scripts/feeds update -a
./scripts/feeds install -a

(copied and pasted the patch text from the webpage to a file)
patch -p0 < /tmp/patchfile.diff

make defconfig
make prereq
make menuconfig  (changed the arch to ateros 231x)
make

4 hours later:
flashed images from trunk/bin/atheros/
openwrt-atheros-vmlinux.lzma
openwrt-atheros-root.squashfs

booted system and installed kmod-i2c-gpio-custom. Followed again the instructions from http://code.google.com/p/fonera-i2c/wiki/FoneraHacks

The new system worked as before. I'm able to detect the i2C bus and the devices. However, there is no path /sys/class/gpio/export.

Should it be like this or did I probabily do something wrong?

Thanks,
Jabss

So, I assume patching worked without any issues? Then, in menuconfig, submenu Kernel modules, section I2C support: are kmod-i2c-gpio-custom and kmod-pcf857x selected?
Are gpiolib.o and pcf857x.o built? Check that in directory build/linux*/linux*/drivers/gpio (* is my placeholder for version or target specific names. when in a good shell, hit Tab-key for auto completion in that case).

Hello,

No success yet...
I have tried everything back again three times and I'm still on the same page.

Firstly I tried patching with "patch -p0 < patchfile.diff" and didn't work. (I copied the patch from the site and pasted into a text-file).
The patching working OK. The "/openwrt/trunk/build_dir/linux-atheros/linux-2.6.37.6/drivers/gpio" directory had both gpiolib.c and pcf857x.c files (note: .c files, not .o - Does it matter the difference?)

Anyway, I contacted the patch author who advised me to download the patch as a file, and put it in "/openwrt/trunk/target/linux/atheros/patches-xxxx". Then it was just to re-build the image and try again.

Then, I figured out that I had both "openwrt/trunk/target/linux/atheros/patches-2.6.38" and "openwrt/trunk/target/linux/atheros/patches-2.6.37" directories. I had copied to the latest release (*38) and then realised that the level being build was the *37, so I copied the patch to the *37 and tried everyting back again.

In every time, I flashed the fonera, and add and configure the kmod-i2c-gpio-custom_2.6.37.6-2_atheros.ipk package.
I test the i2cbus sucessfully and try the command

echo pcf8574 0x38 > /sys/bus/i2c/devices/i2c-0/new_device
i2c i2c-0: new_device: Instantiated device pcf8574 at 0x38

I still don't have the desired directory structure:

root@OpenWrt:/sys/class# ls
bdi         gpiodev     leds        misc        pci_bus     tty
block       i2c-dev     mdio_bus    mtd         ppp
firmware    ieee80211   mem         net         spi_master
root@OpenWrt:/sys/class# cd gpiodev/
root@OpenWrt:/sys/class/gpiodev# ls
gpio
root@OpenWrt:/sys/class/gpiodev# cd gpio/
root@OpenWrt:/sys/devices/virtual/gpiodev/gpio# ls
dev        subsystem  uevent
root@OpenWrt:/sys/devices/virtual/gpiodev/gpio#

What am I doing wrong???

Thanks for all of your tremendous help!
Jabss

it has to be pcf857x.o and gpiolib.o. Files with extension .c are source code, while files with extension .o are already compiled. So now you should check if the patch got successfully applied.
As an example from the patch:

--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
####Means that in your kernel directory the above file gets changed####
@@ -111,7 +111,7 @@ config ATHEROS_AR231X
####somewhere around line 111 in section "config ATHEROS_AR231X####
     select SYS_HAS_CPU_MIPS32_R1
     select SYS_SUPPORTS_BIG_ENDIAN
     select SYS_SUPPORTS_32BIT_KERNEL
-    select GENERIC_GPIO
+    select ARCH_REQUIRE_GPIOLIB
     select SYS_HAS_EARLY_PRINTK
     help
       Support for AR231x and AR531x based boards
####the line starting with - gets deleted and the line starting with + gets added####

So parse through the patch and check that all changes are made in your local trunk copy.

Yes, definetelly, the patch is not being applied.
I've tried several times with the patch -p0 < file command but the target files are not being updated.
(appliying the patch only creates a directory in trunk named "b": trunk/b/target/linux/atheros/patches-2.6.37/300-sysfs_for_gpio.patch)

I've also copied the file to the "/openwrt/trunk/target/linux/atheros/patches--2.6.37" without any result.

Do I have to build differently? I'm just running the "make" command.

I could always apply the patch manually, but it's about 500 lines... (and I wouldn't know what to do with the "+-" lines).

Thanks,
Jabss

ok, seems like this patch has to be applied with -p1 instead of -p0. This is a patchfile within a patchfile. On every pass it is applied, it removes the leading + or - in every line. So +- will become - in the next step. The patchfile inside also needs to be applied with -p1.

it might be necessary to issue an make clean (or even make dirclean), so that the build system runs its patches (assuming target/linux/atheros/patches-2.6.37/300-sysfs_for_gpio.patch exists).

Hello again,

I don't know what else to do.... sad

I've been strugling with the patch and simply it's not applied correctly. I don't know why, but I'm not surprised - I don't know much about compiling/patching and most likelly I'm doing a dumb mistake.

I tried "make clean", "make cleandir", I even created a new build environment in a different computer (this one is a real PC with ubuntu, not virtual as the previous).  Tried "patch -p0 < FILE", "patch -p1 < FILE", even "patch -p4 < FILE" with no luck. I also tried running the patch command both in the "trunk" dir as well in the "target" dir, as it seems that when is applied in the "trunk" directroy, a "b" directory is created in "trunk" - I have no idea if it should be like that or not...

I'm not even trying to flash the fonera anymore - Just checking the "..../trunk/build_dir/linux-atheros/linux-2.6.37.6/drivers/gpio" directory seeking for .o files and nothing...

I also check the first file refered by the patch (/arch/mips/Kconfig) wich I believe in my build environment should be ".../trunk/build_dir/linux-atheros/linux-2.6.37.6/arch/mips/Kconfig" and the line "+-      select GENERIC_GPIO" is always there (it should be deleted, right?).

I'm not sure I have understand what should I do when a patchfile is whithin a patch file. I think when I run the "patch -p1 < FILE" (under the target directroy), another patch file named "300-add_gpiolib_support.patch" is saved in ".../trunk/target/linux/atheros/patches-2.6.37".  Should I go there and run "patch -p1 < 300-add_gpiolib_support.patch" ? Tried anyway and it seems not to work...

I'm getting a bit desesperate. smile

Any suggestion?

Thanks!
Jabss

OK, I tried it.
1. Downloaded http://patchwork.openwrt.org/patch/1452/raw/ to parent dir of my trunk
2. enter trunk and issue

trunk> patch -p1 < ../OpenWrt-Devel-Move-atheros-platforms-to-sysfs-style-gpio.patch 
patching file target/linux/atheros/patches-2.6.37/300-sysfs_for_gpio.patch

That created the above file.
3. run "make menuconfig" to select the atheros target
4. run "make kernel_menuconfig": it downloads and patches a 2.6.37.6 kernel and runs its menuconfig. I checked the first and last two files which get patched - everything looks OK.
If that doesn't work for you, then please start from scratch again and post your console output. In case of any error, either fix it or report it back here - just don't skip it.

Hello,

Some improvements, but still with no success...
I can now see that with make kernel_menuconfig the patch is correctly applied. I have also checked some files pointed by the patch file and the patched entries are there.

However, there is still no .o files in the build directory...

jabss@blackpearl:/mnt/storage/trunk$ ls -larth build_dir/linux-atheros/linux-2.6.37.6/drivers/gpio | grep "\.o"
-rw-r--r--  1 jabss jabss    8 2011-11-06 01:11 built-in.o
-rw-r--r--  1 jabss jabss  120 2011-11-06 01:11 .built-in.o.cmd
-rw-r--r--  1 jabss jabss    0 2011-11-06 19:25 modules.order

Is it possible that it was built anyway but iwithout the .o files in this directory?

I suspect it must be some option I'm not sellecting in make menuconfig. I've added all the I2C (with *, not M), and all the GPIO's I could find in the submenus.

Besides kmod-i2c-gpio-custom and kmod-pcf857x in the I2C section of kernel modules, what should I choose in order to have GPIOLIB?
There is no GPIOLIB item in the libraries section...

Thanks,
Jabss

make kernel_menuconfig does not build the kernel. It is supposed to configure the kernel (with more options than buildroot offers). It is just a side effect, that it has to download, extract and apply patches, which I abused to see if the patches get applied properly (I did not want to build the whole toolchain, which takes hours on my computer).
So you have to issue make from trunk dir, to get the modules compiled. The use of GPIOLIB has already been selected by the patch.