Skip to content

Detaching a (Linux) kernel driver #246

@tommie

Description

@tommie

I'm buildling a USBTMC device, which I'd like to access with WebUSB. When my device connects, the interface is immediately bound to the Linux usbtmc kernel driver, and claimInterface fails with NetworkError.

libusb provides libusb_detach_kernel_driver to explicitly hijack the device.

I can't find any information in the WebUSB specification about how implementations are supposed to handle this case. If I have requested the device, the user likely wants the webpage detaching the driver ("just make it work.") To me, it seems claimInterface should use always try to detach the kernel driver, but it would be nice with some guidance on how disruptive claimInterface ought to be.

For anyone looking for an answer, this udev rule is for a Raspberry Pi RP2040 that can then be claimed by WebUSB:

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

Caveat emptor: I don't know how this works on other OSes, but I don't think it matters for the general question of how eager claimInterface should be to succeed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions