{"id":929,"date":"2020-08-05T09:10:47","date_gmt":"2020-08-05T08:10:47","guid":{"rendered":"https:\/\/maximilien-charlier.be\/blog\/?p=929"},"modified":"2020-08-05T09:10:47","modified_gmt":"2020-08-05T08:10:47","slug":"rename-usb-port-on-debian-and-raspberry-pi","status":"publish","type":"post","link":"https:\/\/maximilien-charlier.be\/blog\/2020\/08\/05\/rename-usb-port-on-debian-and-raspberry-pi\/","title":{"rendered":"Rename USB port on Debian and Raspberry pi"},"content":{"rendered":"<p>This post has to objective to be able to rename a Zolertia device on a UNIX system this allows to manage multiple devices easily. After the configuration, each time we connect a specific device, it we appear with the same name and not change following the order of discovery. To rename USB devices we need to have some information about each of them. The command &#8220;udevadm&#8221; allows to get theses informations.<\/p>\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n udevadm info -a \/dev\/ttyUSB0\n udevadm info -a \/dev\/ttyUSB0 | grep \"ATTRS{serial}==\\\"Z\"\n<\/pre><\/div>\n<p>The second command filter the result to get only the line starting by <code>&quot;ATTRS{serial}==\\&quot;Z&quot;<\/code> (Our devices are from <strong>Z<\/strong>olertia).<\/p>\n<p>Next we will use the command <code>udev<\/code> to create rules that rename the USB device. These rules will be placed in the file <code>\/etc\/udev\/rules.d\/10-local.rules<\/code> on Debian or <code>\/etc\/udev\/rules.d\/10-usb-serial.rules<\/code> on Raspberry pi.<\/p>\n<p>The following command could help to create\/edit\/remove the files.<\/p>\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo rm \/etc\/udev\/rules.d\/10-usb-serial.rules\nsudo touch \/etc\/udev\/rules.d\/10-usb-serial.rules\nsudo vi \/etc\/udev\/rules.d\/10-usb-serial.rules\n<\/pre><\/div>\n<p>Vim is not easy to use for the first time. Escape follow by <code>:w<\/code>will save the file and Escape follow by<code>:q<\/code> will escape vim. If you have forgotten to lunch vim with the root access you can type <code>:qa!<\/code> to exit the program.<\/p>\n<p>Finally, the command to rename the USB port is like this<\/p>\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\nSUBSYSTEM==\"tty\", ATTRS{product}==\"Zolertia Firefly platform\", ATTRS{serial}==\"ZOL-B001-A200002005\", SYMLINK+=\"anchor1\", GROUP=\"dialout\", MODE=\"0666\"\n<\/pre><\/div>\n<ul class=\"wp-block-list\"><li><code>SUBSYSTEM==&quot;tty&quot;, ATTRS{product}==&quot;Zolertia Firefly platform&quot;, ATTRS{serial}==&quot;ZOL-B001-A200002005&quot;<\/code> are used to identify a specific USB device.<\/li>\n<li><code>SYMLINK+=&quot;anchor1&quot;<\/code> add a symbolic links which act as alternative names for the device node.<\/li>\n<li><code>GROUP=&quot;dialout&quot;, MODE=&quot;0666&quot;<\/code> add the device the dialout group with 666 access.<\/li><\/ul>\n<p>If your user is not in the dialout group you can add this user to it using the <code>useradd -G dialout username<\/code> command.<\/p>\n<p>If you have some problems, you can take a look at the journal of the Raspberry pi to check for errors <code>sudo journalctl -xe<\/code>. For Example, in our case we have connected to much USB devices to the raspberry pi and we have encounter theses errors:<\/p>\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nJan 28 12:17:56 raspberrypi kernel: xhci_hcd 0000:01:00.0: Error while assigning device slot ID\nJan 28 12:17:56 raspberrypi kernel: xhci_hcd 0000:01:00.0: Max number of devices this xHCI host supports is 32.\nJan 28 12:17:56 raspberrypi kernel: usb 1-1.3.6.4.1-port4: couldn't allocate usb_device\n<\/pre><\/div>\n<p>If you restart our Raspberry pi, may be you will have some problems for example our device redirect <code>bus\/usb\/001\/020<\/code> in place of <code>ttyUSB1<\/code>.<\/p>\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nls -l \/dev\/anchor*\nlrwxrwxrwx 1 root root  7 Jan 28 12:30 \/dev\/anchor1 -&gt; ttyUSB0\nlrwxrwxrwx 1 root root 15 Jan 28 12:30 \/dev\/anchor10 -&gt; bus\/usb\/001\/032\nlrwxrwxrwx 1 root root 15 Jan 28 12:30 \/dev\/anchor11 -&gt; bus\/usb\/001\/031\nlrwxrwxrwx 1 root root 15 Jan 28 12:30 \/dev\/anchor12 -&gt; bus\/usb\/001\/029\nlrwxrwxrwx 1 root root  7 Jan 28 12:30 \/dev\/anchor2 -&gt; ttyUSB3\nlrwxrwxrwx 1 root root  7 Jan 28 12:30 \/dev\/anchor3 -&gt; ttyUSB2\nlrwxrwxrwx 1 root root  7 Jan 28 12:30 \/dev\/anchor4 -&gt; ttyUSB1\nlrwxrwxrwx 1 root root 15 Jan 28 12:30 \/dev\/anchor5 -&gt; bus\/usb\/001\/020\nlrwxrwxrwx 1 root root 15 Jan 28 12:30 \/dev\/anchor6 -&gt; bus\/usb\/001\/024\nlrwxrwxrwx 1 root root 15 Jan 28 12:30 \/dev\/anchor7 -&gt; bus\/usb\/001\/022\nlrwxrwxrwx 1 root root 15 Jan 28 12:30 \/dev\/anchor8 -&gt; bus\/usb\/001\/027\nlrwxrwxrwx 1 root root 15 Jan 28 12:30 \/dev\/anchor9 -&gt; bus\/usb\/001\/026\n<\/pre><\/div>\n<p>To correct this problem, you need to recharge the rules with the command <code>sudo udevadm trigger<\/code>. Here is the result:<\/p>\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nls -l \/dev\/anchor*\nlrwxrwxrwx 1 root root 7 Jan 28 13:48 \/dev\/anchor1 -&gt; ttyUSB0\nlrwxrwxrwx 1 root root 8 Jan 28 13:48 \/dev\/anchor10 -&gt; ttyUSB11\nlrwxrwxrwx 1 root root 8 Jan 28 13:48 \/dev\/anchor11 -&gt; ttyUSB10\nlrwxrwxrwx 1 root root 7 Jan 28 13:48 \/dev\/anchor12 -&gt; ttyUSB9\nlrwxrwxrwx 1 root root 7 Jan 28 13:48 \/dev\/anchor2 -&gt; ttyUSB3\nlrwxrwxrwx 1 root root 7 Jan 28 13:48 \/dev\/anchor3 -&gt; ttyUSB2\nlrwxrwxrwx 1 root root 7 Jan 28 13:48 \/dev\/anchor4 -&gt; ttyUSB1\nlrwxrwxrwx 1 root root 7 Jan 28 13:48 \/dev\/anchor5 -&gt; ttyUSB4\nlrwxrwxrwx 1 root root 7 Jan 28 13:48 \/dev\/anchor6 -&gt; ttyUSB6\nlrwxrwxrwx 1 root root 7 Jan 28 13:48 \/dev\/anchor7 -&gt; ttyUSB5\nlrwxrwxrwx 1 root root 7 Jan 28 13:48 \/dev\/anchor8 -&gt; ttyUSB8\nlrwxrwxrwx 1 root root 7 Jan 28 13:48 \/dev\/anchor9 -&gt; ttyUSB7\n<\/pre><\/div>\n<p>Sources:<\/p>\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.howtogeek.com\/50787\/add-a-user-to-a-group-or-second-group-on-linux\/\">https:\/\/www.howtogeek.com\/50787\/add-a-user-to-a-group-or-second-group-on-linux\/<\/a><\/li>\n<li><a href=\"https:\/\/www.freva.com\/2019\/06\/20\/assign-fixed-usb-port-names-to-your-raspberry-pi\/\">https:\/\/www.freva.com\/2019\/06\/20\/assign-fixed-usb-port-names-to-your-raspberry-pi\/<\/a><\/li>\n<li><a href=\"http:\/\/www.reactivated.net\/writing_udev_rules.html\">http:\/\/www.reactivated.net\/writing_udev_rules.html<\/a><\/li><\/ul>","protected":false},"excerpt":{"rendered":"<p>This post has to objective to be able to rename a Zolertia device on a UNIX system this allows to manage multiple devices easily. After the configuration, each time we connect a specific device, it we appear with the same name and not change following the order of discovery. To rename USB devices we need [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[27,30,31,29,28],"class_list":["post-929","post","type-post","status-publish","format-standard","hentry","category-cs","tag-debian","tag-raspberry-pi","tag-renamme-usb","tag-udev","tag-zolertia"],"_links":{"self":[{"href":"https:\/\/maximilien-charlier.be\/blog\/wp-json\/wp\/v2\/posts\/929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/maximilien-charlier.be\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/maximilien-charlier.be\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/maximilien-charlier.be\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/maximilien-charlier.be\/blog\/wp-json\/wp\/v2\/comments?post=929"}],"version-history":[{"count":19,"href":"https:\/\/maximilien-charlier.be\/blog\/wp-json\/wp\/v2\/posts\/929\/revisions"}],"predecessor-version":[{"id":1059,"href":"https:\/\/maximilien-charlier.be\/blog\/wp-json\/wp\/v2\/posts\/929\/revisions\/1059"}],"wp:attachment":[{"href":"https:\/\/maximilien-charlier.be\/blog\/wp-json\/wp\/v2\/media?parent=929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/maximilien-charlier.be\/blog\/wp-json\/wp\/v2\/categories?post=929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/maximilien-charlier.be\/blog\/wp-json\/wp\/v2\/tags?post=929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}