Documentation/Allspark2-Orin NX WikiEnglish · NX
Browse documentation
7 Developer Guide

7.8 GPIO Interface

The device provides four bidirectional GPIOs that support 3.3 V CMOS levels. The interface supports a 3.3 V external power output with a current of less than 1 A. The interface…

3 min read · English documentation

图片.png

The device provides four bidirectional GPIOs that support 3.3 V CMOS levels. The interface supports a 3.3 V external power output with a current of less than 1 A. The interface pin definition is shown below:

Pin Parameter PIN 1 PIN 2 PIN 3 PIN4 PIN 5 PIN6
I/O Name 3.3V IO9 IO11 IO1 IO13 GND
Internal Software Name / PAC.06 PQ.06 PQ.05 PH.00 /
Internal Software Number / 492 454 453 391 /

Register addresses:

Pin Number Register Address
PAC.06 0x02448030
PQ.06 0x02430070
PQ.05 0x02430068
PH.00 0x02434040

GPIO Function Test

Test Equipment

Power adapter, Allspark-Orin NX main unit, and a GPIO test cable. You must make the GPIO test cable yourself. The GPIO pin definition is shown below.

Test Objective

Test the functionality of the GPIO-related circuitry

Ubuntu 20.04 Test Procedure

  1. Enter the following command to become the superuser.
sudo su
  1. Enter the following command to set all outputs high. Use a multimeter to check whether the port voltages change to a high level.
gpioh_test
  1. Unexport the high-level port numbers.
gpio_unexport
  1. Enter the following command to set all outputs low. Use a multimeter to check whether the port voltages change to a low level.
gpiol_test
  1. Test an individual GPIO. For example, set PIN 2 (492/PAC.06) high.
echo 492 > /sys/class/gpio/export
echo out > /sys/class/gpio/PAC.06/direction
echo 1 > /sys/class/gpio/PAC.06/value
  1. Test an individual GPIO. For example, set PIN 2 (492) low.
echo 0 > /sys/class/gpio/PAC.06/value

Note

The GPIO control method changed in NVIDIA Jetson Linux 36.4 (JetPack 6.1).

Because of the NVIDIA kernel upgrade, the previous `/sys/class/gpio` control method is deprecated. A new method is now used to enable GPIO.

Ubuntu 22.04 Test Procedure

1. Prerequisite:

a. Install busybox.

sudo apt-get install busybox

2. Install libgpiod

a. Remove libgpiod from the local system:

sudo apt remove libgpiod2

b. Copy libgpiod to the Allspark2 Orin NX. (Alternatively, download libgpiod directly from GitHub.)

c. Install the automake build tools:

sudo apt-get install automake autoconf libtool  autoconf-archive

d. Install libgpiod:

(1) Extract libgpiod.

unzip libgpiod-master.zip

(2) Enter the directory.

cd libgpiod-master

(3) Run the installation commands.

sudo ./autogen.sh --enable-tools=yes
sudo make
sudo make install

e. Set the environment variable:

echo "export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
source ~/.bashrc
sudo ldconfig

Verify the installation:

gpioinfo --version

图片.png

Note

You can also use another version of libgpiod; configure it as needed.

3. Activating GPIO:

  1. Set a GPIO to output mode. busybox devmem <32-bit address> Here, <32-bit address> is the GPIO register address. For the Allspark2 Orin NX, the GPIO register addresses are shown below.

图片.png

Pin Parameter PIN 1 PIN 2 PIN 3 PIN4 PIN 5 PIN6
I/O Name 3.3V IO9 IO11 IO1 IO13 GND
Internal Software Name / PAC.06 PQ.06 PQ.05 PH.00 /
Internal Software Number / 492 454 453 391 /

Register addresses:

Pin Number Register Address
PAC.06 0x02448030
PQ.06 0x02430070
PQ.05 0x02430068
PH.00 0x02434040

For example, to set PIN2 to output mode:

  1. View the current value.
sudo busybox devmem 0x02448030

For details on configuring GPIO registers, refer to Orin-TRM.

  1. Set the GPIO to out mode.
sudo busybox devmem 0x02448030 w 0x004

图片.png

4. Changing GPIO State: GPIO9 (PAC.06) Example

  1. Set the direction of GPIO9 (PAC.06) to OUT.
sudo busybox devmem 0x02448030 w 0x004

Verify that the value was written successfully.

sudo busybox devmem 0x02448030

Note

IO9 (PAC.06) is high by default. All other GPIOs are low by default.
  1. Set GPIO9 (PAC.06) to a high level.
sudo gpioset PAC.06=1

图片.png

  1. Set GPIO9 (PAC.06) to a low level.
sudo gpioset PAC.06=0

图片.png

Commands for Controlling All GPIOs

(1) IO9 (PAC.06)

sudo busybox devmem 0x02448030
sudo busybox devmem 0x02448030 w 0x004  
sudo gpioset PAC.06=1 

(2) IO11 (PQ.06)

sudo busybox devmem 0x02430070
sudo busybox devmem 0x02430070 w 0x004  
sudo gpioset PQ.06=1 

(3) IO1 (PQ.05)

sudo busybox devmem 0x02430068 w 0x004 
sudo busybox devmem 0x02430068
sudo gpioset PQ.05=1 

(4) IO13 (PH.00)

sudo busybox devmem 0x02434040 w 0x004 
sudo busybox devmem 0x02434040
sudo gpioset PH.00=1