Gpiod support on Radxa Zero

Hello again !

I followed the instructions to use libgpiod on a radxa on the wiki. I run Ubuntu server edition on a Radxa Zero. It installs fine. Running sudo gpioinfo returns :

gpiochip0 - 85 lines:
	line   0:      unnamed       unused   input  active-high
	line   1:      unnamed       unused   input  active-high
	line   2:      unnamed       unused   input  active-high
	line   3:      unnamed       unused   input  active-high
	line   4:      unnamed       unused   input  active-high
	line   5:      unnamed       unused   input  active-high
	line   6:      unnamed       unused   input  active-high
	line   7:      unnamed       unused   input  active-high
	line   8:      unnamed       unused   input  active-high
	line   9:      unnamed       unused   input  active-high
	line  10:      unnamed       unused   input  active-high
	line  11:      unnamed       unused   input  active-high
	line  12:      unnamed       unused   input  active-high
	line  13:      unnamed       unused   input  active-high
	line  14:      unnamed       unused   input  active-high
	line  15:      unnamed       unused   input  active-high
	line  16:      unnamed       unused   input  active-high
	line  17:      unnamed       unused   input  active-high
	line  18:      unnamed       unused   input  active-high
	line  19:      unnamed       unused   input  active-high
	line  20:      unnamed       unused   input  active-high
	line  21:      unnamed       unused   input  active-high
	line  22:      unnamed       unused   input  active-high
	line  23:      unnamed       unused   input  active-high
	line  24:      unnamed "regulator-vcc_5v" output active-low [used open-drain]
	line  25:      unnamed       unused  output  active-high
	line  26:      unnamed       unused   input  active-high
	line  27:      unnamed       unused  output  active-high
	line  28:      unnamed       unused   input  active-high
	line  29:      unnamed       unused   input  active-high
	line  30:      unnamed       unused   input  active-high
	line  31:      unnamed       unused   input  active-high
	line  32:      unnamed       unused   input  active-high
	line  33:      unnamed       unused   input  active-high
	line  34:      unnamed       unused   input  active-high
	line  35:      unnamed       unused   input  active-high
	line  36:      unnamed       unused   input  active-high
	line  37:      unnamed      "reset"  output   active-low [used]
	line  38:      unnamed       unused   input  active-high
	line  39:      unnamed       unused   input  active-high
	line  40:      unnamed       unused   input  active-high
	line  41:      unnamed       unused   input  active-high
	line  42:      unnamed       unused   input  active-high
	line  43:      unnamed       unused   input  active-high
	line  44:      unnamed       unused   input  active-high
	line  45:      unnamed       unused   input  active-high
	line  46:      unnamed       unused   input  active-high
	line  47:      unnamed         "cd"   input   active-low [used]
	line  48:      unnamed       unused   input  active-high
	line  49:      unnamed       unused   input  active-high
	line  50:      unnamed       unused   input  active-high
	line  51:      unnamed       unused   input  active-high
	line  52:      unnamed       unused   input  active-high
	line  53:      unnamed       unused   input  active-high
	line  54:      unnamed       unused   input  active-high
	line  55:      unnamed       unused   input  active-high
	line  56:      unnamed       unused   input  active-high
	line  57:      unnamed       unused   input  active-high
	line  58:      unnamed       unused   input  active-high
	line  59:      unnamed       unused   input  active-high
	line  60:      unnamed       unused   input  active-high
	line  61:      unnamed       unused   input  active-high
	line  62:      unnamed       unused   input  active-high
	line  63:      unnamed       unused   input  active-high
	line  64:      unnamed       unused   input  active-high
	line  65:      unnamed       unused   input  active-high
	line  66:      unnamed       unused   input  active-high
	line  67:      unnamed       unused   input  active-high
	line  68:      unnamed       unused   input  active-high
	line  69:      unnamed       unused   input  active-high
	line  70:      unnamed       unused   input  active-high
	line  71:      unnamed      "reset"  output   active-low [used]
	line  72:      unnamed       unused   input  active-high
	line  73:      unnamed       unused   input  active-high
	line  74:      unnamed       unused   input  active-high
	line  75:      unnamed       unused   input  active-high
	line  76:      unnamed       unused   input  active-high
	line  77:      unnamed       unused   input  active-high
	line  78:      unnamed       unused   input  active-high
	line  79:      unnamed       unused   input  active-high
	line  80:      unnamed       unused   input  active-high
	line  81:      unnamed       unused   input  active-high
	line  82:      unnamed   "shutdown"  output  active-high [used]
	line  83:      unnamed       unused   input  active-high
	line  84:      unnamed       unused   input  active-high
gpiochip1 - 15 lines:
	line   0:      unnamed       unused   input  active-high
	line   1:      unnamed       unused   input  active-high
	line   2:      unnamed       unused   input  active-high
	line   3:      unnamed       unused   input  active-high
	line   4:      unnamed       unused   input  active-high
	line   5:      unnamed       unused   input  active-high
	line   6:      unnamed       unused   input  active-high
	line   7:      unnamed       unused   input  active-high
	line   8:      unnamed "radxa-zero:green" output active-high [used]
	line   9:      unnamed       unused   input  active-high
	line  10:      unnamed       unused   input  active-high
	line  11:      unnamed       unused   input  active-high
	line  12:      unnamed       unused   input  active-high
	line  13:      unnamed       unused   input  active-high
	line  14:      unnamed       unused   input  active-high

