OpenWrt Forum Archive

Topic: Fonera 2100 and GPIO

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

Hi,

I have installed OpenWRT following this tutorial: http://wiki.openwrt.org/toh/fon/fonera
It's working, I have configured the network and several other things, but I can't get GPIO working. All the tutorials I have found on The Internet use /proc/gpio to deal with GPIO pins, but I have no gpio dir under /proc.

How can I get GPIO working? Do I have to recompile the kernel? (I hope I have not to compile everything).

/dev/gpio

I have /dev/gpio, but not /proc/gpio. All tutorials I have read use /proc/gpio. How can I use /dev/gpio. Do I neet to install a package? Will one of these help?:

gpioctl_1.0-1_mips.ipk
kmod-input-gpio-buttons_2.6.26.8-atheros-1_mips.ipk
kmod-leds-gpio_2.6.26.8-atheros-1_mips.ipk

(Last edited by doragasu on 3 Feb 2012, 19:49)

I have found the way to control pins using gpioctl. For example to ligth WLAN led:

gpioctl dirout 2
gpioctl set 2

Anyway, if anyone knows how to use the more convenient /proc/gpio way, or even how to do it in plain C, please post it here.

Yes you can use /dev/gpio using c.

    if ((gpio_bus = open("/dev/gpio", O_RDWR)) < 0)
    {
         printf("/dev/gpio open Failure\n");
    }
    else
    {
        ioctl(gpio_bus, GPIO_DIR_OUT, gpionumber);
    }

ioctl(gpio_bus, GPIO_CLEAR, gpionumber);

ioctl(gpio_bus, GPIO_SET, gpionumber);

Thanks a lot! Nice and easy!

Let me know if you have any more questions, though that's pretty much the sum total about GPIOs.

The discussion might have continued from here.