Get USB Report Descriptor with Linux

Posted by jiGGaK on May 8th, 2010

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


Krwawy January 15th, 2018

Nice post - it was working on my distribution (UbuntuMate 17.10), although later I realized it is possible to retrieve report descriptor via call to sys/kernel/debug:

 cat /sys/kernel/debug/hid/0003\:2563\:0575.0009/rdesc

RaLi June 21st, 2017

Did not work with my Linux Distribution (LinuxMint/Ubuntu16.04). What works is usbhid-dump.

https://github.com/DIGImend/usbhid-dump

rurigeo January 3rd, 2015

work at my rasbian, thanks. I wonder this can also be solved by add usb.rules. Because i have another usb controller which has added usb.rules can display Report Descriptor with echo ….

Roman Morawek December 23rd, 2014

To successfully show the report descripters I needed to run lsusb as root.

László Monda March 18th, 2013

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

przemo_li November 6th, 2012

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?

przemo_li November 6th, 2012

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)

Constantine Shulyupi July 20th, 2011

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

jiGGaK February 25th, 2011

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

muzzol February 25th, 2011

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.