OpenWrt Forum Archive

Topic: No /dev/gpio directory

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

Hello everybody!

I am trying to attach an SD-card to a WRT54GS v.1.1. As the tutorial is unclear and I do not want to rely on it without checking the information I want to check the pins mentioned in the tutorial with a voltmeter.
The problem is that the device doesn't have a /dev/gpio directory which I need (or the gpio tool from utils directory needs) to change the state of a pin from low to high or the other way round.
Is it maybe possible that the GPIO-pins are somehow not recognised by the kernel? An argument against this thesis is that i have a /proc/diag/gpiomask file whose content I can change. Its default content is 0.

My OpenWRT version is 7.09 and I am using the precompiled default kernel.


Thank you for your help,

quoonk

Hi, you need to build a kernel yourself with the gpio module enabled and gpio device support

(make menuconfig --> kernel modules --> other modules --> kmod-gpio-dev)
also whilst in make menuconfig (Device Drivers --> Character Devices --> GPIO device support) - Possibly already enabled

Take a look at gpioctl for how to use /dev/gpio

Hope it works for you

(Last edited by ximon on 17 Dec 2008, 15:50)

Bullshit! It's not universal! Only work for 2.6 kernel. Universal one is modify kmod-diag for read the bytton state:

Index: package/broadcom-diag/src/diag.c
===================================================================
--- package/broadcom-diag/src/diag.c    (revision 14605)
+++ package/broadcom-diag/src/diag.c    (working copy)
@@ -910,9 +910,25 @@

static void register_buttons(struct button_t *b)
{
-       for (; b->name; b++)
+       buttons = proc_mkdir("button", diag);
+       if (!buttons)
+               return;
+
+       for (; b->name; b++) {
+               struct proc_dir_entry *p;
                platform.button_mask |= b->gpio;

+               if (b->gpio & gpiomask)
+                       continue;
+
+               if ((p = create_proc_entry(b->name, S_IRUSR, buttons))) {
+                       b->proc.type = PROC_BUTTON;
+                       b->proc.ptr = b;
+                       p->data = (void *) &b->proc;
+                       p->proc_fops = &diag_proc_fops;
+               }
+       }
+
        platform.button_mask &= ~gpiomask;

        gpio_outen(platform.button_mask, 0);
@@ -926,6 +942,9 @@

static void unregister_buttons(struct button_t *b)
{
+       for(; b->name; b++)
+               remove_proc_entry(b->name, buttons);
+
        gpio_intmask(platform.button_mask, 0);

        gpio_set_irqenable(0, button_handler);
@@ -1179,6 +1198,12 @@
                                }
                                break;
                        }
+                       case PROC_BUTTON: {
+                               struct button_t * button = (struct button_t *) handler->ptr;
+                               u32 in = (gpio_in() & button->gpio ? 1 : 0);
+                               len = sprintf(page, "%d\n", in);
+                               break;
+                       }
                        case PROC_MODEL:
                                len = sprintf(page, "%s\n", platform.name);
                                break;
Index: package/broadcom-diag/src/diag.h
===================================================================
--- package/broadcom-diag/src/diag.h    (revision 14605)
+++ package/broadcom-diag/src/diag.h    (working copy)
@@ -125,7 +125,7 @@

/* proc */

-static struct proc_dir_entry *diag, *leds;
+static struct proc_dir_entry *diag, *leds, *buttons;

static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos);
static ssize_t diag_proc_write(struct file *file, const char *buf, size_t count, loff_t *ppos);

or install this module(for bcm2.4): http://strelok-burn.narod.ru/kmod-diag_ … cm-2.4.ipk

The discussion might have continued from here.