Author Topic: USB compliance testing issues  (Read 7882 times)

anthony.carr

  • Member
  • ***
  • Posts: 10
USB compliance testing issues
« on: November 28, 2013, 06:03:34 am »
Hi,

I have developed a product that is a composite device comprising a USB Audio device, USB Keyboard and USB HID.
The product is operating correctly and I can play audio and receive key events from the keyboard and HID.
I am now running the USB compliance tests but it is failing some of them.
In the Chapter 9 Tests it is failing the InterfaceDescriptorTest with no reason given as to why it's failing.
In the HID Tests it is failing the HIDClassReportDescriptorTest stating the report descriptor returned must be compliant with the HID specification.
Can anyone offer any explanation as to why my product is failing these tests?
I presume that it must be just a syntax issue as the product appears to be operating correctly.
I have put a copy of the USB descriptor below for reference.

Code: [Select]
// USB Standard Device Descriptor
const uint8_t Keyboard_DeviceDescriptor[KEYBOARD_SIZ_DEVICE_DESC] = {
0x12, // bLength
USB_DEVICE_DESCRIPTOR_TYPE,                           // bDescriptorType
0x00, // bcdUSB
0x02,
0x00, // bDeviceClass
0x00, // bDeviceSubClass
0x00, // bDeviceProtocol
0x40, // bMaxPacketSize 40
0x3E, // idVendor (0x173E)
0x17, //
0x46, // idProduct = 0x0046
0x00, //
0x04, // bcdDevice rel. 0.04
0x00, //
0x01, // Index of string descriptor describing manufacturer
0x02, // Index of string descriptor describing product
0x05, // Index of string descriptor describing the device serial number
0x01 // bNumConfigurations
}; // Keyboard_DeviceDescriptor

