User Tools

Site Tools


doc:appunti:linux:sa:renaming_usb_devices
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


doc:appunti:linux:sa:renaming_usb_devices [2021/06/09 12:29] (current) – created niccolo
Line 1: Line 1:
 +====== Renaming USB serial devices ======
 +
 +When you connect an **usb-serial** adapter to a GNU/Linux host, it gets named something like **ttyUSB0**. Other similar devices get the name with subsequent numbers: **ttyUSB1**, **ttyUSB2**, etc. If you want a predictable device name, you can use **udev rules**.
 +
 +In the following examples you can assign a predictable name by **USB slot position** or by **vendor/product** of the USB adapter.
 +
 +Once the device is connected, inspect the udev subsystem about it;
 +
 +<code>
 +udevadm info -a -p  $(udevadm info -q path -n /dev/ttyUSB0)
 +</code>
 +
 +You can choose among many attributes to identify the device.
 +
 +The following example will identify the device by the USB position, which is also reported by **dmesg**:
 +
 +<code>
 +usb 1-2.3: pl2303 converter now attached to ttyUSB0
 +</code>
 +
 +Create a file **/etc/udev/rules.d/10-local.rules** with the following line:
 +
 +<file>
 +ACTION=="add", SUBSYSTEMS=="usb", KERNELS=="1-2.3", SYMLINK+="usbserial_A"
 +</file>
 +
 +Otherwise you can select by vendor/product, with another line like this one:
 +
 +<file>
 +ACTION=="add", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", SYMLINK+="usbserial_B"
 +</file>
 +
 +Let the udev subsystem to re-read the rules:
 +
 +<code>
 +udevadm trigger
 +</code>
 +
 +Now, when you plug the USB adapter, a symlink will be created **%%/dev/usbserial_A -> ttyUSB0%%**.
 +
 +If more than one rule match, more than one symlink will be created.
  
doc/appunti/linux/sa/renaming_usb_devices.txt · Last modified: 2021/06/09 12:29 by niccolo