I have more than 2 serial devices enumerated by FTDI driver as /dev/ttyUSB0
, /dev/ttyUSB1
, /dev/ttyUSB2
etc. On reboot, these may get jumbled up in any other order. Also, I may replace/swap these devices physically among these or with some other similar device.
Now, I want a persistent enumeration for these. I want the device names to be enumerated according to the physical USB port (I may connect to the USB ports on the motherboard of the PC directly or use a USB hub) that the device is connected to - say if the devices are connected to the USB hub, port 1 should be reserved to named as ttyUSB0
, port 2 as ttyUSB1
and so on.
After some basic reading, I figured (as mentioned here) that /dev/serial/by-path/
lists the devices as sort of a symlink. So, I created a file /etc/udev/rules.d/101-usb-serial.rules
with the following:
KERNEL=="ttyUSB[0-9]*", SUBSYSTEM=="tty", DRIVERS=="ftdi_sio", PATH=="pci-0000:00:14.0-usb-0:10.1:1.0", SYMLINK+="ttyUSB000"
KERNEL=="ttyUSB[0-9]*", SUBSYSTEM=="tty", DRIVERS=="ftdi_sio", PATH=="pci-0000:00:14.0-usb-0:10.2:1.0", SYMLINK+="ttyUSB001"
KERNEL=="ttyUSB[0-9]*", SUBSYSTEM=="tty", DRIVERS=="ftdi_sio", PATH=="pci-0000:00:14.0-usb-0:10.3:1.0", SYMLINK+="ttyUSB002"
But this doesn't work. On doing ls /dev/ttyUSB*
I'm unable to see the new symlinks I have created. What could possibly be going wrong?
udevadm info /dev/ttyUSB0
while it is plugged in. You can then probably use theID_PATH
value. Since this is prefixed byE:
you need to look for it withENV{...}
.PATH
withENV{ID_PATH}
. It didn't work as well.