Skip to content

Instantly share code, notes, and snippets.

@cbrake
Created December 19, 2012 14:47
Show Gist options
  • Save cbrake/4337154 to your computer and use it in GitHub Desktop.
Save cbrake/4337154 to your computer and use it in GitHub Desktop.
USB Serial udev rules
# /etc/udev/rules.d/99-usb-serial.rules
# udevadm info --attribute-walk -n /dev/ttyUSB0 |grep serial (can be used to get serial number)
# udevadm control --reload-rules (reload rules)
# udevadm trigger (re-add all devices)
# see https://wiki.archlinux.org/index.php/Bus_pirate
# for some reason, ATTRS{bInterfaceNumber}=="00" is not working, hence the use of ENV{}
# single USB/serial adapters
SUBSYSTEM=="tty", ATTRS{serial}=="A900TUKZ", SYMLINK+="ttyUSB_bub_1"
SUBSYSTEM=="tty", ATTRS{serial}=="A700fdWb", SYMLINK+="ttyUSB_bub_2"
# FTDI USB expander beside power supply
SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NIU", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyUSB_du"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NIU", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ttyUSB_redcloud"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NJ7", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyUSB_unused1"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NJ7", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ttyUSB_twister"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NJL", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyUSB_beagle-xm"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NJL", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ttyUSB_beagle"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NK7", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyUSB_cm-t3730"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NK7", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ttyUSB_unused2"
# FTDI USB expander on desk
SUBSYSTEM=="tty", ATTRS{serial}=="FT4O0Y6M", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyUSB_w7-du-sim"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4O0Y6M", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ttyUSB_w7-lefeb-to-sim"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4O0Y7E", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyUSB_w7-lefeb-to-linux"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4O0Y7E", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ttyUSB_w7-lefeb-to-beagle"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4O0Y7T", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyUSB_lefeb-gps-in"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4O0Y7T", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ttyUSB_unused3"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4O0Y8D", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyUSB_unused4"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4O0Y8D", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ttyUSB_unused5"
# RS485/422 USB adapter
SUBSYSTEM=="tty", ATTRS{serial}=="FTTHJVMG", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyUSB_rs422-1"
SUBSYSTEM=="tty", ATTRS{serial}=="FTTHJVMG", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ttyUSB_rs422-2"
# single blue USB serial adapter, prolific devices don't seem to have a serial number that I can find
SUBSYSTEM=="tty", DRIVERS=="pl2303", SYMLINK+="ttyUSB_panda"
@JiangXL
Copy link

JiangXL commented May 6, 2023

SUBSYSTEMS=="usb", ENV{ID_USB_INTERFACE_NUM}="$attr{bInterfaceNumber}" 
SUBSYSTEM=="tty", ATTRS{idProduct}=="6011", ATTRS{idVendor}=="0403", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyCobolt_638"

In my case, I have to add SUBSYSTEMS=="usb", ENV{ID_USB_INTERFACE_NUM}="$attr{bInterfaceNumber}" .

Ref: https://stackoverflow.com/questions/19174482/udev-rule-with-binterfacenumber-doesnt-work

@cbrake
Copy link
Author

cbrake commented May 8, 2023

@JiangXL thanks for the tip!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment