Memo for udev - githeim/windheim_archive GitHub Wiki
UDEV
udev (userspace /dev) is a device manager for the Linux kernel
Find device info
$ udevadm info -a /dev/ttyUSB0
looking at device '/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/ttyUSB0/tty/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="tty"
DRIVER==""
ATTR{power/async}=="disabled"
ATTR{power/control}=="auto"
ATTR{power/runtime_active_kids}=="0"
ATTR{power/runtime_active_time}=="0"
ATTR{power/runtime_enabled}=="disabled"
ATTR{power/runtime_status}=="unsupported"
ATTR{power/runtime_suspended_time}=="0"
ATTR{power/runtime_usage}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/ttyUSB0':
KERNELS=="ttyUSB0"
SUBSYSTEMS=="usb-serial"
DRIVERS=="ch341-uart"
ATTRS{port_number}=="0"
ATTRS{power/async}=="enabled"
ATTRS{power/control}=="auto"
ATTRS{power/runtime_active_kids}=="0"
ATTRS{power/runtime_active_time}=="0"
ATTRS{power/runtime_enabled}=="disabled"
ATTRS{power/runtime_status}=="unsupported"
ATTRS{power/runtime_suspended_time}=="0"
ATTRS{power/runtime_usage}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0':
KERNELS=="3-3:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="ch341"
ATTRS{authorized}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bInterfaceProtocol}=="02"
ATTRS{bInterfaceSubClass}=="01"
ATTRS{bNumEndpoints}=="03"
ATTRS{physical_location/dock}=="no"
...
...
udev rule file examples
udev directory
ls /etc/udev/rules.d
example
ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE:="0666", GROUP:="dialout", SYMLINK+="ttyMCU"
example
KERNEL=="ttyUSB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:="0777", SYMLINK+="AHRS"
Find all serial device info
$ ls -l /sys/class/tty
...
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS27 -> ../../devices/platform/serial8250/tty/ttyS27/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS28 -> ../../devices/platform/serial8250/tty/ttyS28/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS29 -> ../../devices/platform/serial8250/tty/ttyS29/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS3 -> ../../devices/platform/serial8250/tty/ttyS3/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS30 -> ../../devices/platform/serial8250/tty/ttyS30/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS31 -> ../../devices/platform/serial8250/tty/ttyS31/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS4 -> ../../devices/platform/serial8250/tty/ttyS4/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS5 -> ../../devices/platform/serial8250/tty/ttyS5/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS6 -> ../../devices/platform/serial8250/tty/ttyS6/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS7 -> ../../devices/platform/serial8250/tty/ttyS7/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS8 -> ../../devices/platform/serial8250/tty/ttyS8/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyS9 -> ../../devices/platform/serial8250/tty/ttyS9/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyUSB0 -> ../../devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.0/ttyUSB0/tty/ttyUSB0/
lrwxrwxrwx 1 root root 0 8월 20 09:30 ttyUSB1 -> ../../devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/ttyUSB1/tty/ttyUSB1/
...
udev reload
$ udevadm control --reload-rules && udevadm trigger