OpenWrt Forum Archive

Topic: GPIO export failing on WRT54g v2

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

Hello,
I currently have a Linksys WRT54g v2.0 running the latest version of Barrier Breaker, and I would like to access its GPIO ports. I have followed the directions presented on this wiki page for controlling GPIO from the shell, but every time I attempt to export the pins, I receive this error:
"ash: write error: Device or resource busy"
This occurs for every pin except pin 4. I can't find any explanation of what might be causing this and how to alleviate this problem. Any help or tips would be greatly appreciated!

Bump?

4 GPIOs are taken by ADM6996 switch
~2 GPIOs are taken for buttons
~4 GPIOs are taken for LEDs

It leaves you ~6 GPIOs you should be to use.

What are you trying to achieve?

Ah, I didn't realize there were more GPIO lines than listed on the wiki page. I need four lines to connect to an SPI device that I am using as a servomotor controller. I was under the impression that exporting the ports released them from their previous uses, is this not the case? The page on the wiki stated that the ports used by the ADM switch were only used during the boot process, and would not be used after that.

If I do need to use ports 8 and up, do you know where they might be located on the board?

No idea, sorry sad

One last question, as I am still confused. Are the pins used by the ADM switch being used after booting up? If not, i would really like get the kernel to let me use them, as I do know where they are located.

Check it out by yourself: http://git.openwrt.org/?p=openwrt.git;a … /adm6996.c

I still have no idea why does it matter if the GPIOs are used during boot only. Let's say they are. After booting they stay connected to the switch, right? So you can't re-use them for anything else I believe. Unless you want to remove switch support completely.

How would one go about removing switch support? Would that affect my ability to ssh in? I'm sorry if these are newb-ish questions, I'm rather new to Linux.

No idea how switch behaves by default, without any reset/config.

I'm sure you won't be able to have separated "WAN" port and "LAN" ports.

http://wiki.openwrt.org/toh/linksys/wrt54g

Although how the switch is set up without a config file is generally up to the driver, removing the driver will just result all ports bridged as eth0.

qasdfdsaq wrote:

removing the driver will just result all ports bridged as eth0.

Assuming this is the default switch state. Remember that removing GPIOs may result even in CFE not doing any switch initialization.

steiner.davidmichael wrote:

Hello,
I currently have a Linksys WRT54g v2.0 running the latest version of Barrier Breaker, and I would like to access its GPIO ports. I have followed the directions presented on this wiki page for controlling GPIO from the shell, but every time I attempt to export the pins, I receive this error:
"ash: write error: Device or resource busy"
This occurs for every pin except pin 4. I can't find any explanation of what might be causing this and how to alleviate this problem. Any help or tips would be greatly appreciated!

As I have been tracking down a very similar issue with AA on a Meraki Mini, and
was frustrated in mine own search, I shall reply.

This may or may not work for BB.

root@OpenWrt:/#
root@OpenWrt:/# cat /sys/kernel/debug/gpio
GPIOs 0-21, ar2315-gpio:
gpio-0   (sysfs               ) in  lo
gpio-1   (gpio1               ) out lo
gpio-2   (gpio2               ) out lo
gpio-3   (gpio3               ) out lo
gpio-4   (gpio4               ) out lo
gpio-5   (reset               ) in  hi
gpio-6   (sysfs               ) in  lo
gpio-7   (wlan                ) out lo
root@OpenWrt:/#

Other research led me to the leds-gpio driver.
root@OpenWrt:/# ls -l /sys/bus/platform/drivers/leds-gpio/
--w-------    1 root     root          4096 Jul 14 01:48 bind
lrwxrwxrwx    1 root     root             0 Jul 14 01:50 leds-gpio -> ../../../../devices/platform/leds-gpio
--w-------    1 root     root          4096 Jul 13 23:01 uevent
--w-------    1 root     root          4096 Jul 14 01:31 unbind
root@OpenWrt:/#
These 'bind' and 'unbind' leaves look like they might do something if we write to them.
But what to write? Asking Google led to a week's frustration. But then!
Ask Google the full /sys path (/sys/bus/platform/drivers/leds-gpio/unbind)
And with milk! This article made my solution easy.
http://www.drdobbs.com/embedded-systems … /240001076

....
# Turn off the LEDs
root@OpenWrt:/# echo "leds-gpio" > /sys/bus/platform/drivers/leds-gpio/unbind
root@OpenWrt:/# cat /sys/kernel/debug/gpio
GPIOs 0-21, ar2315-gpio:
gpio-0   (sysfs               ) in  lo
gpio-5   (reset               ) in  hi
gpio-6   (sysfs               ) in  lo
root@OpenWrt:/#
(sysfs) are just the ones I was successful with the pin export you had just
referened.

I hope this is helpful to your issue as well.

The discussion might have continued from here.