Using GPIO on High-Performance Processor RK3588

Using GPIO on High-Performance Processor RK3588

Basic Concept of GPIO

GPIO, or General-Purpose Input/Output, refers to the general input/output pins that can be controlled by software. Each GPIO pin can be configured as input or output to read the status of external devices (such as buttons) or control peripherals (such as LEDs, motors, etc.).

Application Areas of GPIO

As an indispensable interface in embedded devices, GPIO has a wide range of applications in the following areas:

Smart Home: Used to control and monitor appliances, lighting, curtains, sensors, and other smart devices, reading sensor status or sending control signals through GPIO pins.

Industrial Automation: GPIO is used to connect and control industrial machines, robots, sensors, etc., achieving automation processes through simple switch control mechanisms.

Internet of Things (IoT): GPIO is widely used in IoT devices for communication with sensors, actuators (such as relays), etc., to achieve data collection and device control.

Automotive Electronics: In vehicle systems, GPIO is used to connect various onboard sensors and actuators, providing control signals for vehicle lights, door locks, alarms, etc.

Robotics: GPIO is used to control motors, sensors, and other external devices in robots, achieving precise hardware control and feedback processing.

Using GPIO on High-Performance Processor RK3588

Using GPIO Interface on RK3588 Processor

On the RK3588 platform, the use of GPIO is very flexible, as it can be controlled through the sysfs interface provided by the kernel or debugged through debugfs. Below we will introduce how to operate GPIO through these two methods.

01

Selecting GPIO

Using GPIO on High-Performance Processor RK3588

We can see that the network label of pin 5 is UART9_RX_M0_BT, then we open the pin multiplexing manual and search based on this network label, finding the following multiplexing content:

Using GPIO on High-Performance Processor RK3588

We can see GPIO pin number GPIO2_C4, we will connect the positive pole of the LED to this GPIO and the negative pole to GND.

02

Controlling GPIO Using sysfs Interface

There are many ways to program GPIO in software, including writing driver programs to call GPIO functions, directly manipulating GPIO through register operations, or controlling GPIO through the sysfs method.

The sysfs interface is a standard method provided by the Linux kernel that allows users to manipulate GPIO in user space. By simple command line operations, GPIO pins can be controlled to light up or turn off LEDs. Here we use the simpler user-space method to control GPIO by configuring GPIO as output mode and writing high (1) or low (0) to control the switch of the LED.

Pin Number Calculation

Pin number = Base address of control register + Control pin register bit number.

Calculation method for GPIO2_PC4 pin:

bank = 2; //GPIO2_C4=> 2, bank ∈ [0,4]
group = 2; //GPIO2_C4 => 2, group ∈ {(A=0), (B=1), (C=2), (D=3)}
X = 4; //GPIO2_C4=>4, X ∈ [0,7]
number = group * 8 + X = 2 * 8 + 4 =20;
pin = bank*32 + number= 2 * 32 + 20 = 84;

▸ Exporting GPIO Pin

echo 84 > /sys/class/gpio/export

Using GPIO on High-Performance Processor RK3588

▸ Configuring GPIO as Output Mode

Next, set the GPIO pin to output mode:

echo “out” > /sys/class/gpio/gpio84/direction

Using GPIO on High-Performance Processor RK3588

▸ Controlling LED Switch

Control the state of the LED by writing 1 or 0 to the value file of GPIO:

Turn on LED:

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

Using GPIO on High-Performance Processor RK3588

Turn off LED:

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

Using GPIO on High-Performance Processor RK3588

Releasing GPIO Pin

After use, GPIO can be removed from user space:

echo 84 > /sys/class/gpio/unexport

Using GPIO on High-Performance Processor RK3588

03

GPIO Debugging

In more advanced debugging scenarios, the debugfs file system provides in-depth viewing and debugging capabilities for GPIO pin status and multiplexing. You can obtain detailed information about GPIO through the following steps:

▸ View GPIO input/output mode, pull-up/pull-down settings, and other electrical properties

cat /sys/kernel/debug/pinctrl/pinctrl-rockchip-pinctrl/pinconf-pins | grep 84

Using GPIO on High-Performance Processor RK3588

▸ View the function modes, pin multiplexing choices, and other related configuration information for each pin

cat /sys/kernel/debug/pinctrl/pinctrl-rockchip-pinctrl/pinmux-pins | grep 84

Using GPIO on High-Performance Processor RK3588

Through this file, you can confirm the current multiplexing configuration for each pin, for example, a pin may be multiplexed as a control pin for UART, SPI, etc. If you want to reconfigure it as a GPIO pin, adjustments can be made through the device tree.

Note: For detailed usage, refer to “[Beijing Xunwei] itop-3588 Development Board Driver Development Guide”.

■ Follow the “Xunwei Electronics” WeChat public account for tutorials, materials, industry insights, and product information.

■ For more information about Xunwei, feel free to contact us:

Sales Engineer: 010-8527-0708 Ext. 1

Technical Support: 010-8527-0708 Ext. 2

Custom Solutions: 010-8527-0708 Ext. 3

■ Real-time technical support:

AM 9:00—12:00, PM 13:30—17:30 (Monday to Saturday)

Technical Group Chat【622417498

END

Long press to scan the QR code to follow

Using GPIO on High-Performance Processor RK3588

Xunwei Electronics

Making learning easier and development simpler

Using GPIO on High-Performance Processor RK3588
http://www.topeet.com/

Using GPIO on High-Performance Processor RK3588

Using GPIO on High-Performance Processor RK3588 Using GPIO on High-Performance Processor RK3588

【Android 11 System Porting】 NVR SolutionEmpowering AI DVRs

Using GPIO on High-Performance Processor RK3588 Using GPIO on High-Performance Processor RK3588

【RK3568】HarmonyOS Demonstration 【RK3568】SDK Upgrade

Leave a Comment

×