Testing Rockchip GPIO's from Ubuntu

Hi, is it possible to test the rockchip GPIO’s from Linux? Do you have a reference code or something for it?

To Configure GPIO Pins

  1. Here, you can find SOC GPIOs Header pins for Vaaman RK3399 Processor.
    https://docs.vicharak.in/vicharak_sbcs/vaaman/vaaman-gpio-description/

  2. The GPIOs are typically accessible in /sys/class/gpio folder.
    Each GPIO Pins have folder named as gpio<GPIO_NUMBER>.
    Example : GPIO PIN 40 => gpio135 for GPIO4_A7

    You need root permission to configure it, Make sure you’re in root User.
    by running command sudo su then, enter the root password OR you can run below commands using sudo.

    If the folder is not present, the GPIO needs to be exported first.

    echo 135 > /sys/class/gpio/export

    Similarly, you can also unexport it -

    echo 135 > /sys/class/gpio/unexport

  3. To read the value of GPIO number 135, need to first set the gpio as an output

    echo out > /sys/class/gpio/gpio135/direction

    Similarly, you can set gpio as an input

    echo in > /sys/class/gpio/gpio135/direction

  4. Read the value by

    cat /sys/class/gpio/gpio135/value

  • To set GPIO4_D5 as low

    echo 0 > /sys/class/gpio/gpio135/value

  • To set GPIO4_D5 as high

    echo 1 > /sys/class/gpio/gpio135/value

Or in simpler way, you can do this way,

sudo apt install libgpiod-dev
sudo gpioset gpiochipX <gpio_num>=value
sudo gpioget gpiochipX <gpio_num>

You can get more info by,

sudo gpioinfo