Note: See attachment below for the pin mapping for CTI Jetson carriers.
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
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.
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