Multiple methods of controlling GPIO are not working on latest kernel

I followed the latest “Getting Started with the BeagleBone Black” tutorial and can not control GPIO with 5.10 kernel.

First, I used gpio-of-helper in my device tree to initialize the pins and noticed the folders created in /sys/class/gpio were all off by 32. For example, instead of creating /sys/class/gpio/gpio64 for GPIO2_0, /sys/class/gpio/gpio32 was created.

Second, I tried manually initializing and toggling the pin and saw no change in the output pin.

echo 64 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio64/direction
echo 1 > /sys/class/gpio/gpio64/value
echo 0 > /sys/class/gpio/gpio64/value

Third, I tried using libgpiod to toggle the output and that didn’t work either.

gpioset gpiochip2 0=0
gpioset gpiochip2 0=1

Then, I tried specifying the same pin on a different gpiochip and the output toggled.

gpioset gpiochip1 0=0
gpioset gpiochip1 0=1

I was also able to toggle the output using the second method, but subtracting 32 from the gpio#.

echo 32 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio32/direction
echo 1 > /sys/class/gpio/gpio32/value
echo 0 > /sys/class/gpio/gpio32/value

Obviously this work around doesn’t work for controlling pins on GPIO0 (gpio# less than 32).

Please help.

@dmccalla stop using gpio-of-helper and sys/class/gpio, for output use gpio-led, or for input use gpio-keys bindings.

If you don’t want to use device tree bindings, make sure you set a simple pinmux loaded like clkout2_pin is done here: am335x-bone-common.dtsi « omap « ti « dts « boot « arm « arch - kernel/git/torvalds/linux.git - Linux kernel source tree

Then use gpioset etc…


Thank you for the quick response.

Using gpio-led and gpio-keys will solve most of my GPIO needs, but I also use 8 GPIOs for a 4x4 matrix that supports up to 16 devices. Each position (row,col) either has a bi-color LED or push button switch. The matrix is scanned at 60Hz and each LED is flashed red/green or a switch is sampled. To do this the GPIOs are constantly changing from inputs to outputs.

Are there any working kernel modules that support bi-directional GPIOs?

For anyone else experiencing this problem, libgpiod and sysfs both work on ti-linux-rt-5.10 but not am33x-rt-v5.10. Since sysfs is deprecated, I will migrate to libgpiod. Since libgpiod is not working on am33x-rt-v5.10, I will migrate to ti-linux-rt-5.10.

Does anyone know the main difference between the TI kernel and Mainline kernel? The Mainline kernel felt like a better choice, but if gpio doesn’t work, that’s a deal breaker. I suspect I’ll run into more issues compiling kernel drivers using the TI kernel instead of Mainline.