0

I have a STM32-Bluepill board where I flashed an USB Bootloader. If I attach it to my computer, it is mounted at /dev/ttyACM0. lsusb shows it as Bus 001 Device 006: ID 1eaf:0004 Leaflabs Maple serial interface

For Arduino-Projects I do have a diy group on my computer. So for the Bluepill I created the following udev rule:

#Bootloader-Mode
DRIVERS=="usb", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1eaf", ATTRS{idProduct}=="0004", GROUP="diy", MODE="0660"
#Normal-Operation-Mode
DRIVERS=="usb", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1eaf", ATTRS{idProduct}=="0003", GROUP="diy", MODE="0660"

Both rules do apply, but none sets the group of /dev/ttyACM0 correctly (its alway uucp). I know that those rule are applied, because I currently use a workaround by setting the mode to 0666 instead. That gives me the permission to work with the device, but anyways I want to set the group correctly.

uucp is only set by one of my default-rules: /usr/lib/udev/rules.d/50-udev-default.rules. But my rule lies at /etc/udev/rules.d/100-bluepill.rules so it should be higher prioritized.

3
  • Rules are processed in lexical order not numerical order I think? See man udev May 6 at 10:37
  • you are absolutely right. So the default 50 rule was executed after my own rule and did overwrite the group again. Renaming the rule to 99-bluepill.rules did the trick. If you could post your suggestion as an answer, I will mark it as "solved" :) Thanks again
    – Tom Mekken
    May 6 at 11:29
  • I've added a brief answer below - thanks May 6 at 13:06

1 Answer 1

1

Although numeric prefixes are the conventional way to specify udev rule order, the processing is actually lexical. From man udev:

RULES FILES
       The udev rules are read from the files located in the system rules
       directories /lib/udev/rules.d and /usr/local/lib/udev/rules.d, the
       volatile runtime directory /run/udev/rules.d and the local
       administration directory /etc/udev/rules.d. All rules files are
       collectively sorted and processed in lexical order, regardless of the
       directories in which they live. However, files with identical filenames
       replace each other. Files in /etc have the highest priority, files in
       /run take precedence over files with the same name under /usr. This can
       be used to override a system-supplied rules file with a local file if
       needed; a symlink in /etc with the same name as a rules file in /lib,
       pointing to /dev/null, disables the rules file entirely. Rule files
       must have the extension .rules; other extensions are ignored.

So 100-bluepill.rules sorts before 50-udev-default.rules (1 < 5). To make your rule apply last, choose something like 99-bluepill.rules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.