home Home > News > libgpiod Examples on Rockchip
Company News, Industry News, News

libgpiod Examples on Rockchip

Published: Dec 04, 2026

Share:

Run gpiodetect and gpioinfo to find the GPIO controller and line offset Linux exposes for a Rockchip pin. The libgpiod examples below use the version 2 command line to inspect a controller, read one input, and hold an output for a bench check.

A number printed next to a connector tells you where the wire goes. Linux needs two different pieces of information: the device for the GPIO controller and the offset of the line inside it. Work those out before running anything that can change the pin’s direction.

libgpiod examples cover with an RK3588 chip and GPIO jumper wires
RK3588 package and GPIO pin header. Editorial illustrations.

Find the GPIO line

Check the board pin table

Start with the manual or schematic for your board revision. On the Kiwi Pi 5 Pro board, the expansion connectors carry several kinds of signals. A connector can include GPIO alongside buses and power rails, so identify the signal name in its pin table and check the voltage for that signal’s I/O domain.

Top view of the Kiwi Pi 5 Pro board showing components and expansion connectors
Kiwi Pi 5 Pro product photo. Consult the pin table for your revision.

A UART or I2C pin may share a pad with GPIO through the SoC’s pin multiplexer. If the board image assigns that pad to a peripheral, use the peripheral driver for that job. The Rockchip UART console guide shows a case where board wiring and the running image both matter.

Rockchip names a GPIO by bank, port letter and bit. The bank identifies the on-chip controller. Within that bank, ports A, B, C and D start at offsets 0, 8, 16 and 24. For example, GPIO3_C2 means bank 3, offset 18, because C starts at 16 and the bit index is 2.

That’s a numbering example. It doesn’t identify a usable header pin on any particular board. And a Linux device called gpiochip3 can belong to a different controller, depending on which devices the image registered and in what order.

From connector position to Linux GPIO line
IdentifierWhat it tells you
Connector positionPhysical pin number in the board manual
SoC padGPIO3_C2 identifies bank 3, port C, bit 2
Linux GPIO chipMatch the bank to a controller reported by gpiodetect
Line offset18 within that controller (16 + 2)

Match the GPIO controller

Run gpiodetect and read the controller labels. Use the label and the board’s device tree or documentation to match the bank. An I2C GPIO expander can show up in the same list, with its own set of offsets.

Terminal · Bash
gpiodetect

Then run gpioinfo on the controller you identified. It shows line offsets and may show names, current direction and a consumer. A consumer can be a kernel driver or another program requesting the line. Leave lines in use alone unless you own that configuration and know what the consumer does.

Check the tool version before copying a command. Version 2 uses the chip option with a numeric offset. Older examples often pass the chip as the first positional argument. A syntax error is a good reason to read the local help before digging into the device tree.

Terminal · Bash
gpioinfo --version
# Replace CHIP with the controller you matched.
gpioinfo -c CHIP

Read and set GPIO

Read a spare input

For a documented spare input, supply a valid logic level with a suitable test circuit. Otherwise, a floating input can give you changing readings. Use the actual chip and offset you just checked, then run gpioget. If it fails, read the error before trying it again with elevated privileges.

Terminal · Bash
# Replace CHIP and OFFSET with the verified input.
gpioget -c CHIP OFFSET

Think about polarity when you read a value. When a request uses active-low semantics, the asserted logic state corresponds to a low physical level. A logical one and the voltage on a probe can therefore describe the same event in different ways.

Illustration of a GPIO pin header with jumper wires
GPIO pin header and jumper wires. Editorial illustration.

Hold an output

To try an output, choose a spare line you have verified in both the manual and gpioinfo. Keep it disconnected from other outputs and sensitive loads. Run gpioset with a value and observe the line while the process is still running. Use a suitable meter or logic probe at the documented voltage.

Terminal · Bash
# Replace CHIP and OFFSET with the verified output.
gpioset -c CHIP OFFSET=1

Stop gpioset with Ctrl+C to release the request. After that, the line’s state depends on the system. If another device needs that signal to start or stop reliably, define the desired boot and idle state in the hardware or platform software before you rely on it.

Diagnose GPIO errors

Check the line owner

A busy error means you should look for an owner. If gpioinfo lists a reset, interrupt, LED or regulator consumer, check the board configuration. In that case, the existing driver may already handle the signal the way the system needs.

Permission denied is a separate problem. Check the device node and the application’s service account. The app needs the intended device to be available to it with the appropriate permissions. Broad access to every GPIO controller can include lines that have nothing to do with the app.

Before ordering

Before ordering an embedded board, write down which signals are inputs, which are outputs, and what should happen before Linux starts. The RK3588 board comparison is a starting point for connector choices. Ask for a pin table for the exact revision and the supported image, especially if a line must hold an idle state through boot.

Rockchip Embedded Platforms

Configure RK3588 GPIO

Send your GPIO count, signal voltages, connector and boot-state requirements so we can discuss an RK3588 board or carrier that fits your project.

Top-view illustration of the Rockchip RK3588 processor package

FAQ

Does gpiochip3 always mean bank 3?

Check gpiodetect on the image you plan to ship. The chip number comes from Linux device enumeration. Match the controller label, line map and board revision before applying the offset.

Does reading a value change the direction?

The gpioinfo tool reports line properties without taking a new request. A value read with gpioget normally requests the line as an input. Use a documented spare line or check the tool’s local help for options before reading a line whose current direction matters.

Can I still use GPIO sysfs?

Existing images can still expose the legacy GPIO sysfs ABI. For new userspace work, use the character device and choose a libgpiod release the target kernel supports.

Technical references · libgpiod GPIO tools · Linux GPIO character device · RK3588 pin definitions

close_white

Contact US

    Name *

    Email Address *

    Phone

    Your Campany Name

    Message *