<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://baszerr.eu/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>BaSzErr - blog:2025:03:30</title>
        <description></description>
        <link>https://baszerr.eu/</link>
        <lastBuildDate>Fri, 01 May 2026 11:43:23 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://baszerr.eu/lib/exe/fetch.php?media=wiki:dokuwiki.svg</url>
            <title>BaSzErr</title>
            <link>https://baszerr.eu/</link>
        </image>
        <item>
            <title>2025-03-30_-_udev_names_per_raspi_pico</title>
            <link>https://baszerr.eu/doku.php?id=blog:2025:03:30:2025-03-30_-_udev_names_per_raspi_pico</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;udev_names_per_raspi_pico&quot;&gt;2025-03-30 - udev names per RasPi Pico&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
some time ago i found out a &lt;a href=&quot;https://baszerr.eu/doku.php?id=blog:2013:11:21:avr_programming_as_non-root&quot; class=&quot;wikilink1&quot; title=&quot;blog:2013:11:21:avr_programming_as_non-root&quot; data-wiki-id=&quot;blog:2013:11:21:avr_programming_as_non-root&quot;&gt;way to add udev rules for AVR programmers&lt;/a&gt;. while i barely ever use AVRs nowadays, the &lt;code&gt;udev&lt;/code&gt; part becomes handy over and over again. :)
&lt;/p&gt;

&lt;p&gt;
recently at work we had a few helper RasPi boards connected a test env, with loads of other TTY-to-USB adapters. it was a mess, as after a reboot one could never tell which device is which. it was time to clean it up, and &lt;a href=&quot;https://github.com/cadsdf&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/cadsdf&quot; rel=&quot;ugc nofollow&quot;&gt;Chris&lt;/a&gt; pointed me to a neat fact, that RasPi Pico chips actually have a unique serial number to them. that insight was enough to make unique links for each serial device, so that instead of &lt;code&gt;/dev/ttuACM3&lt;/code&gt; you could have &lt;code&gt;/dev/my_foobar_device&lt;/code&gt;.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;2025-03-30 - udev names per RasPi Pico&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;udev_names_per_raspi_pico&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;1-771&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit2&quot; id=&quot;per-pico_rule&quot;&gt;per-Pico rule&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
first just check device properties with:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;udevadm info &lt;span class=&quot;re5&quot;&gt;--name&lt;/span&gt;=&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;dev&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;ttyACM3 &lt;span class=&quot;re5&quot;&gt;--attribute-walk&lt;/span&gt; &lt;/pre&gt;

&lt;p&gt;
then create &lt;code&gt;udev&lt;/code&gt; rule in, say &lt;code&gt; /etc/udev/rules.d/50-foobar.rules&lt;/code&gt; file:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;SUBSYSTEM==&amp;quot;tty&amp;quot;, ATTRS{idVendor}==&amp;quot;2e8a&amp;quot;, ATTRS{idProduct}==&amp;quot;0005&amp;quot;, ATTRS{serial}==&amp;quot;1234567890AB&amp;quot;, \
  SYMLINK+=&amp;quot;my_foobar_device&amp;quot;&lt;/pre&gt;

&lt;p&gt;
note that the rule is specific to a particular board / µC, as it has a serial number.
&lt;/p&gt;

&lt;p&gt;
then make the change live:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;udevadm control &lt;span class=&quot;re5&quot;&gt;--reload-rules&lt;/span&gt;
udevadm trigger &lt;/pre&gt;

&lt;p&gt;
…and enjoy new symlink! :)
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;per-Pico rule&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;per-pico_rule&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;772-1351&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit3&quot; id=&quot;multi-device_targets&quot;&gt;multi-device targets&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
to make things more fun, we had one device that reported 4 serial devices (e.g. &lt;code&gt;/dev/ttyUSB0&lt;/code&gt; to &lt;code&gt;/dev/ttyUSB3&lt;/code&gt;), but we needed to name / link those differently, to make it readable. &lt;code&gt;serial&lt;/code&gt; is available inside &lt;code&gt;tty&lt;/code&gt; while &lt;code&gt;bInterfaceNumber&lt;/code&gt; is in &lt;code&gt;usb&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
the bad news is that &lt;code&gt;udev&lt;/code&gt; does not have built-in support for more than 1 &lt;code&gt;SUBSYSTEM&lt;/code&gt;(S) match. the good news is that this can be worked around with labels. let&amp;#039;s say we want 3rd of 4 (i.e. number 2):
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# 1st part
SUBSYSTEM==&amp;quot;tty&amp;quot;, ATTRS{idVendor}==&amp;quot;2e8a&amp;quot;, ATTRS{idProduct}==&amp;quot;0005&amp;quot;, ATTRS{serial}==&amp;quot;1234567890AB&amp;quot;, \
  GOTO=&amp;quot;second_match&amp;quot;
GOTO=&amp;quot;no_match&amp;quot;

# 2nd part
LABEL=&amp;quot;second_match&amp;quot;
SUBSYSTEMS==&amp;quot;usb&amp;quot;, ATTRS{bInterfaceNumber}==&amp;quot;02&amp;quot; \
  SYMLINK+=&amp;quot;my_device&amp;quot;

# no match - this rule does not apply
LABEL=&amp;quot;no_match&amp;quot;&lt;/pre&gt;

&lt;p&gt;
and voila – now we can have &lt;code&gt;/dev/ttyUSB2&lt;/code&gt; of our device, differentiated by serial, linked as &lt;code&gt;/dev/my_device&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
while this problem could also be addressed by &lt;code&gt;SYMLINK+=“my_device_%n”&lt;/code&gt; and have just 4 linked devices, one would still need to remember which-is-which.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;multi-device targets&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;multi-device_targets&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;1352-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Sun, 30 Mar 2025 13:54:39 +0000</pubDate>
        </item>
    </channel>
</rss>
