Get USB Report Descriptor with Linux

Came across this handy little hack today googlin around the internetz. On several occasions I've had the need to get the full device and report descriptors from an attached USB device. Today was another one of those occasions. If you run lsusb with the -v flag you will get a nice verbose output, but if you locate the section that contains the report descriptor you'll be welcomed with a typical Linux friendly message: ** UNAVAILABLE **.

OH NOOZ!!1!

I thought to myself, self: "certainly there must be some way to tame this beast?". Wouldn't you know it, there certainly is.

Start by plugging in your fancy pants USB device and running dmesg to get the kernel output for the event. It will look something like this:

input: Sony PLAYSTATION(R)3 Controller as /devices/pci0000:00/0000:00:04.1/usb2/2-4/2-4.2/2-4.2:1.0/input/input16
sony 0003:054C:0268.000F: input,hiddev0,hidraw3: USB HID v1.11 Joystick [Sony PLAYSTATION(R)3 Controller] on usb-0000:00:04.1-4.2/input0

The first line input: ... is what we want. It contains the full device path and in this case we are interested in third last component of the path: 2-4.2:1.0.

Now run lsusb and locate the entry for your device.

Bus 002 Device 024: ID 054c:0268 Sony Corp. Batoh Device

Using the VendorID:ProductID pair from the output we can get verbose output from lsusb for just the device we are interested in and nothing else:

$ lsusb -vd 054c:0268

This is when we see that lsusb flat out refuses to show us the report descriptor. To get it, we need to unbind the device first (as root).

$ sudo bash -c "echo -n 2-4.2:1.0 >/sys/bus/usb/drivers/usbhid/unbind"

Now run lsusb again for the device and you should see the report descriptor in the output!

$ lsusb -vd 054c:0268

Comments 6

  1. muzzol wrote:

    hi,

    just found your post about crappy ps3 controllers.

    did you ever managed to make this work on linux? i've bougth two on dealextreme but i can't make them work.

    i see js0 and js1 devices created but jstest shows no output when buttons are pressed.

    Posted 25 Feb 2011 at 03:05 PM
  2. jiGGaK wrote:

    Try pressing the Home button (a.k.a PS button) after you connect the controller.

    Posted 25 Feb 2011 at 03:07 PM
  3. Constantine Shulyupi wrote:

    Unbind last connected USB device with this command:

    dmesg | perl -ne '/(\d+-\d+:\d+.\d+)/ && print "$1\n"' | tail -n 1 > /sys/bus/usb/drivers/usbhid/unbind

    Posted 20 Jul 2011 at 06:05 AM
  4. przemo_li wrote:

    GREAT post. I thought that my device is partialy unoperational.

    (6 times host tryied to fetch CONFIGURATION, and 5 times got partial erb in response, so i thought lack of report descriptor was error too)

    Posted 06 Nov 2012 at 07:11 PM
  5. przemo_li wrote:

    OK. Its not working for me :D

    [13790.709319] usb 2-1.3: new full-speed USB device number 26 using ehci_hcd [13790.805755] generic-usb 0003:1B1F:C00A.0589: hiddev0,hidraw3: USB HID v1.01 Device [eQ-3 Entwicklung GmbH IWF-USB] on usb-0000:00:1d.0-1.3/input0 [13790.806273] usb 2-1.3: USB disconnect, device number 26

    I do not have needed line :D Can I find that info somewhere elese?

    Posted 06 Nov 2012 at 07:21 PM
  6. László Monda wrote:

    Thanks for the very useful post, just managed to query the report descriptors of my keyboard with your help!

    Posted 18 Mar 2013 at 11:04 AM

Post a Comment

Your email is never published nor shared. Required fields are marked *

Thanks! Your comment will be reviewed shortly.