3

I'm trying to understand better the process of binding a device to its driver. I have an USB tool (In System Programmer for Arduino) whose Id (Product and Vendor) are known. The driver, cdc_acm.ko, doesn't recognize it (of course, it's not in its internal device list!). So... I have loaded the module

sudo modprobe cdc_acm
lsmod | grep cdc
$>cdc_acm

$>dmesg
...
[41244.510906] usbcore: registered new interface driver cdc_acm
[41244.510915] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

Perfect. Then I insert the device and dmesg output is the following:

...
[41447.794431] usb 2-1.2: new full-speed USB device number 17 using ehci-pci
[41447.887680] usb 2-1.2: New USB device found, idVendor=03eb, idProduct=2ff7
[41447.887690] usb 2-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[41447.887695] usb 2-1.2: Product: Arduino USB-Serial DFU

That seems to me that usb driver has been dealing with. Let me check accordingly to the folllowing http://lwn.net/Articles/143397/

$>ls -la /sys/bus/usb/drivers/usb/usb2/2-1/2-1.2/2-1.2\:1.0/
total 0
drwxr-xr-x 3 root root    0 gen 20 19:29 .
drwxr-xr-x 5 root root    0 gen 20 12:51 ..
-r--r--r-- 1 root root 4096 gen 20 12:58 bAlternateSetting
-r--r--r-- 1 root root 4096 gen 20 12:51 bInterfaceClass
-r--r--r-- 1 root root 4096 gen 20 12:51 bInterfaceNumber
-r--r--r-- 1 root root 4096 gen 20 12:58 bInterfaceProtocol
-r--r--r-- 1 root root 4096 gen 20 12:58 bInterfaceSubClass
-r--r--r-- 1 root root 4096 gen 20 12:58 bNumEndpoints
-r--r--r-- 1 root root 4096 gen 20 12:58 modalias
drwxr-xr-x 2 root root    0 gen 20 12:58 power
lrwxrwxrwx 1 root root    0 gen 20 12:58 subsystem -> ../../../../../../../bus/usb
-r--r--r-- 1 root root 4096 gen 20 12:58 supports_autosuspend
-rw-r--r-- 1 root root 4096 gen 20 12:51 uevent

module link is not existing, therefore it seems that the device is not linked to usb module driver. Nice to note that the content of modalias file is what I was expecting:

 usb:v03EBp2FF7d0000dc00dsc00dp00icFEisc01ip02in00

Now I try to link the device to the module cdc_acm with the following command:

$>sudo echo -n "2-1.2:1.0" > sudo /sys/bus/usb/drivers/cdc_acm/bind

dmesg output shows nothing specific to the command just issued.

What am I doing wrong here? I would expect at least some debug output, if I issued an offending request I would expect at least a kernel message back... At least having some system feedback would help me in understanding what the problem is... Anybody can help me? Thanks. PS. I'm using Ubuntu 14.10 64bit on Intel core i3 ASUS laptop F552C.

bobuaits
  • 31
  • 1
  • 4
  • Ok, let me upgrdade this question. First it come out that having sudo echo.... > sudo /sys/... just echoed to a "sudo" text file local to current folder. Unfortunately that doesn't solve the problem. I changed to "sudo -i", entering the shell and from there type the right command. Unfortunately the result is "no such device". What is not clear to me is what should I expect after binding or unbinding a device. Anything in dmesg? Just a message after command has been executred...? "no such device" is a shell output or is a bind/unbind result? – bobuaits Jan 24 '15 at 16:00
  • As you're a reputation 6 user: If the answer below helped you, don't forget to click the grey at the left of its text, which means Yes, this answer is valid! ;-) – Fabby Sep 06 '15 at 07:37

1 Answers1

2

This is very popular situation, the use of shell redirection with sudo to write to root owned file. You can run it as:

sudo sh -c 'echo -n "2-1.2:1.0" > /sys/bus/usb/drivers/cdc_acm/bind'

Which run shell as root and use redirect inside it. There are many other ways, see When using sudo with redirection, I get 'permission denied'

user.dz
  • 48,105