Jetson TX2 UART2 (the one on M.2 Key E) doesn't work as intended

I am working on a custom carrier board. I want to use UART0 (ttyS0) as the debug console, and UART2(ttyTHS1) as the serial port. The UART0 functions as the debug console without any issues. The UART2(ttyTHS1) on the other hand doesn’t work as intended. Irrespective of the data being received on this port, I am only seeing a fixed byte pattern that gets printed.
Is there any special procedure that needs to be done to enable UART2(ttyTHS1) ? Is the UART2_TX and UART2_RX pins configured as a serial port by default? (I am using Jetpack 4.2.2 without any dtb changes)

Note: I have used UART1(ttyTHS2 ) on the J17 header on the development board. It works fine too.

hello vinmeen,

according to TX2 Product Design Guide, that UART2 is by default for external WLAN or BT.
you may check Chapter-13.3 for UART chapters, may I have also more details of your use-case,
thanks

Lets check by verifying the following:

  1. Are you referring to UART2_TX connected to pin B16 and UART2_RX connected to pin B15?
  2. Are you having trouble receiving on UART2_RX inside the Jetson TX2 kernel?
  3. Are you having trouble transmitting on UART2_TX from the Jetson TX2 kernel to an external device?
  4. Here are the pinmux settings you need to verify from the kernel after you boot fully:

# sudo devmem2 0x0243d020 w
Read at address 0x0243D020: 0x00000400

Field Bits Value
DRV_TYPE 14:13 0
SCHMT 12 0
GPIO_SF_SEL 10 1 (HSIO)
PBIAS_BUF 9 0
INPUT 6 0
TRISTATE 4 0
PUPD 3:2 0 (NONE)
PM 1:0 0

# sudo devmem2 0x0243d028 w
Read at address 0x0243D028: 0x00000458

Field Bits Value
DRV_TYPE 14:13 0
SCHMT 12 0
GPIO_SF_SEL 10 1 (HSIO)
PBIAS_BUF 9 0
INPUT 6 1
TRISTATE 4 1
PUPD 3:2 2 (PULL_UP)
PM 1:0 0
  1. What baudrate are you using?
  2. Are you using hardware flow control?
  3. Have you tried testing /dev/ttyS1?
  4. Perform dmesg | grep ttyTHS1 and make sure you get address 0x3110000 for UARTB
1 Like
  1. Are you referring to UART2_TX connected to pin B16 and UART2_RX connected to pin B15?

Yes, On my carrier board, these pins are the ones available for UART communication

  1. Are you having trouble receiving on UART2_RX inside the Jetson TX2 kernel?

Yes, when you say inside Jetson TX2 kernel, I am testing the UART using a C++ code. The C++ uart code prints out the same hex pattern each time I get data. On the sender side, I try sending a data packet of size 6 bytes. The received packet always shows the same hex pattern irrespective of the different data packets that I send. The same C++ code works perfectly fine when I change the port to /dev/ttyTHS2 (UART1)

  1. Are you having trouble transmitting on UART2_TX from the Jetson TX2 kernel to an external device?

Yes, on the external device, I used minicom to parse the data. I dont get the data what I send.

  1. Here are the pinmux settings you need to verify from the kernel after you boot fully:

I executed the commands and below were the print outs

gpufsw@tx2:~$ sudo devmem2 0x0243d020 w
/dev/mem opened.
Memory mapped at address 0x7f843cb000.
Value at address 0x243D020 (0x7f843cb020): 0x400

gpufsw@tx2:~$ sudo devmem2 0x0243d028 w
/dev/mem opened.
Memory mapped at address 0x7faddf8000.
Value at address 0x243D028 (0x7faddf8028): 0x458

gpufsw@tx2:~$ dmesg | grep ttyTHS1
[ 1.125425] 3110000.serial: ttyTHS1 at MMIO 0x3110000 (irq = 37, base_baud = 0) is a TEGRA_UART

I do not know how to check the pin mux settings
DRV_TYPE, SCHMT, GPIO_SF_SEL, PBIAS_BUF,INPUT,TRISTATE, PUPD, PM

  1. What baudrate are you using?
    115200
  2. Are you using hardware flow control?
    No, I am not using the hardware flow control
    here is my port settings code

int serial::set_interface_attribs(int fd, int speed)
{
struct termios tty;

if (tcgetattr(fd, &tty) < 0) {
    printf("Error from tcgetattr: %s\n", strerror(errno));
    return -1;
}

cfsetospeed(&tty, (speed_t)speed);
cfsetispeed(&tty, (speed_t)speed);

tty.c_cflag |= (CLOCAL | CREAD);    /* ignore modem controls */
tty.c_cflag &= ~CSIZE;
tty.c_cflag |= CS8;         /* 8-bit characters */
tty.c_cflag &= ~PARENB;     /* no parity bit */
tty.c_cflag &= ~CSTOPB;     /* only need 1 stop bit */
tty.c_cflag &= ~CRTSCTS;    /* no hardware flowcontrol */

/* setup for non-canonical mode */
tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
tty.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
tty.c_oflag &= ~OPOST;

/* fetch bytes as they become available */
tty.c_cc[VMIN] = 1;
tty.c_cc[VTIME] = 1;

if (tcsetattr(fd, TCSANOW, &tty) != 0) {
    printf("Error from tcsetattr: %s\n", strerror(errno));
    return -1;
}
return 0;

}

  1. Have you tried testing /dev/ttyS1?

No, is it an alternate name for /dev/ttyS1?
dmesg | grep ttyS1 did not return anything

  1. Perform dmesg | grep ttyTHS1 and make sure you get address 0x3110000 for UARTB

yes it is the address 0x3110000

Hi JerryChang, I could see that the configuration is WLAN or BT but will it affect me using it as a serial port?

I am trying to use UART2 for communicating to an external device. TX2 is interfaced using a carrier board and when the external device tried sending the data, the data packets reach the input of the TX2 UART. The TX2 boad doesn’t seem to read the data properly.