Zero 3w gpiod issue

Hi, I just received this hat from waveshare:
https://www.waveshare.com/wiki/1.3inch_OLED_HAT

I managed to get screen working with gpiod over SPI but I can’t use buttons and joystick.

I’ve set pins as documentation (and converted pin number as radxa ones). But pin state doesn’t change when I press a button. I’ve tested gpiod pull up flags too.

Any idea?

Thanks

Rpi conf for this hat add pull-ups for buttons and joystick pins.

Trying to create an overlay :

dts
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/rockchip.h>

/ {
compatible = "radxa,zero3";

fragment@0 {
    target = <&{/}>;
    __overlay__ {
        buttons_joystick {
            compatible = "gpio-keys";
            pinctrl-names = "default";
            pinctrl-0 = <&buttons_joystick_pins>;

            key1 {
                label = "KEY1";
                gpios = <&gpio3 RK_PA5 GPIO_ACTIVE_LOW>;
                linux,code = <KEY_1>;
            };

            key2 {
                label = "KEY2";
                gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
                linux,code = <KEY_2>;
            };

            key3 {
                label = "KEY3";
                gpios = <&gpio3 RK_PA7 GPIO_ACTIVE_LOW>;
                linux,code = <KEY_3>;
            };

            joy_up {
                label = "JOY_UP";
                gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>;
                linux,code = <KEY_UP>;
            };

            joy_down {
                label = "JOY_DOWN";
                gpios = <&gpio3 RK_PA4 GPIO_ACTIVE_LOW>;
                linux,code = <KEY_DOWN>;
            };

            joy_left {
                label = "JOY_LEFT";
                gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
                linux,code = <KEY_LEFT>;
            };

            joy_right {
                label = "JOY_RIGHT";
                gpios = <&gpio1 RK_PA4 GPIO_ACTIVE_LOW>;
                linux,code = <KEY_RIGHT>;
            };

            joy_press {
                label = "JOY_PRESS";
                gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_LOW>;
                linux,code = <KEY_ENTER>;
            };
        };
    };
};

fragment@1 {
    target = <&pinctrl>;
    __overlay__ {
        buttons_joystick_pins: buttons-joystick-pins {
            rockchip,pins = 
                <3 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>,
                <3 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>,
                <3 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>,
                <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>,
                <3 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>,
                <3 RK_PB3 RK_FUNC_GPIO &pcfg_pull_up>,
                <1 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>,
                <3 RK_PC3 RK_FUNC_GPIO &pcfg_pull_up>;
        };
    };
};
};

Will it work ?

I haven’t looked at this hat specifically, but the first thing you’d need to do is figure out which physical RPi pins the the hat uses for button gpios, then look at the Radxa pinout to determine whether those physical pins are even available as gpios. Then you’d have to figure out whether those RPi gpios are active high or active low, because that will indicate whether the hat is pulling those pins high or low when the button is activated. Then you’d need to go back to the Radxa pinout again and determine whether the corresponding pins are also active high or low.

If any of the pins don’t match up exactly between the RPi and the Radxa, you might still be able to use the hat but probably not as a hat. Instead, you could use jumper wires to reroute the pins to available gpios.

Solved, I removed includes and substituted all values, then removed the KEY_* parts. I was able to compile it and use overlay, now all works well!

That’s fantastic news! Thanks for sharing!