Linux Find all Serial Ports (ttyS, ttyUSB, …)

How To Check and Use Serial Ports Under Linux
How to find which serial port is in use?
How to find all serial devices (ttyS, ttyUSB, ..) on Linux without opening them?

$ dmesg | grep ttyS
[    0.686269] 00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    0.687681] ttyS4: detected caps 00000700 should be 00000500
[    0.687695] 0000:01:00.0: ttyS4 at MMIO 0xf7c01000 (irq = 16, base_baud = 4000000) is a 16C950/954
[    0.687800] ttyS5: detected caps 00000700 should be 00000500
[    0.687813] 0000:01:00.0: ttyS5 at MMIO 0xf7c01200 (irq = 16, base_baud = 4000000) is a 16C950/954

$ ll /sys/class/tty/*/device/driver | grep -v bus/platform
lrwxrwxrwx 1 root root 0 Mar 31 11:43 /sys/class/tty/ttyS0/device/driver -> ../../../bus/pnp/drivers/serial/
lrwxrwxrwx 1 root root 0 Mar 31 11:43 /sys/class/tty/ttyS4/device/driver -> ../../../../bus/pci/drivers/serial/
lrwxrwxrwx 1 root root 0 Mar 31 11:43 /sys/class/tty/ttyS5/device/driver -> ../../../../bus/pci/drivers/serial/

$ sudo apt install setserial
$ sudo setserial -g /dev/ttyS[0123456789]
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: unknown, Port: 0x02f8, IRQ: 3
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
/dev/ttyS4, UART: 16950/954, Port: 0x0000, IRQ: 16
/dev/ttyS5, UART: 16950/954, Port: 0x0000, IRQ: 16
/dev/ttyS6, UART: unknown, Port: 0x0000, IRQ: 0

$ sudo cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0
1: uart:unknown port:000002F8 irq:3
2: uart:unknown port:000003E8 irq:4
3: uart:unknown port:000002E8 irq:3
4: uart:16C950/954 mmio:0xF7C01000 irq:16 tx:30 rx:0
5: uart:16C950/954 mmio:0xF7C01200 irq:16 tx:30 rx:0

Leave a Reply

Your email address will not be published. Required fields are marked *