6

In that question someone wanted a blacklist for all USB devices, and then only allow specific devices.

In this question, we want to accept all USB devices, but prevent the driver (e.g. cdc_acm) from taking one specific device type – for example, an LEGO® NXT brick in flash mode should not be taken (because fwflash needs raw access to the device), but an Arduino board should still be accessed by the driver to produce /dev/ttyACM0, in an educative environment accessing both NXT and Arduino hardware.

1 Answer 1

5

I’ve been able to do this with an udev rule, after some trickery (and using lsusb to find out the vendor and product ID of the device in flash mode):

$ cat /etc/udev/rules.d/nxt.rules
# disable NXT in flash mode
ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="6124", RUN="/bin/sh -c '/bin/echo -n $kernel:1.0 | /usr/bin/tee /sys/bus/usb/drivers/cdc_acm/unbind | /usr/bin/logger -t nxt-flashmode'"

This rule is triggered when an NXT brick is plugged in while in flash mode, or put into flash mode while plugged in. It does not prevent cdc_acm from grabbing it, but immediately after tells it to release the device, so fwflash can access it.

I have not found out what the :1.0 is, and why use that and not :1.1 which also shows up in sysfs. However, I wanted to share a working (for me) solution. Environment: Debian unstable as of end of October, 2014 (i.e. pretty much Debian jessie).

2
  • 3
    In more recent kernels you can come at with more directly, with a rule like SUBSYSTEM=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="6124", ATTR{authorized}="0" which will unauthorise (and likely power down the device) within the kernel.
    – vk5tu
    Nov 13, 2020 at 12:17
  • @vk5tu that fails the question: a different driver needs to access that device, in raw mode.
    – mirabilos
    Nov 16, 2020 at 21:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .