Linux: how to assign a USB driver to a device

This question is twofold:

1- How do you manually disconnect the driver from the USB device and connect another? For example, I have a device that automatically uses the USB storage driver when connected.

// usbview output

Vendor Id: xxxx Product Id: xxxx ... Number of Interfaces: 2 Interface Number: 0 Name: usb-storage Number of Endpoints: 2 ... Interface Number: 1 Name: (none) Number of Endpoints: 2 ... 

I don't want to use the usb-storage driver, so I have an application running on the host in which I use the libusb library to disconnect the USB storage driver, and then I require an interface. Then I can send data to applications and applications running on my USB device and on my Linux operating system.

How do you manually disconnect a driver from outside the application?

2- How to automatically assign a driver to connect to the device plug-in. Currently, I have set up the udev rule to automatically set device permissions.

 SUBSYSTEM=="usb", ATTR{idVendor}=="xxxx", MODE="0666" 

Can udev rules be used to assign drivers to specific interfaces on a USB device? For example, if I wanted usbnet to be used automatically on interface 0 instead of usb-storage, is this possible in udev?

Thanks,

(I'm a little confused about how StackExchange works with it on different sites, or if they are all the same. This is a Linux issue, so it has also been published on Unix and Linux. Forgive me if it should not be published here too, but StackOverflow also handles Linux, so ...)

+7
source share
1 answer

This question sounds very much like a USB device containing a small flash drive that contains a Windows driver, but it's actually a kind of network access device (the UMTS modem comes to my mind). If so, try using USB_ModeSwitch , which contains a database of USB devices, as well as the commands and data that you need to use to move the device from “storage mode” to “network access mode”. If the device is not configured in the database, Usb Sniffer for Windows can be used in Windows to track USB traffic and retrieve the necessary combo command / data.

Automating usb_modeswitch so that it does the magic when connecting your device can be done using udev rules. If you are using a Fedora or Ubuntu distribution, this will be used for you when installing packages that provide usb_modeswitch (sorry I do not have information about SUSE, but I think it looks like). On Fedora, this is the use_modeswitch_data package, which provides a wrapper for usb_modeswitch cmd and the necessary rule files.

If you really want to connect / disconnect USB devices from drivers, see this LWN article . As root, echo $usbid > /sys/bus/usb/drivers/usb-storage/unbind untie the USB device with $usbid from the "usb-storage" driver. Using the same command, but using bind instead of unbind , it will try to associate the device with the driver. But keep in mind that there is no point (and will not work) to bind a device that acts as a storage device to the usbnet driver.

+8
source

All Articles