UP4000 GPIO using libgpiod in Rocky 9

z_tj
z_tj New Member Posts: 2

I am running Rocky 9 (kernel 5.14), and the sysfs GPIO interface (/sys/class/gpio) is now deprecated and replaced with libgpiod. I have installed libgpiod, and it appears to work, mostly.
However, I am having trouble finding the gpio-to-pin mapping and reading the gpio value back.

Is there any documentation that relates the gpiochip and line to the 40pin interface?
Comments in the forum suggest the following:
https://github.com/up-board/up-community/wiki/Pinout
But I can't find the gpiochip(n) and line(m) mapping. Where can I find this?

Through some testing, I was able to toggle the blue LED, and some GPIO's that I configured in the BIOS as outputs. Here is what I've found:

For example, the following toggles the Blue LED:
gpioset gpiochip0 73=1
gpioset gpiochip0 73=0

The following toggles pin 13 (also referred to as UP pinout GPIO4, or Linux GPIO 27).
gpioset gpiochip1 75=1
gpioset gpiochip1 75=0

FYI - using a previous kernel with sysfs(Centos 7.x), I was able to toggle pin 13 using the following
echo "1" >> /sys/class/gpio/gpio432/value
echo "0" >> /sys/class/gpio/gpio432/value
But this is now deprecated.

Here are a few pin associations I've been able to verify:
gpioset gpiochip1 38=$value #this controls pin 18
gpioset gpiochip1 74=$value #this controls pin 15
gpioset gpiochip1 73=$value #this controls pin 29
gpioset gpiochip1 37=$value #this controls pin 31

I can control a pin using gpioset, but when I read the same pin back, it sets the output to 0.
For example
gpioset gpiochip1 75=1 #output is asserted hi
gpioget gpiochip0 75 #this value reads back as zero, and the output is set to 0 (low).

Lastly, when I read chip0, pin 72, all three (red, green, yellow) LED's turn off.
gpioget gpiochip0 72 #turns off three LEDs

And when I try to set gpiochip0 72=1, the LED's do not restore.

Any clarification would be helpful.

Comments

  • z_tj
    z_tj New Member Posts: 2
    edited November 20

    Typo in the above question. It should read:

    For example
    gpioset gpiochip1 75=1 #output is asserted hi
    gpioget gpiochip1 75 #this value reads back as zero, and the output is set to 0 (low).

Privacy Policy