OpenWrt Forum Archive

Topic: how to make the router button work?

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

how to make the router button work? I have a router ,firmawre image openwrt-ramips-rt305x-wr512-3gn-4M-squashfs-sysupgrade.bin ,but the button didn't work ,I follow the wiki how to log $action of button ,but have nothing...can someone give me some suggest? Thanks~

as control of leds and buttons are highly hardware dependent, you have to gather infos about the gpio of your router.
Hint to search openwrt / google :        gpioctl  button  led    sysctl

as well as any infos o your routers I/O

there is alot of code aout there dealing with routers I/O, so go and learn
   example : https://forum.openwrt.org/viewtopic.php?id=28193

good luck

3zl

(Last edited by 3zl on 6 Nov 2011, 11:28)

thanks~I find the reset of gpio10 can pressed tx value 0 and unpressed rx value 1 ,but how can i use it to reset??I have mkdir /etc/hotplug.d/button/00-reset and input so code,but it doesn't work!

scripts like this
#! /bin/sh

[ "$BUTTON" = "reset" ] && [ "$ACTION" = "pressed" ] && {
reboot
}


3zl wrote:

as control of leds and buttons are highly hardware dependent, you have to gather infos about the gpio of your router.
Hint to search openwrt / google :        gpioctl  button  led    sysctl

as well as any infos o your routers I/O

there is alot of code aout there dealing with routers I/O, so go and learn
   example : https://forum.openwrt.org/viewtopic.php?id=28193

good luck

3zl

Hello, I have the same problem with buttons in wr512-3gn (the buttons didn't work)

I put a simple script in /etc/hotplug.d/button/buttons and don't see anything in logread. The script is:

#!/bin/sh
logger $BUTTON
logger $ACTION

I try to see the file /sys/kernel/debug/gpio , but i can't find anything about buttons :

GPIOs 0-23, RT305X-GPIO0:
 gpio-1   (reserved            ) in  lo
 gpio-2   (reserved            ) in  lo
 gpio-3   (reserved            ) in  lo
 gpio-4   (reserved            ) in  lo
 gpio-9   (wr512:green:3g      ) out hi
 gpio-11  (wr512:green:gateway ) out hi
 gpio-12  (wr512:green:ap      ) out hi
 gpio-13  (wr512:green:station ) out hi
 gpio-14  (wr512:green:wps     ) out hi
 gpio-15  (reserved            ) in  lo
 gpio-16  (reserved            ) in  lo
 gpio-17  (reserved            ) in  lo
 gpio-18  (reserved            ) in  lo

GPIOs 24-39, RT305X-GPIO1:
 gpio-24  (reserved            ) in  lo
 gpio-25  (reserved            ) in  lo
 gpio-26  (reserved            ) in  lo
 gpio-27  (reserved            ) in  lo
 gpio-28  (reserved            ) in  lo
 gpio-29  (reserved            ) in  lo
 gpio-30  (reserved            ) in  lo
 gpio-31  (reserved            ) in  lo
 gpio-32  (reserved            ) in  lo
 gpio-33  (reserved            ) in  lo
 gpio-34  (reserved            ) in  lo
 gpio-35  (reserved            ) in  lo
 gpio-36  (reserved            ) in  lo
 gpio-37  (reserved            ) in  lo
 gpio-38  (reserved            ) in  lo
 gpio-39  (reserved            ) in  lo

GPIOs 40-51, RT305X-GPIO2:
 gpio-40  (reserved            ) in  lo
 gpio-41  (reserved            ) in  lo
 gpio-42  (reserved            ) in  lo
 gpio-43  (reserved            ) in  lo
 gpio-44  (reserved            ) in  lo
 gpio-45  (reserved            ) in  lo
 gpio-46  (reserved            ) in  lo
 gpio-47  (reserved            ) in  lo
 gpio-48  (reserved            ) in  lo
 gpio-49  (reserved            ) in  lo
 gpio-50  (reserved            ) in  lo
 gpio-51  (reserved            ) in  lo

Any idea?

Solved! A newbie error sad

I list all packages that contains "gpio"

root@OpenWrt:~# opkg list | grep gpio
gpioctl - 1.0-1 - Tool for controlling gpio pins
kmod-gpio-dev - 2.6.39.4-1 - Kernel module to allows control of GPIO pins using a character device.
kmod-gpiotoggling - 2.6.39.4+b57866441932eabc75b6c4252103121f606dc820-1 - Toggle GPIOs in kernel space
kmod-i2c-gpio - 2.6.39.4-1 - Kernel modules for a very simple bitbanging I2C driver utilizing the
kmod-i2c-gpio-custom - 2.6.39.4-2 - Kernel module for register a custom i2c-gpio platform device.
kmod-i2c-mux-gpio - 2.6.39.4-1 - Kernel modules for GENERIC_GPIO I2C bus mux/switching devices.
kmod-input-gpio-buttons - 2.6.39.4-1 - Kernel module for support polled GPIO buttons input device
kmod-input-gpio-encoder - 2.6.39.4-1 - GPIO rotay encoder
kmod-input-gpio-keys - 2.6.39.4-1 - This driver implements support for buttons connected
kmod-input-gpio-keys-polled - 2.6.39.4-1 - Kernel module for support polled GPIO keys input device
kmod-leds-gpio - 2.6.39.4-1 - Kernel module for LEDs on GPIO lines
kmod-ledtrig-gpio - 2.6.39.4-1 - Kernel module that allows LEDs to be controlled by gpio events.
kmod-mmc-over-gpio - 2.6.39.4-4 - Support for driving an MMC/SD card over GPIO pins via SPI.
kmod-pwm-gpio-custom - 2.6.39.4-1 - Kernel module to register a custom pwm-gpio platform device.
kmod-rotary-gpio-custom - 2.6.39.4-1 - Kernel module for register a custom rotary-gpio-encoder platform device.
kmod-spi-gpio - 2.6.39.4-1 - This package contains the GPIO-based bitbanging SPI Master
kmod-spi-gpio-old - 2.6.39.4-1 - This package contains the GPIO based bitbanging SPI controller driver
kmod-w1-gpio-custom - 2.6.39.4-2 - Kernel module to register a custom w1-gpio platform device.
kmod-w1-master-gpio - 2.6.39.4-1 - Kernel module for the GPIO 1-wire bus master driver
luci-app-mmc-over-gpio - trunk+svn7790-1 - MMC-over-GPIO configuration module

Then I list all packages installed in my router:

root@OpenWrt:~# opkg list_installed | grep gpio
kmod-leds-gpio - 2.6.39.4-1

OUX! I don't have any packages with "button".... I install this packages

root@OpenWrt:~# opkg install kmod-input-gpio-buttons kmod-input-gpio-keys kmod-input-gpio-keys-polled

Now the RESET button work, but not the MODE button. This is OK for me smile

google search with : wr512-3gn gpio button
reveals

   http://club.dealextreme.com/forums/Foru … did.960455   
......"Also some gpios are shared with the second uart, 7,8,9,10 if the remaining of the port is still used as GPIO. So could work depending on where GPIO8 is?

You defined GPIO 0 and 8 as input buttons named WPS and WPS2, are they exposed somewhere, on a testpoint?"

if they arent supported in you openwrt version you may test the buttos directly running a script in cron using "gpioctl get <pin>"

more infos
  http://www.mail-archive.com/openwrt-dev … 10480.html
  https://lists.openwrt.org/pipermail/ope … 09785.html

...just take a ride and wade through the internet ( as i did)

regards
3zl

(Last edited by 3zl on 9 Nov 2011, 15:43)

The discussion might have continued from here.