Jetson/GPIO

GPIO on Jetson TK1
The Jetson TK1 has both a 50-pin and a 75-pin expansion port, both with 2mm spacing in rows of 25 pins:
 * J3A1 (SKT2X25_THR_R 50-pin 2-row 2mm-spaced socket)
 * J3A2 (SKT3X25_THR_R 75-pin 3-row 2mm-spaced socket).

The sockets on the board are female, so you have a few options for physically connecting to the expansion ports:
 * The Samtec TW-25-06-F-5-420-110 header can cover the whole 5x25 expansion port. It might be difficult to find if you just want 1 or 2 of them.
 * You could use separate 3x25 + 2x25 connectors such as a 2-row connector from Digikey.
 * You could just connect to some of the pins individually with solid hookup work or breadboarding pins, particularly if you just want access to several pins.
 * You could build a PCB board with pins sticking out at 2mm spacing, providing you access to potentially all 125 expansion port pins.

If you are building your own kernel or using an early L4T kernel before 19.2, then you need to make sure your kernel .config file contains this before building your kernel: CONFIG_GPIO_SYSFS=y

Controlling GPIO pins from user-space
Follow the simple Jetson TK1 GPIO tutorial to test a single GPIO pin using sysfs manually from the command-line.

You can also do the equivalent sysfs operations by writing code that accesses those files (eg: using C/C++, Python, Perl, Bash, Java or whatever you want) and then running your code using root permissions. There is an Introduction to sysfs-based GPIO video with associated source-code showing how to do this using C/C++ (shown for BeagleBone, but sysfs-based GPIO programming is the same on Jetson TK1). More details are in the Jetson TK1 Vision-controlled GPIO tutorial.

Jetson TK1 Power pinouts
+12V (VDD_MUX) is available on pin 25 on J3A1. It can supply upto 400mA (4.8W). +5V is available on pin 1 on J3A1 (bottom-right pin of the dual-row header, next to the text saying "DISPLAY TOUCH"). It can supply upto 500mA (2.5W).

+3.3V is available on pin 16 on J3A1. It can supply upto 500mA (1.65W). Another +3.3V is available on pin 22 (+3.3V_RUN, intended for powering an LCD) that can supply an additional 450mA (1.5W).

+1.8V is available on pin 3 on J3A1 as well as pin 19. It can supply upto 400mA (0.7W).

GND is available on pin 2 on J3A1 (see the image above) as well as pins 8, 9, 14, 15, 26, 47 and many others.

Note: Several other pins can also supply 1.05V, 1.2V and 2.8V at lower currents, for powering CSI cameras.

Jetson TK1 GPIO pinouts
In addition to gpio57 shown in the GPIO Tutorial, you can also access gpio160 to gpio166 (ports GPIO_PU0 to GPIO_PU6) as GPIO, and potentially various other pins too if you don't use 2 CSI cameras, etc.



Full pinouts are provided in JTK1_DevKit_Specification.pdf, but the PDF is protected and it can be a pain to work with tabular data in that format. This is a transcription of the J3A1 and J3A2 pinouts, with an added column for connector row. (Try sorting by that, to easily see which pins are adjacent.) You should be able to paste this into the spreadsheet of your choice for easier manipulation:

PWM output
See the PWM page for details about how to generate PWM output, such as to control the speed of a motor or brightness of an LED.

I2C / I²C (I-squared-C) / TWI (Two-Wire-Interface) communication
See the I2C page for details about I2C on Jetson TK1.

SPI (Serial Peripheral Interface) / Three-Wire or Four-Wire Interface / SSI communication
See the forum discussion for details about SPI communication.

You can also find a detailed tutorial on using the touch screen SPI of the Jetson TK1 to send and receive high speed data (25 MHz). It shows how to connect the Jetson's SPI channels to an Arduino Due to stream high-speed data back and forth. Detailed instructions are provided that show how to configure the kernel to enable spidev, how to modify the device tree to create a spidev controller, and includes source code for both the Jetson TK1 and Arduino Due to stream data. It also shows how to use the Jetson connector and level shifter boards described below in the electrical connections section. You can find the post here: http://neurorobotictech.com/Community/Blog/tabid/184/ID/11/Using-the-Jetson-TK1-SPI--Part-1-Why-is-SPI-important.aspx

Jetson TK1 GPIO electrical connections
The GPIO pins on Jetson TK1 are all 1.8V logic and can only supply a few milli-amps of current, so you can't simply attach common 5V or 3.3V logic signals or devices directly to the Jetson TK1 GPIO pins. There are several options for using the 1.8V GPIO:
 * Build your own transistor or FET based switching circuit. This is a reasonable solution if you just want to turn on 1-2 output pins and/or read 1-2 input pins and you don't need high-speed or bidirectional behavior. For example, if you only want to turn on a single LED or motor or relay then you could connect a GPIO pin through a resistor to a transistor, and get the transistor to turn on the LED, motor or relay (with a flyback diode for protection), such as shown in the circuit on the right. (You can [[Media:JetsonTK1_DigOut_KiCad.zip|download this schematic for KiCad]]). You can also learn more about using a Transistor as a switch. See the GPIO tutorial for an example circuit.
 * Use a bidirectional logic level shifter to allow bidirectional behavior at high-speeds for multiple GPIO pins. This is the recommended option, particularly if you want to use more than 2 or 3 GPIO pins. Some examples are:
 * An 8-channel bidirectional level shifter for $8 (might have problems with I2C).
 * A 4-channel bidirectional level shifter for $4 (should handle I2C), shown in the photo on the right.
 * Use a one-way opto-isolated level shifter, such as a 2-channel opto-isolated level shifter for $5. Opto-isolation allows you to use a separate power circuit (eg: separate batteries) for a high-power load such as a robot's motor, compared to the logic circuitry, and this is fairly crucial for industrial or rugged projects such as outdoor robotics, but typically not needed for low-power hobby projects.
 * Use the following link to download the schematics and board layout for a connector that plugs into the J3A1 and J3A2 plugs on the Jetson. http://neurorobotictech.com/Community/Blog/tabid/184/ID/10/Using-Jetson-TK1-connector-and-level-shifter-for-25-MHz-SPI-data-transfers.aspx It breaks out almost all of the important signals from those headers to a 40 pin 0.1" IDC header for prototyping. The blog post also includes schematics and a board layout for a level shifter circuit that uses the GTL2002 chip instead of the TXB0108. The GTL2002 is capable of much faster transitions, making it suitable for higher speed applications. It can also be used for I2C projects. The electronics projects were built using the free DesignSpark PCB layout tool, and each part has a corresponding Mouser or Digi-Key part number so you can build the boards yourself.