Introduction
Using the Jetson Xavier/TX2/TX1 GPIO pins is primarily done using the Linux sysfs (for pins directly connected to Jetson) or I2C read/writes (for pins using I2C GPIO expanders). The “pin# (source)” column of the table has details about which GPIO pins are sourced directly from the Jetson and which ones use an I2C GPIO expander for your carrier.
GPIO TX1 Reference Table
Part Number | Board Name | Pin # (source)* | Carrier Designator (Header-Pin#) | Voltage Level | sysfs # | In/out (default) | PU/PD (ohms) | Device Tree Name |
---|---|---|---|---|---|---|---|---|
ASG001, ASG004 | Astro | H13 (TX1) | P4-1 | 1.8 | 187 | in | PU (100K) | als_prox_int_px3 |
G14 (TX1) | P4-3 | 1.8 | 186 | in | PU (100K) | motion_int_px2 | ||
A22 (TX1) | P4-5 | 1.8 | 89 | in | PU (100K) | pl1 | ||
A23 (TX1) | P4-7 | 1.8 | 202 | in | PU (100K) | pz2 | ||
ASG002 | Elroy | H13 (TX1) | P5-12 | 1.8 | 187 | in | PU (100K) | als_prox_int_px3 |
G14 (TX1) | P5-14 | 1.8 | 186 | in | PU (100K) | motion_int_px2 | ||
A22 (TX1) | P5-16 | 1.8 | 89 | in | PU (100K) | pl1 | ||
A23 (TX1) | P5-18 | 1.8 | 202 | in | PU (100K) | pz2 | ||
ASG003, ASG016 | Orbitty, Quasar | H13 (TX1) | P4-7 | 3.3 | 187 | in | PU (100K) | als_prox_int_px3 |
G14 (TX1) | P4-8 | 3.3 | 186 | in | PU (100K) | motion_int_px2 | ||
A22 (TX1) | P4-9 | 3.3 | 89 | in | PU (100K) | pl1 | ||
A23 (TX1) | P4-10 | 3.3 | 202 | in | PU (100K) | pz2 | ||
ESG503, ASG005 | Rudi | P00 (TCA9539@74) | I/O -5 | 3.3 | 488 | in | None | TBD |
P01 (TCA9539@74) | I/O -6 | 3.3 | 489 | in | None | TBD | ||
P02 (TCA9539@74) | I/O -7 | 3.3 | 490 | in | None | TBD | ||
P03 (TCA9539@74) | I/O -8 | 3.3 | 491 | in | None | TBD | ||
ASG006 | Spacely | P00 (TCA9539@77) | P13-15 | 3.3 | 472 | in | None | TBD |
P01 (TCA9539@77) | P13-16 | 3.3 | 473 | in | None | TBD | ||
P02 (TCA9539@77) | P13-13 | 3.3 | 474 | in | None | TBD | ||
P03 (TCA9539@77) | P13-14 | 3.3 | 475 | in | None | TBD | ||
P04 (TCA9539@77) | P13-11 | 3.3 | 476 | in | None | TBD | ||
P05 (TCA9539@77) | P13-12 | 3.3 | 477 | in | None | TBD | ||
P06 (TCA9539@77) | P13-9 | 3.3 | 478 | in | None | TBD | ||
P07 (TCA9539@77) | P13-10 | 3.3 | 479 | in | None | TBD | ||
P10 (TCA9539@77) | P13-7 | 3.3 | 480 | in | None | TBD | ||
P11 (TCA9539@77) | P13-8 | 3.3 | 481 | in | None | TBD | ||
P12 (TCA9539@77) | P13-5 | 3.3 | 482 | in | None | TBD | ||
P13 (TCA9539@77) | P13-6 | 3.3 | 483 | in | None | TBD | ||
P14 (TCA9539@77) | P13-3 | 3.3 | 484 | in | None | TBD | ||
P15 (TCA9539@77) | P13-4 | 3.3 | 485 | in | None | TBD | ||
P16 (TCA9539@77) | P13-1 | 3.3 | 486 | in | None | TBD | ||
P17 (TCA9539@77) | P13-2 | 3.3 | 487 | in | None | TBD | ||
ASG007 | Cogswell | P0 (XRA1200@20) | P7-3 | 3.3 | 496 | in | None | TBD |
P1 (XRA1200@20) | P7-1 | 3.3 | 497 | in | None | TBD | ||
P2 (XRA1200@20) | P7-4 | 3.3 | 498 | in | None | TBD | ||
P3 (XRA1200@20) | P7-2 | 3.3 | 499 | in | None | TBD | ||
ASG008 | Sprocket | H13 (TX1) | P2-7 | 3.3 | 187 | in | PU (100K) | als_prox_int_px3 |
G14 (TX1) | P2-8 | 3.3 | 186 | in | PU (100K) | motion_int_px2 | ||
A22 (TX1) | P2-9 | 3.3 | 89 | in | PU (100K) | pl1 | ||
A23 (TX1) | P2-10 | 3.3 | 202 | in | PU (100K) | pz2 | ||
* Format for GPIOs directly from the TX1 : [A#] (TX1), where the A# is the TX1 Module Pin #; Format for the GPIOs from I2C Expanders: [P##] ([Part#]@[I2C##]) Where P## is the Expander's GPIO #, Part# is the I2C expander part # and @I2C## is the Expander's I2C Address |
GPIO TX2 Reference Table
Part Number | Board Name | Pin # (source)* | Carrier Designator (Header-Pin#) | Voltage Level | sysfs # | In/out (default) | PU/PD (ohms) | Device Tree Name |
---|---|---|---|---|---|---|---|---|
ASG001, ASG004 | Astro | H13 | P4-1 | 1.8 | 388 | in | PU (20K) | gpio_pq4_pi4 |
G14 | P4-3 | 1.8 | 298 | in | PU (20K) | can_gpio2_paa2 |
||
A22 | P4-5 | 1.8 | 480 | in | PU (100K) | gpio_mdm7_py6 |
||
A23 | P4-7 | 1.8 | 486 | in | PU (100K) | gpio_mdm1_py0 |
||
ASG002 | Elroy | H13 | P5-12 | 1.8 | 388 | in | PU (20K) | gpio_pq4_pi4 |
G14 | P5-14 | 1.8 | 298 | in | PU (20K) | can_gpio2_paa2 | ||
A22 | P5-16 | 1.8 | 480 | in | PU (100K) | gpio_mdm7_py6 | ||
A23 | P5-18 | 1.8 | 486 | in | PU (100K) | gpio_mdm1_py0 | ||
ASG003, ASG016 | Orbitty, Quasar | H13 | P4-7 | 3.3 | 388 | in | PU (20K) | gpio_pq4_pi4 |
G14 | P4-8 | 3.3 | 298 | in | PU (20K) | can_gpio2_paa2 | ||
A22 | P4-9 | 3.3 | 480 | in | PU (100K) | gpio_mdm7_py6 | ||
A23 | P4-10 | 3.3 | 486 | in | PU (100K) | gpio_mdm1_py0 | ||
ESG503, ASG005 | Rudi | P00 (TCA9539@74) | I/O -5 | 3.3 | 232 | in | None | TBD |
P01 (TCA9539@74) | I/O -6 | 3.3 | 233 | in | None | TBD | ||
P02 (TCA9539@74) | I/O -7 | 3.3 | 234 | in | None | TBD | ||
P03 (TCA9539@74) | I/O -8 | 3.3 | 235 | in | None | TBD | ||
ASG006 | Spacely | P00 (TCA9539@77) | P13-15 | 3.3 | 216 | in | None | TBD |
P01 (TCA9539@77) | P13-16 | 3.3 | 217 | in | None | TBD | ||
P02 (TCA9539@77) | P13-13 | 3.3 | 218 | in | None | TBD | ||
P03 (TCA9539@77) | P13-14 | 3.3 | 219 | in | None | TBD | ||
P04 (TCA9539@77) | P13-11 | 3.3 | 220 | in | None | TBD | ||
P05 (TCA9539@77) | P13-12 | 3.3 | 221 | in | None | TBD | ||
P06 (TCA9539@77) | P13-9 | 3.3 | 222 | in | None | TBD | ||
P07 (TCA9539@77) | P13-10 | 3.3 | 223 | in | None | TBD | ||
P10 (TCA9539@77) | P13-7 | 3.3 | 224 | in | None | TBD | ||
P11 (TCA9539@77) | P13-8 | 3.3 | 225 | in | None | TBD | ||
P12 (TCA9539@77) | P13-5 | 3.3 | 226 | in | None | TBD | ||
P13 (TCA9539@77) | P13-6 | 3.3 | 227 | in | None | TBD | ||
P14 (TCA9539@77) | P13-3 | 3.3 | 228 | in | None | TBD | ||
P15 (TCA9539@77) | P13-4 | 3.3 | 229 | in | None | TBD | ||
P16 (TCA9539@77) | P13-1 | 3.3 | 230 | in | None | TBD | ||
P17 (TCA9539@77) | P13-2 | 3.3 | 231 | in | None | TBD | ||
ASG007 | Cogswell | P0 (XRA1200@20) | P7-3 | 3.3 | 240 | in | None | TBD |
P1 (XRA1200@20) | P7-1 | 3.3 | 241 | in | None | TBD | ||
P2 (XRA1200@20) | P7-4 | 3.3 | 242 | in | None | TBD | ||
P3 (XRA1200@20) | P7-2 | 3.3 | 243 | in | None | TBD | ||
ASG008 | Sprocket | H13 | P2-7 | 3.3 | 388 | in | PU (20K) | gpio_pq4_pi4 |
G14 | P2-8 | 3.3 | 298 | in | PU (20K) | can_gpio2_paa2 | ||
A22 | P2-9 | 3.3 | 480 | in | PU (100K) | gpio_mdm7_py6 | ||
A23 | P2-10 | 3.3 | 486 | in | PU (100K) | gpio_mdm1_py0 | ||
* Format for GPIOs directly from the TX2 : [A#] (TX1), where the A# is the TX1 Module Pin #; Format for the GPIOs from I2C Expanders: [P##] ([Part#]@[I2C##]) Where P## is the Expander's GPIO #, Part# is the I2C expander part # and @I2C## is the Expander's I2C Address |
GPIO Xavier Reference Table
Part Number | Board Name | Pin # (source)* | Carrier Designator (Header-Pin#) | Voltage Level | sysfs # | In/out (default) | PU/PD (ohms) | Device Tree Name |
---|---|---|---|---|---|---|---|---|
AGX001 | Mimic | E10 | TX2-GPIO12 | 1.8V | 440 | TBD | TBD | TBD |
G7 | TX2-GPIO13 | 1.8V | 443 | TBD | TBD | TBD |
||
L15 | TX2-GPIO10 | 1.8V | 444 | TBD | TBD | TBD |
||
A54 | TX2-GPIO11 | 1.8V | 417 | TBD | TBD | TBD |
||
K56 | TX2-GPIO15 | 1.8V | TBD | TBD | TBD | TBD |
||
G55 | TX2-GPIO17 | 1.8V | TBD | TBD | TBD | TBD |
||
J51 | TX2-GPIO14 | 1.8V | TBD | TBD | TBD | TBD |
||
H51 | TX2-GPIO16 | 1.8V | TBD | TBD | TBD | TBD |
||
H52 | TX2-GPIO18 | 1.8V | TBD | TBD | TBD | TBD |
||
A7 | TX2-GPIO9 | 1.8V | 412 | BiDir | TBD | TBD |
||
J55 | TX2-GPIO8 | 1.8V | 438 | BiDir | TBD | TBD |
||
C55 | TX2-GPIO_EXP0_INT | 1.8V | 414 | BiDir | TBD | TBD |
||
L50 | TX2-GPIO_EXP1_INT | 1.8V | 344 | BiDir | TBD | TBD |
||
AGX101 | Rogue | E10 | P3-13 | 3.3V | 440 | In | PU (100k) | SOC_GPIO33_PT0 |
G7 | P3-15 | 3.3V | 443 | In | PU (100k) | DAP3_DIN_PT3 | ||
L15 | P3-17 | 3.3V | 444 | In | PU (100k) | DAP3_FS_PT3 | ||
A54 | P3-19 | 3.3V | 417 | In | PD (100k) | SOC_GPIO21_PQ1 | ||
* Format for GPIOs directly from the Xavier : [A#] (TX1), where the A# is the Xavier Module Pin #; Format for the GPIOs from I2C Expanders: [P##] ([Part#]@[I2C##]) Where P## is the Expander's GPIO #, Part# is the I2C expander part # and @I2C## is the Expander's I2C Address |
GPIO Sentry-X Reference Table
Part Number | Board Name | Pin # (source) | Designator (PC Style D-SUB 44) | Designator (Fischer MiniMax) | Voltage Level | sysfs # | Sentry X Function |
---|---|---|---|---|---|---|---|
SGX001 | Sentry-X | E59 | J4 pin 29 | J5 pin 1 | 5V | 253 | ZEROIZE |
F59 | Internal | Internal | 1.8V | 254 | LED_CTL0 | ||
B62 | Internal | Internal | 1.8V | 256 | LED_CTL1 | ||
C61 | Internal | Internal | 1.8V | 257 | LED_CTL2 | ||
B8 | J4 pin 34 | J5 pin 22 | 5V | 437 | GPO0 | ||
E10 | J4 pin 33 | J5 pin 11 | 5V | 440 | GPO1 | ||
G7 | J4 pin 32 | J5 pin 12 | 5V | 443 | GPO2 | ||
L15 | J4 pin 31 | J5 pin 24 | 5V | 444 | GPO3 | ||
F10 | J4 pin 4 | J5 pin 16 | 5V | 445 | GPI0 | ||
F9 | J4 pin 3 | J5 pin 7 | 5V | 446 | GPI1 | ||
A54 | J4 pin 2 | J5 pin 8 | 5V | 417 | GPI2 | ||
C55 | J4 pin 1 | J5 pin 18 | 5V | 420 | GPI3 | ||
K56 | Internal | Internal | 1.8V | 423 | SERIAL1_MODE (0=RS232 or 1=RS485) | ||
A58 | Internal | Internal | 1.8V | 291 | SERIAL1_DUPLEX (0=Full Duplex, 1=Half Duplex) | ||
B58 | Internal | Internal | 1.8V | 288 | SERIAL1_TERM (0=No Term, 1=120ohm Term) | ||
G55 | Internal | Internal | 1.8V | 490 | SERIAL2_MODE (0= RS232 or 1=RS485) | ||
J51 | Internal | Internal | 1.8V | 387 | SERIAL2_DUPLEX (0=Full Duplex, 1=Half Duplex) | ||
K49 | Internal | Internal | 1.8V | 389 | SERIAL2_TERM (0=No Term, 1=120ohm Term) |
Using GPIO Pins Sourced Directly from the Xavier/TX2/TX1
To use a GPIO pin that is sourced directly 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
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
Using GPIO Pins Sourced from I2C Expanders
Some of Connect Tech’s carriers use I2C GPIO expanders for their external GPIO pins. These are interfaced with by using the I2C utilities in Linux to read and write from the I2C IC. The table below gives a breakdown of which expanders are on each board, what I2C address they are set to and which I2C bus they are on.
Part Number | Board Name | Expander Part# | I2C address | I2C Bus Number |
---|---|---|---|---|
ESG503, ASG005 | Rudi | TI TCA9539 | 0x74 | L4T24.2.1 - /dev/i2c0 L4T28.1 - /dev/i2c1 |
ASG006 | Spacely | TI TCA9539 | 0x77 | L4T24.2.1 - /dev/i2c1 L4T28.1 - /dev/i2c0 |
ASG007 | Cogswell | Exar XRA1200 | 0x20 | L4T24.2.1 - /dev/i2c0 L4T28.1 - /dev/i2c1 |
Configuration using I2C
These are some brief descriptions of important registers that can be read and written to on the I2C expanders, more details can be found in the datasheets linked in the table:
0x00 = Input 0 – 7 Status Register (Not all inputs/outputs are implemented on all carriers see the GPIO Reference Table)
0x01 = Input 8 – 15 Status Register (Not all inputs/outputs are implemented on all carriers see the GPIO Reference Table)
0x02 = Output 0-7 Register – Default = 0xFF, 0 = GND, 1 = 3.3V HIGH (only valid if I/O set to an output in register 0x06)
0x03 = Output 8-15 Register – Default = 0xFF, 0 = GND, 1 = 3.3V HIGH (only valid if I/O set to an output in register 0x06)
0x06 = I/O Mode 0-7 set register – Default = 0xFF (all inputs), (0 = output, 1 = input)
0x07 = I/O Mode 8-15 set register – Default = 0xFF (all inputs), (0 = output, 1 = input)
To read a register from the I2C Expander you can use:
i2cget -y (BUS) (ADDR) (REGISTER)
To write to a register use:
i2cset –y (BUS) (ADDR) (REGISTER) (DATA)
Here is an example of how to set pin I/O-5 on the Rudi as an input:
i2cset –y 0x0 0x06 0x74 0x01 #P00 as input
To read the value of the inputs on the Rudi:
i2cget -y 0x0 0x74 0x00 #least significant bit of the return value is value of I/O-5(P00)
If you wish to access the GPIO devices via the I2C when the driver is holding the address (i2cdetect returns UU on address), you may add the -f flag to either the i2cget and ic2set commands.
Configuration using GPIO using I2C Driver
When the Connect Tech Board Support Package is installed using TX2/TX1, (see release notes for details). The GPIO are accessible through the system driver. This can be assessed by applying the driver to the I2C BUS of the Expansion IC (See above Table for I2C BUS).
Check the following command to see if the Driver is already applied you will see a UU under the address location:
i2cdetect (BUS)
If the bus is not held by the driver than you will see the address number under the location such as 74 for the RUDI. You may set the driver with the following command:
echo (NOTE 1) (ADDR) > /sys/bus/i2c/devices/(BUS)/new_device
When the BUS is taken by the driver the corresponding address of the I2C Expander will be occupied by a UU. You may also see the GPIO ports assigned to the expander by issuing the following command:
cat /sys/kernel/debug/gpio
To use the GPIO on the expander you must release the GPIO port from the driver using the following command:
echo (SYSFS) > /sys/class/gpio/export
When in this directory, you may use the echo commands as done previously Using GPIO Pins Sourced Directly from the Xavier/TX2/TX1 section.