Hi, i currently work with an Arm Controller from ST and i try to create a CDC + HID usb interface device.
The configuration is working under XP but on Win7 only the Com Port is visible, the keyboard is not detected. While sniffing the usb communication i found out that the device descriptor is read correct (like on XP) but the HID report descriptor is not read by win7. Does anybody have an idea what is the problem?
Here is the driver i used:
; ; STMicroelectronics Comunication Device Class driver instalation file ; (C)2006 Copyright STMicroelectronics ; [Version] Signature="$Windows NT$" Class=Ports ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} Provider=%STM% LayoutFile=layout.inf DriverVer=10/02/06 [Manufacturer] %STM%=DeviceList [DestinationDirs] DefaultDestDir=12 [SourceDisksFiles] [SourceDisksNames] [DeviceList] %DESCRIPTION%=STMUSB, USB\VID_0483&PID_A097&MI_00 ;------------------------------------------------------------------------------ ; Windows 2000/XP Sections ;------------------------------------------------------------------------------ [STMUSB.nt] include=mdmcpq.inf CopyFiles=DriverCopyFiles AddReg=STMUSB.nt.AddReg [DriverCopyFiles] usbser.sys,,,0x20 [STMUSB.nt.AddReg] HKR,,DevLoader,,*ntkern HKR,,NTMPDriver,,usbser.sys HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" [STMUSB.nt.Services] AddService=usbser, 0x00000002, DriverService [STMUSB.nt.HW] include=mdmcpq.inf [DriverService] DisplayName=%DESCRIPTION% ServiceType=1 StartType=3 ErrorControl=1 ServiceBinary=%12%\usbser.sys ;------------------------------------------------------------------------------ ; String Definitions ;------------------------------------------------------------------------------ [Strings] STM="STMicroelectronics" DESCRIPTION="Datafox Virtual COM Port"
_ALIGN_BEGIN uint8_t usbd_cdc_CfgDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END = { /*------------------------------------------------------------------------*/ /*Configuration Descriptor*/ /*------------------------------------------------------------------------*/ 0x09,0x02,0x4B,0x00,0x03,0x01,0x00,0xC0,0x32, //--------------------------------------------------------------------------- // Interface Association Descriptor //--------------------------------------------------------------------------- 0x08,0x0B,0x00,0x02,0x02,0x02,0x01,0x04, /*---------------------------------------------------------------------------*/ /*Interface Descriptor 1 */ //--------------------------------------------------------------------------- 0x09,0x04,0x00,0x00,0x01,0x02,0x02,0x01,0x04, //--------------------------------------------------------------------------- /*Header Functional Descriptor*/ //--------------------------------------------------------------------------- 0x05,0x24,0x00,0x10,0x01, //--------------------------------------------------------------------------- /*Call Management Functional Descriptor*/ //--------------------------------------------------------------------------- 0x05,0x24,0x01,0x00,0x03, //--------------------------------------------------------------------------- /*ACM Functional Descriptor*/ //--------------------------------------------------------------------------- 0x04,0x24,0x02,0x06, //--------------------------------------------------------------------------- /*Union Functional Descriptor*/ //--------------------------------------------------------------------------- 0x05,0x24,0x06, 0x00,0x01, //--------------------------------------------------------------------------- /*Endpoint 2 Descriptor*/ //--------------------------------------------------------------------------- 0x07,0x05,0x83, 0x03,LOBYTE(CDC_CMD_PACKET_SZE1),HIBYTE(CDC_CMD_PACKET_SZE1), 0xFF, /*---------------------------------------------------------------------------*/ /*Data class interface descriptor 1*/ //--------------------------------------------------------------------------- 0x09,0x04,0x01,0x00,0x02,0x0A,0x00,0x00,0x04, //--------------------------------------------------------------------------------- /*Endpoint OUT Descriptor*/ //--------------------------------------------------------------------------------- 0x07,0x05,0x01, 0x02,LOBYTE(CDC_DATA_MAX_PACKET_SIZE1), HIBYTE(CDC_DATA_MAX_PACKET_SIZE1), /* 065 */ 0x00, //--------------------------------------------------------------------------------- /*Endpoint IN Descriptor*/ //--------------------------------------------------------------------------------- 0x07,0x05,0x81, 0x02,LOBYTE(CDC_DATA_MAX_PACKET_SIZE1), HIBYTE(CDC_DATA_MAX_PACKET_SIZE1), 0x00, ////------------------------------------------------------------- ///************** Interface Descriptor Keyboard ****************/ ////------------------------------------------------------------- 0x09, USB_INTERFACE_DESCRIPTOR_TYPE, 0x02, 0x00, 0x01, 0x03, 0x01, 0x01, 0x00, ////---------------------------------------------------------------- ///**************** HID Descriptor Keyboard ********************/ ////---------------------------------------------------------------- 0x09,0x21,0x11,0x01,0x00,0x01,0x22,0x3F,0x00, ////------------------------------------------------------------------------- ///******************** Descriptor of Keyboard endpoint ********************/ ////------------------------------------------------------------------------- 0x07,0x05,0x82,0x03,0x08,0x00,0x0A, //---------------------------------------------------------------------------
wMaxPacketSize field of the config descriptor (0x4B,0x00) is wrong. This number counts just the IAD and CDC descriptors. It's the reason why HID interface was ignored.
I'm not sure, if there is any other bug on your descriptor or not. It's hard to see meaningful fields just on the array of numbers.
Tsueno
Auu, wMaxPacketSize <-- wTotalLength
Hi,
you are right. I checked it again but it was only a typo, because i replaced the define for this post with the wrong number. The compilation uses the correct value 100. Win7 read out the complete decriptor file but doesn't read the report descriptor
I removed the comments because of post limit.
Here is the original:
__ALIGN_BEGIN uint8_t usbd_cdc_CfgDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END = { /*------------------------------------------------------------------------*/ /*Configuration Descriptor*/ /*------------------------------------------------------------------------*/ /*Configuration Descriptor*/ 0x09, /* 000 bLength: Configuration Descriptor size */ USB_CONFIGURATION_DESCRIPTOR_TYPE (0x02), /* 001 bDescriptorType: Configuration*/ USB_CDC_CONFIG_DESC_SIZ, (100) /* 002 wTotalLength:no of returned bytes*/ 0x00, /* 003 */ 0x03, /* 004 bNumInterfaces: 3 interface / 0x01, /* 005 bConfigurationValue: Configuration value */ 0x00, /* 006 iConfiguration: Index of string descriptor describing the configuration */ 0xC0, /* 007 bmAttributes: self powered */ 0x32, /* 008 MaxPower 0 mA */ //--------------------------------------------------------------------------- // Interface Association Descriptor //--------------------------------------------------------------------------- 0x08, // 009 bLength 0x0B, // 010 bDescriptorType 0x00, // 010 bFirstInterface 0x02, // 011 bInterfaceCount 0x02, // 012 bFunctionClass 0x02, // 013 bFunctionSubClass 0x01, // 014 bFunctionProtocoll 0x04, // 015 iFunction /*---------------------------------------------------------------------------*/ /*Interface Descriptor 1 */ //--------------------------------------------------------------------------- 0x09, /* 016 bLength: Interface Descriptor size */ USB_INTERFACE_DESCRIPTOR_TYPE (0x04), /* 017 bDescriptorType: Interface */ 0x00, /* 018 bInterfaceNumber: Number of Interface */ 0x00, /* 019 bAlternateSetting: Alternate setting */ 0x01, /* 020 bNumEndpoints: One endpoints used */ 0x02, /* 021 bInterfaceClass: Communication Interface Class */ 0x02, /* 022 bInterfaceSubClass: Abstract Control Model */ 0x01, /* 023 bInterfaceProtocol: Common AT commands */ 0x04, /* 024 iInterface: */
continue...
//--------------------------------------------------------------------------- /*Header Functional Descriptor*/ //--------------------------------------------------------------------------- 0x05, /* 025 bLength: Endpoint Descriptor size */ 0x24, /* 026 bDescriptorType: CS_INTERFACE */ 0x00, /* 027 bDescriptorSubtype: Header Func Desc */ 0x10, /* 028 bcdCDC: spec release number */ 0x01, /* 029 */ //--------------------------------------------------------------------------- /*Call Management Functional Descriptor*/ //--------------------------------------------------------------------------- 0x05, /* 030 bFunctionLength */ 0x24, /* 031 bDescriptorType: CS_INTERFACE */ 0x01, /* 032 bDescriptorSubtype: Call Management Func Desc */ 0x00, /* 033 bmCapabilities: D0+D1 */ 0x03, /* 034 bDataInterface: 1 */ //--------------------------------------------------------------------------- /*ACM Functional Descriptor*/ //--------------------------------------------------------------------------- 0x04, /* 035 bFunctionLength */ 0x24, /* 036 bDescriptorType: CS_INTERFACE */ 0x02, /* 037 bDescriptorSubtype: Abstract Control Management desc */ 0x06, /* 038 bmCapabilities */ //--------------------------------------------------------------------------- /*Union Functional Descriptor*/ //--------------------------------------------------------------------------- 0x05, /* 039 bFunctionLength */ 0x24, /* 040 bDescriptorType: CS_INTERFACE */ 0x06, /* 041 bDescriptorSubtype: Union func desc */ 0x00, /* 042 bMasterInterface: Communication class interface */ 0x01, /* 043 bSlaveInterface0: Data Class Interface */ //--------------------------------------------------------------------------- /*Endpoint 2 Descriptor*/ //--------------------------------------------------------------------------- 0x07, /* 044 bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE (0x05), /* 045 bDescriptorType: Endpoint */ CDC_CMD_EP1 (0x83), /* 046 bEndpointAddress */ 0x03, /* 047 bmAttributes: Interrupt */ LOBYTE(CDC_CMD_PACKET_SZE1) (0x08), /* 048 wMaxPacketSize: */ HIBYTE(CDC_CMD_PACKET_SZE1) (0x00), /* 049 */ 0xFF, /* 050 bInterval: */ /*---------------------------------------------------------------------------*/ /*Data class interface descriptor 1*/ //--------------------------------------------------------------------------- 0x09, /* 051 bLength: Endpoint Descriptor size */ USB_INTERFACE_DESCRIPTOR_TYPE (0x04), /* 052 bDescriptorType: */ 0x01, /* 053 bInterfaceNumber: Number of Interface */ 0x00, /* 054 bAlternateSetting: Alternate setting */ 0x02, /* 055 bNumEndpoints: Two endpoints used */ 0x0A, /* 056 bInterfaceClass: CDC */ 0x00, /* 057 bInterfaceSubClass: */ 0x00, /* 058 bInterfaceProtocol: */ 0x04, /* 059 iInterface: */ //--------------------------------------------------------------------------------- /*Endpoint OUT Descriptor*/ //--------------------------------------------------------------------------------- 0x07, /* 060 bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE (0x05), /* 061 bDescriptorType: Endpoint */ CDC_OUT_EP1 (0x01), /* 062 bEndpointAddress */ 0x02, /* 063 bmAttributes: Bulk */ LOBYTE(CDC_DATA_MAX_PACKET_SIZE1) (0x40, /* 064 wMaxPacketSize: */ HIBYTE(CDC_DATA_MAX_PACKET_SIZE1) (0x00), /* 065 */ 0x00, /* 066 bInterval: ignore for Bulk transfer */ //--------------------------------------------------------------------------------- /*Endpoint IN Descriptor*/ //--------------------------------------------------------------------------------- 0x07, /* 067 bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE (0x05), /* 068 bDescriptorType: Endpoint */ CDC_IN_EP1 (0x81), /* 069 bEndpointAddress */ 0x02, /* 070 bmAttributes: Bulk */ LOBYTE(CDC_DATA_MAX_PACKET_SIZE1) (0x40),/* 071 wMaxPacketSize: */ HIBYTE(CDC_DATA_MAX_PACKET_SIZE1) (0), /* 072 */ 0x00, /* 073 bInterval: ignore for Bulk transfer */
Best regards,
Matthew
////------------------------------------------------------------- ///************** Interface Descriptor Keyboard ****************/ ////------------------------------------------------------------- 0x09, /* bLength: Interface Descriptor size */ USB_INTERFACE_DESCRIPTOR_TYPE (0x04), /* bDescriptorType: Interface descriptor type */ 0x02, /* bInterfaceNumber: Number of Interface*/ 0x00, /* bAlternateSetting: Alternate setting ## fix */ 0x01, /* bNumEndpoints */ 0x03, /* bInterfaceClass: HID fix */ 0x01, /* bInterfaceSubClass : 1=BOOT, 0=no boot ## fix */ 0x01, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/ 0x00, /* iInterface: Index of string descriptor*/ ////---------------------------------------------------------------- ///**************** HID Descriptor Keyboard ********************/ ////---------------------------------------------------------------- 0x09, /* bLength: HID Descriptor size ## fix - no change*/ 0x21, /* bDescriptorType: HID ## fix - no change*/ 0x11, /* bcdHID: HID Class Spec release number ##fix no change */ 0x01, /* High Byte of HID Class Spec number */ 0x00, /* bCountryCode: Hardware target country*/ 0x01, /* bNumDescriptors: Number of HID class descriptors to follow*/ 0x22, /* bDescriptorType fix -no change*/ 0x3F, /* wItemLength: Total length of Report descriptor*/ 0x00, /* High Byte of wItemLength */ ////------------------------------------------------------------------------- ///******************** Descriptor of Keyboard endpoint ********************/ ////------------------------------------------------------------------------- 0x07, /* bLength: Endpoint Descriptor size*/ 0x05, /* bDescriptorType: ## fix 0x05 */ HID_IN_EP (0x82), /* bEndpointAddress: Endpoint Address (IN)*/ 0x03, /* bmAttributes: Interrupt endpoint*/ 0x08, /* wMaxPacketSize: 8 Byte for keyboard transfer */ 0x00, /* High Byte of wMaxPacketSize */ 0x0A
> but the HID report descriptor is not read
Did you change the macro for HID interface number in usbcfg.h?
usbcfg.h #define USB_HID_IF_NUM 0 // <---- 2
This macro is used to process Get_Descriptor( HID_REPORT_DESCRIPTOR ), in USB_ReqGetDescriptor(), usbcore.c
Tsuneo
i checked it and the value is 3 (2 interfaces for CDC and one for HID) Meanwhile i make some more tests with the system and i found out, that the timing problem is related to the used hub (not the test system with VM). Connecting the board directly to a free usb port of the pc and win7 detects both configurations, yeah! It works under 32 / 64 System. I think the timing problem is because of not using the DMA configuration. I will try if DMA works with hub as well.
Many thanks for your attention and your help!!