Setting up the udev-rules for connecting multiple external devices through USB in Linux.

Darshan K T
3 min readOct 22, 2019

--

Udev rules are device manager level script that will detects when you have things plugged into your computer, like a network card, external hard drives (including USB thumb drives), mouses, keyboards, joysticks and gamepads.

Using this can configure the symbolical names for every external devices connected to computer. This udev rules script should be written in a particular format using the connected external devices properties like vendor ID and device ID, etc. This udev rule script runs whenever external devices connected to computer and specify what name is given to a device, regardless of which port it is plugged into. This method eliminates the remembering the some random port name’s provided by system/computer like ttyACM0, ACM1, ACM2, etc, for each external devices plugged into it.

How to setting up the udev rule for detect the multiple arduino boards connected to Linux system ?

  1. Go to udev-rules located location and create a .rules format file

Terminal:

$ cd /etc/udev/rules.d

$ sudo gedit ardiuno.rules

Note: The above command creates and opens a file called arduino.rules inside /etc/udev/rules.d folder. Then copy the syntax of normal script format( this syntax format can be sometimes varies for different devices, on that time add some properties to this syntax and remove some properties from it )inside it.

ie, SUBSYSTEM==”tty”,SUBSYSTEMS==”usb”, ATTR{idProduct}==”0042", ATTR{idVendor}==”2341",ATTRS{serial}==”8573031393635151F1A0",MODE=”777", SYMLINK+=”steering”

2. Plug in the all arduino boards(and any other external devices) to USB port of system.

Terminal:

$ ls /dev/

Note: This will lists the all the external devices connected to system and assigns some random port name’s such as ACM0, ACM1, etc.

From this select any port name which want change its name to some symbolical name and get it properties information by running below command in the terminal.

$ udevadm info -a /dev/ttyACM1

This will lists the all kind of it properties information such as vender, product id, driver, serial number etc.

From this copy the “ATTR{idProduct}, ATTR{idVendor}, ATTRS{serial}” properties number information(this information’s are vary from device to device) and paste in the above script syntax format in respective positions. Finally name its symbolical name infront of variable called SYMLINK+= “ ”. This name assigned permanently for that plugged device and detects this device automatically by using this name whenever connected to system regardless of any port.

In the above same manner find the properties of other plugged devices and name its symbolical configuration name inside the udev rule file for any number of plugged devices.

3. Finally, save the created udev rule file by running reload and restart commands.

Terminal:

$ sudo service udev reload
$ sudo service udev restart

Final edited udev rule file.

Finally, unplug the external devices the from system and re-plugin it to any USB ports, this script will runs behind. Then if lists the devices connected to system. it will automatically detects the corresponding symbolical name written in the script file.

--

--