How to Control GPIO via Command Line on AM62x


The AM62x processor, developed by Texas Instruments (TI), is a high-performance, low-power processor widely used in industrial automation, automotive electronics, and other fields. The AM62x offers a rich set of GPIO interfaces that can be controlled via command-line tools. This article will explain how to control the GPIO on AM62x using the command line. It aims to help users accelerate product development and is for reference only. This guide is primarily applicable to the TI AM62x platform. For more ARM motherboard-related information, follow Weathink.


1. Preparations

Hardware: WTB-AM62XXS industrial control board, connected to a serial terminal.

Software: Linux operating system.

AM62XXS工控板_V02_TOP-宽770.png

Figure 1: WTB-AM62XXS Industrial Control Board


2. Confirm GPIO Number

The GPIO numbers for AM62x can be confirmed in the following ways:

Check the chip manual: The chip manual provides detailed information on each GPIO's number and function.

For example:

VOUTO DATA8/GPIO0_53: 396 + 53 = 449

VOUTO DATA9/GPIO0_54: 396 + 54 = 450

VOUTO DATA10/GPIO0_55: 396 + 55 = 451

GPIO1_30: 344 + 30 = 374


The base number for GPIO0 starts at 396, and for GPIO1, it starts at 344.


3. Command Line Control for GPIO


3.1 Configure GPIO as Input and Read Status

echo 374 >> /sys/class/gpio/export;      // Export GPIO1_30

echo in > /sys/class/gpio/gpio374/direction;  // Set GPIO as input

cat /sys/class/gpio/gpio374/value;       // Read GPIO status


3.2 Configure GPIO as Output and Set Status

echo 449 >> /sys/class/gpio/export;      // Export GPIO0_53

echo out > /sys/class/gpio/gpio449/direction;  // Set GPIO as output

echo 1 > /sys/class/gpio/gpio449/value;  // Set GPIO output to high level


4. Notes

Root privileges are required to operate GPIO.

Confirm the GPIO's multiplexing function before operation to avoid conflicts.

Pay attention to voltage levels to avoid damaging the chip.


Summary

This article explains how to control the GPIO on AM62x using the command line. With the libgpiod tool, you can easily set and read GPIO levels to implement various control functions.


For more technical support or design references, please contact Hangzhou Weathink Electronics Co., Ltd.

As a third-party partner of TI, Weathink can provide support in GPIO-related matters. We recommend using the AM62x core board designed by Weathink, the WTC-AM62XXS SOM:

https://www.weathink.com/products/hexinban/11.html



Tags: Array