gpio Issues

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

gpio Issues

1,275 Views
tony_l_cai
Contributor III

Hi all

      Now, I used gpio_export to export the GPIO,but in console, it didnt show the gpio which I what? why?

      And I want to know about the what is the definition of the gpiochip, how to use? what can I get from it and how to get in console?

3Q!

Labels (2)
0 Kudos
3 Replies

698 Views
jimmychan
NXP TechSupport
NXP TechSupport

Have you apply the configuration CONFIG_GPIO_SYSFS=y ?

you can read this for reference.

imx.6 GPIO

GPIO output value not changing.

698 Views
tony_l_cai
Contributor III

Maybe from above info, I cant solve my problem. Now I export a LED gpio. And I cant use "echo 1 /sys/class/gpio/gpio50/value" to change the LED on/off. could you give another info? 

0 Kudos

698 Views
jimmychan
NXP TechSupport
NXP TechSupport

1. First, do you enable the GPIO in SYSFS in kernel?

Device Drivers --->

      --- GPIO Support

            [*] /sys/class/gpio/... (sysfs interface)

2. I don't know which pin you want to export. Have you try to follow example in "GPIO output value not changing."?

Be sure that the pins you will try to use are really accessible as GPIO pins and were not requested by the kernel (gpio_request).

If pin was gpio_request'ed, you will need to gpio_export the same pin inside the kernel in order to have it accessible through SYSFS.

If pin is not set as GPIO by default, you will need to set IO MUX in the proper file inside <kernel>/arch/arm/mach-XXX.

Accessing GPIO in user space

After enabling GPIO-SYSFS feature, you can boot your device with the new kernel to make some tests.

First you need to export the GPIO you want to test to the user space:
BUZZER GPIO(4,28) - (4-1)*32 + 28

echo 124 > /sys/class/gpio/export


XX shall be determined by the following algorithm:
GPIOA_[B] is the GPIO you want to export, where "A" is the GPIO bank and "B" is the offset of the pin in the bank.

if the first available GPIO bank is 0 // (iMX.6, for example)
    XX = A*32 + B;
else // first GPIO bank is 1
    XX = (A-1)*32 + B;

After exporting a GPIO pin, you shall be able to see the GPIO interface exported to:
/sys/class/gpio/gpio124

Through this interface, you are now able to do things like:
# Reading the pin value
cat /sys/class/gpio/gpio124/value

# Changing pin direction
echo in > /sys/class/gpio/gpio124/direction
echo out > /sys/class/gpio/gpio124/direction

# Toggling GPIO output level
echo 0 > /sys/class/gpio/gpio124/value
echo 1 > /sys/class/gpio/gpio124/value

0 Kudos