// USB Configuration Descriptor
// All Descriptors (Configuration, Interface, Endpoint, Class, Vendor
const uint8_t Keyboard_ConfigDescriptor[KEYBOARD_SIZ_CONFIG_DESC] = {
0x09, // bLength: Configuation Descriptor size
USB_CONFIGURATION_DESCRIPTOR_TYPE, // bDescriptorType: Configuration
KEYBOARD_SIZ_CONFIG_DESC, // wTotalLength: Bytes returned
0x00,
0x04, // bNumInterfaces: 4 interfaces (2 audio, 1 HID, 1 keyboard)
0x01, // bConfigurationValue: Configuration value
0x00, // iConfiguration: Index of string descriptor describing the configuration
0xA0, // bmAttributes: Bus powered, remote wake up
0xC8, // MaxPower 400 mA: this current is used for detecting Vbus

/************** USB Speaker Standard interface descriptor ****************/
/************** Descriptor of speaker interface ****************/
SPEAKER_SIZ_INTERFACE_DESC_SIZE, // bLength
USB_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
0x00, // bInterfaceNumber
0x00, // bAlternateSetting
0x00, // bNumEndpoints
USB_DEVICE_CLASS_AUDIO, // bInterfaceClass
AUDIO_SUBCLASS_AUDIOCONTROL, // bInterfaceSubClass
AUDIO_PROTOCOL_UNDEFINED, // bInterfaceProtocol
0x00, // iInterface

/************** USB Speaker Class-specific AC Interface Descriptor ****************/
SPEAKER_SIZ_INTERFACE_DESC_SIZE, // bLength
AUDIO_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
AUDIO_CONTROL_HEADER, // bDescriptorSubtype
0x00, // bcdADC
0x01, // 1.00
0x27, // wTotalLength = 39
0x00,
0x01, // bInCollection
0x01, // baInterfaceNr

/************** USB Speaker Input Terminal Descriptor ****************/
AUDIO_INPUT_TERMINAL_DESC_SIZE, // bLength
AUDIO_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
AUDIO_CONTROL_INPUT_TERMINAL, // bDescriptorSubtype
0x01, // bTerminalID
0x01, // wTerminalType AUDIO_TERMINAL_USB_STREAMING   0x0101
0x01,
0x00, // bAssocTerminal
0x01, // bNrChannels
0x00, // wChannelConfig 0x0000  Mono
0x00,
0x00, // iChannelNames
0x00, // iTerminal

/************** USB Speaker Audio Feature Unit Descriptor ****************/
0x09, // bLength
AUDIO_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
AUDIO_CONTROL_FEATURE_UNIT, // bDescriptorSubtype
0x02, // bUnitID
0x01, // bSourceID
0x01, // bControlSize
AUDIO_CONTROL_MUTE, // bmaControls(0)
0x00, // bmaControls(1)
0x00, // iTerminal

/************** USB Speaker Output Terminal Descriptor ****************/
0x09, // bLength
AUDIO_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
AUDIO_CONTROL_OUTPUT_TERMINAL, // bDescriptorSubtype
0x03, // bTerminalID
0x01, // wTerminalType  0x0301
0x03,
0x00, // bAssocTerminal
0x02, // bSourceID
0x00, // iTerminal

/************** USB Speaker Standard AS Interface Descriptor - Audio Streaming Zero Bandwith ****************/
/************** Interface 1, Alternate Setting 0 ****************/
SPEAKER_SIZ_INTERFACE_DESC_SIZE, // bLength
USB_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
0x01, // bInterfaceNumber
0x00, // bAlternateSetting
0x00, // bNumEndpoints
USB_DEVICE_CLASS_AUDIO, // bInterfaceClass
AUDIO_SUBCLASS_AUDIOSTREAMING, // bInterfaceSubClass
AUDIO_PROTOCOL_UNDEFINED, // bInterfaceProtocol
0x00, // iInterface

/************** USB Speaker Standard AS Interface Descriptor - Audio Streaming Operational ****************/
/************** Interface 1, Alternate Setting 1 ****************/
SPEAKER_SIZ_INTERFACE_DESC_SIZE, // bLength
USB_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
0x01, // bInterfaceNumber
0x01, // bAlternateSetting
0x01, // bNumEndpoints
USB_DEVICE_CLASS_AUDIO, // bInterfaceClass
AUDIO_SUBCLASS_AUDIOSTREAMING, // bInterfaceSubClass
AUDIO_PROTOCOL_UNDEFINED, // bInterfaceProtocol
0x00, // iInterface

/************** USB Speaker Audio Streaming Interface Descriptor ****************/
AUDIO_STREAMING_INTERFACE_DESC_SIZE, // bLength
AUDIO_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
AUDIO_STREAMING_GENERAL, // bDescriptorSubtype
0x01, // bTerminalLink
0x01, // bDelay
0x02, // wFormatTag AUDIO_FORMAT_PCM8  0x0002
0x00,

/************** USB Speaker Audio Type I Format Interface Descriptor ****************/
0x0B, // bLength
AUDIO_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
AUDIO_STREAMING_FORMAT_TYPE, // bDescriptorSubtype
AUDIO_FORMAT_TYPE_I, // bFormatType
0x01, // bNrChannels
0x01, // bSubFrameSize
8, // bBitResolution
0x01, // bSamFreqType
0xF0, // tSamFreq 22000 = 0x55F0
0x55,
0x00,

/************** Endpoint 1 - Standard Descriptor ****************/
AUDIO_STANDARD_ENDPOINT_DESC_SIZE, // bLength
USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType
0x01, // bEndpointAddress 1 out endpoint
USB_ENDPOINT_TYPE_ISOCHRONOUS, // bmAttributes
0x16, // wMaxPacketSize 22 bytes
0x00,
0x01, // bInterval
0x00, // bRefresh
0x00, // bSynchAddress

/************** Endpoint - Audio Streaming Descriptor ****************/
AUDIO_STREAMING_ENDPOINT_DESC_SIZE, // bLength
AUDIO_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType
AUDIO_ENDPOINT_GENERAL, // bDescriptor
0x00, // bmAttributes
0x00, // bLockDelayUnits
0x00, // wLockDelay
0x00,

/************** Descriptor of KPD interface ****************/
0x09, // bLength: Interface Descriptor size
USB_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType: Interface descriptor type
0x03, // bInterfaceNumber: Number of Interface
0x00, // bAlternateSetting: Alternate setting
0x01, // bNumEndpoints
0x03, // bInterfaceClass: HID
0x00, // bInterfaceSubClass : 1=BOOT, 0=no boot
0x01, // nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse
4, // iInterface: Index of string descriptor

/******************** Descriptor of KPD HID ********************/
0x09, // bLength: HID Descriptor size
HID_DESCRIPTOR_TYPE, // bDescriptorType: HID
0x10, // bcdHID: HID Class Spec release number
0x01,
0x00, // bCountryCode: Hardware target country
0x01, // bNumDescriptors: Number of HID class descriptors to follow
0x22, // bDescriptorType
KPD_SIZ_REPORT_DESC, // wItemLength: Total length of Report descriptor
0x00,

/******************** Descriptor of KPD endpoint ********************/
0x07, // bLength: Endpoint Descriptor size
USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType:
0x83, // bEndpointAddress: Endpoint Address (IN)
0x03, // bmAttributes: Interrupt endpoint
0x08, // wMaxPacketSize: 8-Byte max
0x00,
0x0A, // bInterval: Polling Interval (10 ms)

/************** Descriptor of DKP interface ****************/
0x09, // bLength: Interface Descriptor size
USB_INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType: Interface descriptor type
0x02, // bInterfaceNumber: Number of Interface
0x00, // bAlternateSetting: Alternate setting
0x01, // bNumEndpoints
0x03, // bInterfaceClass: HID
0x00, // bInterfaceSubClass : 1=BOOT, 0=no boot
0x01, // nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse
3, // iInterface: Index of string descriptor

/******************** Descriptor of DKP HID ********************/
0x09, // bLength: HID Descriptor size
HID_DESCRIPTOR_TYPE, // bDescriptorType: HID
0x10, // bcdHID: HID Class Spec release number
0x01,
0x00, // bCountryCode: Hardware target country
0x01, // bNumDescriptors: Number of HID class descriptors to follow
0x22, // bDescriptorType
DKP_SIZ_REPORT_DESC, // wItemLength: Total length of Report descriptor
0x00,

/******************** Descriptor of DKP endpoint ********************/
0x07, // bLength: Endpoint Descriptor size
USB_ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType:
0x82, // bEndpointAddress: Endpoint Address (IN)
0x03, // bmAttributes: Interrupt endpoint
0x08, // wMaxPacketSize: 8 Byte max
0x00,
0x0A // bInterval: Polling Interval (10 ms)
}; // Keyboard_ConfigDescriptor

