kdb379: GPIO Pin Mapping for Jetson Carriers

Note: See attachment below for the pin mapping for CTI Jetson carriers.

GPIOJetsonCarriers.xlsx

Updated GPIO pin mapping for CTI Jetson carrier boards. Using the Jetson GPIO pins is primarily done using the Linux sysfs or the Jetson pin number.

To use a GPIO pin from the Jetson first it will need to be “exported”.  This tells the Tegra’s GPIO driver that the pin is to be used as a GPIO. The example below demonstrates how to export pin 186 to be used as a GPIO:

echo 186 > /sys/class/gpio/export

The GPIO Reference Table maps out which pin on your carrier maps to which sysfs pin number.  For this example we will continue using pin 186.

The pin can be set as either an input or an output. The following sets pin 186 to be an output:

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

OR:

echo out > /sys/class/gpio/PH.00/direction

*Note that depending on board and JetPack version the pin may show up in /sys/class/gpio as it’s pin number (ex. PH.00), in this case you can still interact with the pin the same way by referencing it with it’s pin number instead.

While this would set pin 186 to be an input (default):

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

Another option is changing if the pin is an “active high” (reads 1 when the pin is held high), or “active low” (reads 1 when the pin is held low). This is modified by writing a 0 or 1 to “active_low” this would set pin 186 to be active low:

echo  1 > /sys/class/gpio/gpio186/active_low

Now that the pin is setup, you can read or write to it using the “value” file.

This reads the current value of the pin, returning 1 or 0.

cat /sys/class/gpio/gpio186/value

While this writes a 1 to the pin (if the pin is configured to be an output)

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

If you would like to monitor an input pin in the terminal to see if it is being toggled you can use this command.  It continuously reads the value of the pin every 0.1 seconds and shows it in the terminal.  It can be exited by using ctrl-c.

while [ True ] ; do echo -ne $(cat /sys/class/gpio/gpio186/value) “\r”; sleep 0.1;  done

For JetPack 6 GPIO have been updated to use the libgpiod library instead of using the Linux sysfs used in prior JetPack versions.  For additional information and lists of tools and commands that can be used with libgpiod please visit the following page: https://kernel.googlesource.com/pub/scm/libs/libgpiod/libgpiod/+/v0.2.x/README.md

Full API documentation can be found below:

libgpiod: libgpiod public API

To use a GPIO pin from the Jetson first you can run the command ‘gpioinfo’. This will give a full list of all gpiochips, corresponding controller IDs and line numbers for a given GPIO. The example below demonstrates how to configure GPIO1 of the Forge Carrier for NVIDIA® Jetson AGX Orin™.

After ‘gpioinfo’ is run look for the corresponding GPIO for the given Controller ID. You can find the tables of Controller IDs corresponding to the GPIO of each carrier board in the bottom section of this article. In the case of GPIO1 on Forge, the Controller ID is PAC.05. PAC.05 can be found under gpiochip0 line 143. You can also run the command ‘gpiofind’ to return both the gpiochip as well as line number. If you run the command ‘gpiofind PAC.05’ it will return ‘gpiochip0 143’. Once you have the gpiochip and line number you can set the value of the given GPIO. To do this you can run the ‘gpioset’ command:

gpioset gpiochip0 143=1

This will momentarily toggle the GPIO and then return to its default state. If instead of a pulse you want to toggle the GPIO and hold its state you can run the following command instead:

gpioset -m wait gpiochip0 143=1

Alternatively you can combine the ‘gpioset’ and ‘gpiofind’ commands to skip the lookup of gpiochip number and line number as long as you provide the Controller ID. You can do this by running the command:

gpioset -m wait $(gpiofind PAC.05)=1

Boson Carrier – NGX007/NGX017

Photon Carrier – NGX002/NGX003

Quark Carrier – NGX004/NGX014

Hadron Carrier – NGX012

Rogue for AGX Xavier – AGX101

Rogue for AGX Orin – AGX202

Forge for AGX Orin – AGX201

Rudi NX – ESG605

Rudi AGX – ESG610

Go to Top