If I compare this output with the one on the wiki (supposedly a Radxa Rockchip), I can see that all pins are unnamed on the RZ. But the interface seems functional.

Is gpiod supported on Radxa Zero ?

It works, there just aren’t any helpful labels for the gpio lines. There’s actually a patch pending for the Rock5 to do just this. Someone just needs to do something similar for the Radxa Zero.

done.

Oh my dog ! pull slash one !

:nerd_face:

I’m facing the same problem. I tried to find the line for GPIOAO_3, PIN7 by brute force. Unfortunately the device hangs at some point. Did somebody found the line for PIN7?

To control an RGB LED I need 3 pins. At the moment I use PIN3 and PIN5. At the moment I’m restricted to use PIN7. I could not find any other lines to control any other pin.

I used this chart for meson-g12a: https://github.com/torvalds/linux/blob/master/include/dt-bindings/gpio/meson-g12a-gpio.h

Pin 7 on the zero is GPIOAO3, which corresponds to line 3!

I also found this table.
https://wiki.radxa.com/Gpiod
But it is not representetive since some GPIO can have multiple lines.
gpioset 0 3=1
is not doing anything and sometimes the device hangs.

GPIOAO_3, PIN7 is on line 3 but on chip 1
gpioset 1 3=1
@Timbo header file was actually helpfull!

Someone said elsewhere on this forum that gpiod lines shouldn’t be filled by the board manufacturer (if I’m correct), so my pull request will not land. Anyway gpiod is supported on this platform, just not with the line names filled in. This settles that.

Now, quick howto get line names :

  • save the following content to /boot/gpiod-line-names.dts :
/dts-v1/;

/ {

    fragment@0 {
        target = <0xffffffff>;

        __overlay__ {
            gpio-line-names = "GPIOAO_0\0GPIOAO_1\0GPIOAO_2\0GPIOAO_3\0GPIOAO_4\0GPIOAO_5\0GPIOAO_6\0GPIOAO_7\0GPIOAO_8\0GPIOAO_9\0GPIOAO_10\0GPIOAO_11\0GPIOE_0\0GPIOE_1\0GPIOE_2";
        };
    };

    fragment@1 {
        target = <0xffffffff>;

        __overlay__ {
            gpio-line-names = "GPIOZ_0\0GPIOZ_1\0GPIOZ_2\0GPIOZ_3\0GPIOZ_4\0GPIOZ_5\0GPIOZ_6\0GPIOZ_7\0GPIOZ_8\0GPIOZ_9\0GPIOZ_10\0GPIOZ_11\0GPIOZ_12\0GPIOZ_13\0GPIOZ_14\0GPIOZ_15\0GPIOH_0\0GPIOH_1\0GPIOH_2\0GPIOH_3\0GPIOH_4\0GPIOH_5\0GPIOH_6\0GPIOH_7\0GPIOH_8\0BOOT_0\0BOOT_1\0BOOT_2\0BOOT_3\0BOOT_4\0BOOT_5\0BOOT_6\0BOOT_7\0BOOT_8\0BOOT_9\0BOOT_10\0BOOT_11\0BOOT_12\0BOOT_13\0BOOT_14\0BOOT_15\0GPIOC_0\0GPIOC_1\0GPIOC_2\0GPIOC_3\0GPIOC_4\0GPIOC_5\0GPIOC_6\0GPIOC_7\0GPIOA_0\0GPIOA_1\0GPIOA_2\0GPIOA_3\0GPIOA_4\0GPIOA_5\0GPIOA_6\0GPIOA_7\0GPIOA_8\0GPIOA_9\0GPIOA_10\0GPIOA_11\0GPIOA_12\0GPIOA_13\0GPIOA_14\0GPIOA_15\0GPIOX_0\0GPIOX_1\0GPIOX_2\0GPIOX_3\0GPIOX_4\0GPIOX_5\0GPIOX_6\0GPIOX_7\0GPIOX_8\0GPIOX_9\0GPIOX_10\0GPIOX_11\0GPIOX_12\0GPIOX_13\0GPIOX_14\0GPIOX_15\0GPIOX_16\0GPIOX_17\0GPIOX_18\0GPIOX_19";
        };
    };

    __fixups__ {
        gpio_ao = "/fragment@0:target:0";
        gpio = "/fragment@1:target:0";
    };
};
  • compile :
sudo dtc -@ -I dts -O dtb -o gpiod-line-names.dtbo gpiod-line-names.dts
  • add to uboot parameters. If using /boot/extlinux/extlinux.conf :
FDTOVERLAYS /boot/gpiod-line-names.dtbo

Now one should get line names with gpioinfo.

1 Like

What does this warning mean? How does one correct the dts file to avoid this warning?

# dtc -@ -I dts -O dtb -o gpiod-line-names.dtbo gpiod-line-names.dts
gpiod-line-names.dts:23.9-39: Warning (gpios_property): /__fixups__:gpio: property size (21) is invalid, expected multiple of 4