const uint8_t KPD_ReportDescriptor[KPD_SIZ_REPORT_DESC] =
{
0x05, 0x01, // Usage page (Generic Desktop)
0x09, 0x06, // Usage (Keyboard)
0xa1, 0x01, // Collection (Application)

0x05, 0x07, // Usage page (Key Codes)
0x19, 0xe0, // Usage minimum (224)
0x29, 0xe7, // Usage maximum (231)
0x15, 0x00, // Logical minimum (0)
0x25, 0x01, // Logical maximum (1)
0x75, 0x01, // Report size (1-bit)
0x95, 0x08, // Report count (8 x 1-bit = 1-byte)
0x81, 0x02, // Input (Data, Variable, Absolute) = Modifier byte
0x81, 0x01, // Input (Constant) = Reserved byte
0x19, 0x00, // Usage minimum (0)
0x2a, 0xff, 0x00, // Usage maximum (255)
0x15, 0x00, // Logical minimum (0)
0x26, 0xff, 0x00, // Logical maximum (255)
0x75, 0x08, // Report size (8-bits)
  0x95, 0x06, // Report count (6 x 8-bits = 6-bytes)
0x81, 0x00, // Input (Data, Array) = Key code bytes (6)

0x05, 0x08, // Usage page (LEDs)
0x19, 0x01, // Usage minimum (1)
0x29, 0x05, // Usage maximum (5)
0x15, 0x00, // Logical minimum (0)
0x25, 0x01, // Logical maximum (1)
0x75, 0x01, // Report size (1-bit)
0x95, 0x05, // Report count (5 x 1-bit = 5-bits)
0x91, 0x02, // Output (Data, Variable, Absolute) = LED byte
0x95, 0x03, // Report count (3 x 1-bit = 3-bits)
0x91, 0x01, // Output (Constant) = Reserved

0xC0, // End collection
}; // KPD_ReportDescriptor

