29 May 2016

Ensure to have the same path for a specific USB device

This article explains how to ensure to have the same path for a specific USB Device on Raspberry Pi 3, on Fedora 23 Minimal version. It should be useful for all other kind of GNU/Linux installation.
If you need to install or complete your Raspberry Pi 3 installation on Fedora 23 Minimal version, for the most lightweight, you can read part 1, and part 2 of my articles.

When we plug/unplug several times an USB device, its device path can change.

This article will take the example of the Aotec Z-Stick Gen5 Z-Wave+, but following instructions can be applied for any USB device.

Install some additional tools
dnf install usbutils

Find idVendor and the idProduct of your USB Device
You need to find the idVendor and the idProduct of your USB Device; there are at least 3 ways to do that.

Method 1 (works in any case) :

  • plug the USB device
  • run dmesg
  • look for lines like

usb 1-1.4: new full-speed USB device number 6 using dwc_otg
usb 1-1.4: New USB device found, idVendor=0658, idProduct=0200
usb 1-1.4: New USB device strings: Mfr=0, Product=0, SerialNumber=0
cdc_acm 1-1.4:1.0: ttyACM0: USB ACM device
You just found the needed IDs.

Method 2 (you must be able to identify the device from the vendor name) :

  • run lsusb
  • look for the line corresponding to the product

For instance:
Bus 001 Device 006: ID 0658:0200 Sigma Designs, Inc.
The ID information corresponds to idVendor:idProduct.

    Method 3 (you must know the current device path) :
    For instance, the Method 1 gives the device sub-path => ttyACM0.
    Run the following command
    udevadm info /dev/ttyACM0

    You will get plenty of information, including the needed IDs.

    Ensure to have the same path for this specific USB device
    To do that, you only need to create/update a /etc/udev/rules.d/50-usb-serial.rules file with good information.
    It will ensure the same symbolic link is created for the corresponding USB device.

    You only need to adapt the value of idVendor (0658 here), idProduct (0200 here) and SYMLINK+ (USBzwave here).

    sudo cat <<EOF > /etc/udev/rules.d/50-usb-serial.rules
    SUBSYSTEM=="tty", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", SYMLINK+="USBzwave", GROUP="dialout", MODE="0666"

    Reboot your Raspberry Pi, or your computer.

    Now, whenever you reboot, plug/unplug the USB device, it will always be reachable with the device path /dev/USBzwave (or whatever you defined in SYMLINK+).

    No comments:

    Post a Comment

    Thank you for your visit, let's share your point of view: