I am programming a USB-HID device based on STM32 CubeMX Mouse example. I made some modifications (interface, endpoints, report descriptor, etc using the CustomHID Class template) and I am currently testing enumeration.
Everything seems to be OK except that the lsusb
command fails to dump the report descriptor:
$lsusb
Bus 001 Device 013: ID 0483:5740 STMicroelectronics STM32F407
$sudo lsusb -v -s 001:013
Bus 001 Device 013: ID 0483:5740 STMicroelectronics STM32F407
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.01
bDeviceClass 2 Communications
bDeviceSubClass 2 Abstract (modem)
bDeviceProtocol 0 None
bMaxPacketSize0 64
idVendor 0x0483 STMicroelectronics
idProduct 0x5740 STM32F407
bcdDevice 2.00
iManufacturer 1 TEST-ST
iProduct 2 TEST MY HID
iSerial 3 00000000001A
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 41
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 36
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 5
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 5
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 12
bNumDeviceCaps 1
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000002
Link Power Management (LPM) Supported
Device Status: 0x0001
Self Powered
The only link I've found related to my problem on the web is this, however it lacks some explanations about what is done here...
[EDIT]
I have also tried to debug with HIDAPI:
For some reason, the Report descriptor is not sent when the target is plugged.
However, when I connect then disconnect the target (does not matter if I send a command or not) via HIDAPI, then the Report descriptor is populated in lsusb
output:
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 34
Report Descriptor: (length is 34)
Item(Global): Usage Page, data= [ 0xd0 0xf1 ] 61904
(null)
Item(Local ): Usage, data= [ 0x01 ] 1
(null)
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Local ): Usage, data= [ 0x20 ] 32
(null)
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x40 ] 64
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x21 ] 33
(null)
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x40 ] 64
Item(Main ): Output, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Main ): End Collection, data=none
Endpoint Descriptor:
Moreover, when I spy with udevadm monitor
here is the output:
KERNEL[25465.054769] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2 (usb)
KERNEL[25465.055295] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0 (usb)
KERNEL[25465.056409] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D (hid)
KERNEL[25465.056864] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/usbmisc/hiddev2 (usbmisc)
KERNEL[25465.056944] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D/hidraw/hidraw3 (hidraw)
UDEV [25465.097179] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2 (usb)
UDEV [25465.100961] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0 (usb)
UDEV [25465.104350] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D (hid)
UDEV [25465.106807] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/usbmisc/hiddev2 (usbmisc)
UDEV [25465.108620] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D/hidraw/hidraw3 (hidraw)
And when I connect to the target with HIDAPI:
KERNEL[25560.356084] remove /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/usbmisc/hiddev2 (usbmisc)
KERNEL[25560.356187] remove /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D/hidraw/hidraw3 (hidraw)
KERNEL[25560.356278] remove /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D (hid)
UDEV [25560.359579] remove /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/usbmisc/hiddev2 (usbmisc)
UDEV [25560.360677] remove /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D/hidraw/hidraw3 (hidraw)
UDEV [25560.362515] remove /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0483:5740.002D (hid)
There is no more activity when I disconnect. However the Report descriptor only appears in lsusb
after HIDAPI is disconnected for the target.
My guess is that something is blocking/missing right after the plug. The connection with HIDAPI triggers the sending of missing information, but I am not sure why the information is only available once HIDAPI disconnects...
User contributions licensed under CC BY-SA 3.0