Forums » Software Development »
GPIO in linux
Added by Steven Hill about 11 years ago
I want to use GPIO pins in my application. Doing the following:
echo 0 > /sys/class/gpio/export
creates a GPIO0 object in the /sys/class/gpio directory. Next I input:
echo "out" > /sys/class/gpio/gpio0/direction echo 1 > /sys/class/gpio/gpio0/value
but when I look at the pin (pin25 on J701 of the Industrial I/O board) I see 0V. What am I missing?
Replies (4)
RE: GPIO in linux - Added by Gregory Gluszek about 11 years ago
Make sure that the pinmux is set correctly so that GPIO0 functions as a GPIO.
\Greg
RE: GPIO in linux - Added by Dominic Giambo about 11 years ago
You will need to edit the baseboard file you are using and rebuild the linux kernel. For instance, the industrial IO board uses baseboard file present at /arch/arm/mach-davinci/baseboard-industrialio.c, which has an array:
static short baseboard_gpio_pins[] __initdata = {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_3,
DA850_GPIO0_4, DA850_GPIO0_5, DA850_GPIO0_6, DA850_GPIO0_7,
DA850_GPIO0_8, DA850_GPIO0_9, DA850_GPIO0_10, DA850_GPIO0_11,
DA850_GPIO0_12, DA850_GPIO0_13, DA850_GPIO0_14, DA850_GPIO0_15,
DA850_GPIO2_12, DA850_GPIO2_15, -1,
};
Later, an init function is called on this array which sets up pin muxing for the GPIOs listed.
-Dominic
RE: GPIO in linux - Added by Steven Hill about 11 years ago
I looked at that file, and the array includes all the Bank 0 pins, so they all should be acting as GPIO - but according to my test, they are not.
Then I went back and had a close look at J701 on the board, and I was looking at it upside-down. With my DVM attached to the correct pin, my test works.
Sorry for the trouble...