const uint8_t DKP_ReportDescriptor[DKP_SIZ_REPORT_DESC] =
{
0x06, 0x00, 0xff, // Usage page (Vendor defined)
0x09, 0xA5, // Usage (Vendor specific)
0xa1, 0x01, // Collection (Application)

0x09, 0xa7, // Usage (Vendor specific)
0x15, 0x00, // Logical minimum (0)
0x26, 0xff, 0x00, // Logical maximum (255)
0x75, 0x08, // Report size (8-bits)
  0x95, 0x08, // Report count (8 x 8-bits = 8-bytes)
0x81, 0x00, // Input (Data, Array) = Key code bytes (6)

0x06, 0x01, 0xff, // Usage page (Vendor Defined)
0x19, 0x00, // Usage minimum (0)
0x29, 0xff, // Usage maximum (255)
0x15, 0x00, // Logical minimum (0)
0x25, 0xff, // Logical maximum (255)
0x75, 0x08, // Report size (8-bits)
0x95, 0x08, // Report count (8 x 8-bits = 8-bytes) - First byte command, other bytes data
0xb1, 0x02, // Feature (Data, Variable, Absolute)

0xC0 // End collection
}; // DKP_ReportDescriptor


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB compliance testing issues
« Reply #1 on: November 30, 2013, 04:49:14 pm »
You could try

0x26, 0xff, 0x00

for the other Logical Maximum

Do you know which interface descriptor the tool is complaining about?

To keep Windows from remembering previous descriptors, with the functioning device attached, open Windows Device Manager and uninstall the device (under Driver). Then reattach with the new firmware.

anthony.carr

  • Member
  • ***
  • Posts: 10
Re: USB compliance testing issues
« Reply #2 on: December 03, 2013, 09:37:42 am »
Hi Jan,

Once again thanks for your help.
The issue with the logical maximum resolved the HIDClassReportDescriptor failure.

I ran the USB verification tool in debug mode and found some more information about the interface error.
I didn't have the interfaces in sequential order (I had them 0,1,3,2) which is what the verification tool was objecting to.
By re-ordering the descriptor this now passes the USB verification.

Many thanks,

Tony


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB compliance testing issues
« Reply #3 on: December 03, 2013, 09:59:53 am »
Thanks for reporting what you found. Good to know it's resolved.

Bret

  • Frequent Contributor
  • ****
  • Posts: 68
Re: USB compliance testing issues
« Reply #4 on: December 03, 2013, 02:06:11 pm »
I'd have to read the specs again to know for certain (it's been awhile), but I don't remember a requirement for the interfaces to be listed sequentially, or even that there couldn't be "holes" in the interface numbering pattern (e.g., having a 1 and a 3 without a 2).

Am I just not remembering correctly?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB compliance testing issues
« Reply #5 on: December 03, 2013, 04:53:12 pm »
The spec defines bInterfaceNumber as a "Zero-based value identifying the index in the array of concurrent interfaces supported by this configuration."

From that you could infer that the set of interface descriptors is considered an array and thus the indexes should be numerically sequential in the descriptor set. But I don't know of anywhere that clearly states that, maybe the compliance document?