How can I quickly perform a UART2/UART3 TXD/RXD loopback test on a G720 Android 14 device without any external UART devices connected?
aiot8391p2_64_bsp:/ # ls /sys/bus/platform/devices/11004000.serial/tty/
ttyS3
aiot8391p2_64_bsp:/ # ls /sys/bus/platform/devices/11003000.serial/tty/
ttyS2
Hi Josh,
ttyS2 (11003000.serial) and ttyS3 (11004000.serial) are already registered by
the 8250-based UART driver, so you can test them in either of two ways:
-
Internal loopback (no wiring)
Configure the port with termios (raw mode, baud rate, no flow control), then
set the TIOCM_LOOP modem-control bit via ioctl(fd, TIOCMBIS, …) to enable
the UART’s loopback mode. Anything you write() should then be read() back.
Note this only checks the controller/driver, not the pinmux or the board pins.
Refs:
-
External loopback
Short TXD to RXD of the same UART on the header, then open the tty
(e.g. stty -F /dev/ttyS2 115200 raw -echo -crtscts), write data and read it back.
This also verifies the pins and wiring.
Please make sure no other service is holding the port. If it still fails, share
your BSP/kernel version and the output of dmesg | grep -i serial.