Using GPIO for Serial UART Communication

Hi all,

I’m planning to use the Jetson TX2 for a project which requires communication with multiple sensors. I would like to connect six LIDAR sensors that use 3.3V-TTL serial communication. I know the board comes with one set of pins (TX and RX) for this but is it possible to configure more GPIO to accommodate the other 5 sensors?


hello jjhurst,

did you want to use UART for receive/transmit LIDAR sensor data?
for example, according to NVIDIA Jetson TX2 J21 Header Pinout, you would like to use UART0 for communication.

you might also refer to Tegra X2 (Parker Series SoC) Technical Reference Manual, check the [Chapter-38 UNIVERSAL ASYNCHRONOUS RECEIVER/TRANSMITTER (UART)] chapter for more details.

Hi JerryChang,

Yes, I would like to use UART to receive/transmit LIDAR sensor data. Since we will have multiple LIDAR sensors, I would need more that one set of UART pins.

Is it possible to program GPIO pins to act as UART1, UART2, etc…


hello jjhurst,

according to TX2 TRM, Chapter-38.8 Pad and Pinmux information.
there’re UART1,2,3,4,5,7 total six UARTs have Tx/Rx pins for receive/transmit sensor data.
they should works with your multiple LIDAR sensors ideally, but we’ll still need to confirm.

If you do decide you don’t have enough actual UARTs, then I’m going to suggest that GPIO timing will be insufficiently precise to replace an actual UART. Maybe for very restrictive conditions a GPIO could be made to behave as a UART…if you run at the very slowest speed possible…but some sort of expansion UART will be far simpler and less frustrating in comparison to using GPIO as a UART. For example, a USB serial UART, or perhaps there is a USB to multiple-UART cable available. Different vendors sell different carrier boards, and perhaps one of those has enough UARTs exposed.

A possible solution I formerly used in project is a COMPORT Server connected via Ethernet. It supported RS232/ RS422 and also 485 levels thus beeing ready for even I2C / SPI through emulation. (it had an ARM included which I modded a little bit to support this sufficiently).

With the particular device (comtrol’s devicemaster 16) 16 ports were available.

The com ports show up in the device tree and work for both WIN and LIN. It should be possible to make them visible in e.g. Ubuntu too, by modding the driver.

I’ll give you the easy answer…it depends on your baudrate requirements.

Here are the rough steps to figure out if it can be done with the Tegra X2 SoC:

  1. Familiarize yourself with the SPE (Cortex-R5), how to build the source example, change the code, rebuild, do various things like configuring GPIOs, reading GPIOs, etc.
  2. Configure the GPIO as an input (for the SPE) you want to use as the UART RX signal
  3. Eliminate any references/conflicts in the kernel with that GPIO and ensure your SPE code is considered the "owner" and no one else tries to reconfigure/use it
  4. Configure the GPIO as an interrupt source in the SPE code with appropriate edge triggering mechanism
  5. Test and make sure when data is received on the UART RX signal that your ISR is executed appropriately on the SPE
  6. Find an appropriate clock source (i.e., sufficiently fast given your baud rate) that it can be used in the SPE code to create a tight code loop in the ISR for reading the GPIO successively with the right timings
  7. In lieu of the above, you could do some bench marking of the SPE execution to determine how many spin loops with nop execution are required to make the timing correct for your baud. Note this is usually easier than the above mechanism on Cortex-R/M cores that you know what the clock rate will be before hand
  8. Once you have the RX using GPIO interrupt+reads working you can move on to the TX GPIO control using a similar flow used to make the RX path work

Another option to make the RX GPIO work properly, is to look at the Generic Timestamping Engine (GTE) that the SoC has and see if there is a way to precisely get the timed transitions on the GPIO and convert that data to the RX byte information.

Hello jjhurst
Were u able to sort this out?
I have a similar issue where I need multiple serial ports on GPIO header