GPIO usage
This guide covers the Linux interface for GPIO operations using bash
Available GPIO's
The following output provides a list of all GPIO's that are available to the Jetson. This includes Tegra GPIO's as well as external driven GPIO extender.
Syntax: sudo cat /sys/kernel/debug/gpio
test@test-desktop:~$ sudo cat /sys/kernel/debug/gpio
[sudo] password for test:
gpiochip1: GPIOs 316-347, parent: platform/c2f0000.gpio, tegra234-gpio-aon:
gpio-316 (PAA.00 )
gpio-317 (PAA.01 )
gpio-318 (PAA.02 )
gpio-319 (PAA.03 )
gpio-320 (PAA.04 )
gpio-321 (PAA.05 |fixed-regulators:reg) out hi
gpio-322 (PAA.06 )
gpio-323 (PAA.07 )
gpio-324 (PBB.00 )
gpio-325 (PBB.01 )
gpio-326 (PBB.02 )
gpio-327 (PBB.03 )
gpio-328 (PCC.00 )
gpio-329 (PCC.01 )
gpio-330 (PCC.02 )
gpio-331 (PCC.03 |mux ) out hi
gpio-332 (PCC.04 )
gpio-333 (PCC.05 )
gpio-334 (PCC.06 )
gpio-335 (PCC.07 )
gpio-336 (PDD.00 )
gpio-337 (PDD.01 )
gpio-338 (PDD.02 )
gpio-339 (PEE.00 )
gpio-340 (PEE.01 )
gpio-341 (PEE.02 )
gpio-342 (PEE.03 )
gpio-343 (PEE.04 |power-key ) in hi IRQ ACTIVE LOW
gpio-344 (PEE.05 )
gpio-345 (PEE.06 )
gpio-346 (PEE.07 )
gpio-347 (PGG.00 )
gpiochip0: GPIOs 348-511, parent: platform/2200000.gpio, tegra234-gpio:
gpio-348 (PA.00 |fixed-regulators:reg) out lo
gpio-349 (PA.01 )
gpio-350 (PA.02 )
gpio-351 (PA.03 )
# And so on...
The GPIO numbers listed in the Linux operating system do not match with the numbers of the Jetson socket pins.
Export GPIO
At first, you have to export the GPIO that you want to use in the Linux file system in order to configure and read or write data from it.
Syntax: echo <GPIO_NR> > /sys/class/gpio/export
nvidia@nvidia-desktop:~$ echo 414 > /sys/class/gpio/export
nvidia@nvidia-desktop:~$
Change GPIO direction
The GPIO direction decides if the GPIO should be used as Input or Output
Syntax
echo <in|out> > /sys/class/gpio/gpio<GPIO_NR>/direction
Configure as Input
nvidia@nvidia-desktop:~$ echo in > /sys/class/gpio/gpio414/direction
nvidia@nvidia-desktop:~$
Configure as Output
nvidia@nvidia-desktop:~$ echo out > /sys/class/gpio/gpio414/direction
nvidia@nvidia-desktop:~$
Set GPIO Value
The logical GPIO level can be configure in the following ways. Keep in mind that its required to configure the GPIO as output before changing its output value.
Syntax
echo <0|1> > /sys/class/gpio/gpio<GPIO_NR>/value
Set low
nvidia@nvidia-desktop:~$ echo 0 > /sys/class/gpio/gpio414/value
nvidia@nvidia-desktop:~$
Set high
nvidia@nvidia-desktop:~$ echo 1 > /sys/class/gpio/gpio414/value
nvidia@nvidia-desktop:~$
Read GPIO state
Syntax
cat /sys/class/gpio/gpio<GPIO_NR>/value
The following example reads the current state of the GPIO. This operation works in output as well as in input mode.
nvidia@nvidia-desktop:~$ cat /sys/class/gpio/gpio414/value
0
nvidia@nvidia-desktop:~$ cat /sys/class/gpio/gpio414/value
1
Last updated
Was this helpful?