• Latest Articles
  • Atom Feed
  • About
  • Automatically Unbinding a Linux Kernel USB Device Driver With UDev Tommie's blog

    For an upcoming project, I’m implementing a USB Test and Measurement Class device. To avoid having to build apps for desktop and mobile, I’m starting with a web app using WebUSB.

    However, since I’m trying to be a nice citizen by using an existing class rather than going directly for a vendor-specific class, I’m immediately punished: the Linux usbtmc device driver is loaded automatically, and attempting to access the interface with WebUSB fails with NetworkError, per the specification.

    This udev rule makes usbtmc unbind itself from any interface on any Raspberry Pi RP2040 device:

    DRIVER=="usbtmc", ACTION=="add", \
        ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000a", \
        RUN+="/bin/sh -c 'echo -n %k >%S%p/driver/unbind'"
    

    I’ve opened webusb#246 to ask how eager USBDevice.claimInterface should be to succeed. Should it try to unbind the kernel driver or not?