UART communication between tx2 and pixhawk

Hi All,

I’m working with jetson tx2 with carrier board Aetina AN301. The goal was to establish two way UART communication with mavros between tx2 and pixhawk.

Initially I tested the telemetry port of pixhawk by connecting it to my pc using a USB to tty cable and mavros. And the pixhawk works fine.

Then I tried connecting my pixhawk to tx2 and I had no luck with it though I could see some data being transmitted through the port /dev/ttyTHS2 using picocom.

Then I connected my PC with the RS232 in J4, used cutecom to find that the data transmitted from one end is received as some junk value on the other end. I assumed that to be some encoding initially but the data received in both ends is different for the same input. (i.e. when I send “ab” from tx2, I’m receiving “47 a7” and when I send the same input “ab” from PC, I’m receiving “47 27”).

Then I proceeded to use the debug UART port in j4 (/dev/ttyS0). I could receive the exact data sent from the other end using cutecom. (i.e. when I send “abc” from one end, I’m receiving the same in the other end.)

So, I tried connecting my pixhawk with the Debug UART, but couldn’t do it. The output said that the serial port was unavailable. Then I used lsof to find that there was a process running on the port known as “agetty”. I tried to kill the process but every-time I do, the process gets re-initiated with a different PID. But the PPID seems to be the same but I couldn’t kill that.

So, how to change a Debug UART to a normal UART port in tx2 (with the carrier board Aetina AN301) ?

Just some things to check, not in any particular order…

In the case of all integrated serial UARTs on the Jetson are all of your communications using 3.3V logic level? If 1.8V or the extremes of an actual DB-9 connector, then this will fail (the DB-9 might even damage the Jetson).

For all ports used, be certain they are group “dialout”. If the group is “tty”, then the port is used by serial console. Note that if the group on your UART is already “dialout”, then there is no need to disable serial console.

Beware that device naming for “/dev/ttyTHS#” and “/dev/ttyS#”, where “#” is the same, is the same hardware (but provided interface via different drivers). So for example, “/dev/ttyS2” and “/dev/ttyTHS2” is the same UART, but different drivers. When you check to make sure the port is not group “tty” check both the “ttyTHS#” file name and the corresponding “ttyS#” name.

How the ports are initially set up is through the device tree. Third party carrier boards will have provided different flash content, and it is the device tree from this content which makes initial UART setup.

Whenever a UART is group “tty” (and thus a serial console) you can disable this in Linux (but not necessarily U-Boot) simply by turning off the serial console service:

# Turns this off for this session until next reboot:
sudo systemctl stop nvgetty.service
# Disables (within Linux, but not within U-Boot) serial console even after reboot:
sudo systemctl disable nvgetty.service
# Enables this again if disabled:
sudo systemctl enable nvgetty.service

Note that serial console in the bootloader is different software than that in Linux, so disabling this in Linux might still cause the system to halt and wait in the bootloader if it gets a stray keystroke during boot.

Looking at ASCII “ab” and “47 27” (assuming this is hex and not ASCII) I don’t see any obvious pattern. Is the “47 27” hex? Probably is, but wanted to be sure.

Are both sides using 115200 8N1 settings? This is the Jetson default unless the device tree was changed.

I’ve heard of some people with an issue sometimes having to add a 10k pull-down resistor.

Thanks for the quick response. I connect to the telemetry port of pixhawk which is 3.3V or to my PC using USB to tty cable which also gives out 3.3V. So there’s no problem with that.

As of the baud rates, I’ve set them as 57600. Please let me know how to see the device tree settings.

As of the RS232 port, yes, it is hex value. If I take it out of hex mode, the values seem to be some junk address value. I used cutecom and the results for “abcd” as input from both ends is as seen in the attachment Cutecom_PC/TX2_RS232.


Cutecom_TX2_RS232

When I use the debug UART, in cutecom, I get a pop up in the cutecom in tx2 which says “No such file exists” or “Resource temporarily unavailable”. I get the root login option on the other end (Of course I know that’s the purpose of debug UART). Refer to the attachment Cutecom_PC.

Then I use the following commands,

sudo systemctl stop nvgetty.service
sudo chgrp dialout /dev/ttyS0
sudo kill -STOP $(PID of agetty) 
sudo chmod 666 /dev/ttyS0

After this, I’m able to communicate through cutecom and the output is as shown below.
Cutecom_TX2_debugUART

I connect with pixhawk through this port and I don’t get all the parameters properly (properly in the sense, like how the output comes when I directly connect the pixhawk through USB), though mavlink is established.

Also I want to know how can I configure the GPIO pins (there isn’t much in the user guide of the board on this). So, is there anything you would suggest?

There were a lot of cases there, and I’m not sure I’m following the screenshots correctly, but if software using the UARTs is setting speed, then it won’t matter what the default is from the device tree. However, just to be thorough, if you know the physical address of your particular UART, then you can easily find it in the device tree. To see all serial UARTs which are integrated into the TX2, at each offset, examine the directories shown by this command (I don’t know which UART address corresponds to the “/dev/tty*” file):
find /proc/device-tree -name 'serial@*'

For example, on a TX2 dev kit, I can:

  • cd /proc/device-tree/serial@311000
  • ls
  • Use cat to examine any of the files…these are device tree nodes.

Better yet, to get a complete device tree as it runs from the current system:
dtc -I fs -O dts -o extracted.dts /proc/device-tree
(and then look for the “serial@” lines, and browse the tree a bit more intuitively)

An important test would be to take the serial device you are using at the Jetson end, put it in loopback mode where TX and RX are directly wired together, and see what happens when your serial console program has the “abcd” data sent…does it echo correctly in loopback mode? If so, then the problem is not in the individual UART, but is instead a problem of combining two UARTs; however, if there is a problem, then you know it is an issue of software with that specific UART.

So far as GPIO goes you would normally use the PINMUX spreadsheet to set this up, although there are other ways. For the PINMUX, see:
https://developer.nvidia.com/embedded/downloads#?search=pinmux&tx=$product,jetson_tx2

Hello
I am having Jetson Xavier Nx and Pixhawk 2.4.8
Please tell me how to connect both of them for data transmission.
what are steps required, Is there any external device required ?
Please tell me in detail as soon as possible.
I will be very thankful to you.

Sorry, I don’t actually have a Pixhawk, so I have no way to know what it requires. A lot of people here have a Pixhawk, so likely someone who has one can answer (I only answered some serial UART questions which are generic enough it doesn’t matter if it is a Pixhawk). You should probably start a new thread.