Author Topic: Get_Descriptor for Configuration has odd behavior from host  (Read 23099 times)

andychen_ca

  • Member
  • ***
  • Posts: 5
Get_Descriptor for Configuration has odd behavior from host
« on: November 14, 2011, 01:21:26 pm »
Hi:

I setup a Crtl0 with maxPacketSize 64 bytes and have a total length of 182 bytes in Configuration Descriptor. When I attach the device, the host always just issues two IN packets for the whole Configuration Descriptor transfer and showing unrecognized usb device after that. Can anyone kindly show me how to debug this issue? Does this happen when the host gets some fields misconfigured in the descriptor or it is USB hardware related? Is any tools can assist me to identify the error fields in descriptors?


Thanks,
Andy 

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Get_Descriptor for Configuration has odd behavior from host
« Reply #1 on: November 14, 2011, 01:29:59 pm »
Typically the host requests only the first 9 bytes of the config. descriptor to learn the descriptor's length, then requests the whole descriptor. The device should send the number of bytes the host requests (or less). The device must check to see how many bytes the host is requesting before returning data.

http://www.lvr.com/usbcenum.htm

Jan

andychen_ca

  • Member
  • ***
  • Posts: 5
Re: Get_Descriptor for Configuration has odd behavior from host
« Reply #2 on: November 14, 2011, 01:42:54 pm »
Hi Jan,
Thanks for the reply.

Yes. the host already learn the config descriptor once and try to get the whole config descriptor but failed in the middle. Does host always issue the enough IN packets for the completion of whole config descriptor or halt while parsing a wrong descriptor setting. From my USB analyzer revealed, the host seems behavor as later. Any idea on this. 

Thanks,
Andy

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Get_Descriptor for Configuration has odd behavior from host
« Reply #3 on: November 14, 2011, 02:38:50 pm »
The host can do whatever it wants but typically collects the whole descriptor set. If you have an analyzer, examine what the device returned. You can also post your descriptors here and maybe someone will see something.

Jan

andychen_ca

  • Member
  • ***
  • Posts: 5
Re: Get_Descriptor for Configuration has odd behavior from host
« Reply #4 on: November 14, 2011, 03:11:43 pm »
Thanks Jan.

Here is the config descriptor definition:

Audio Streaming OUT interface #1 -> IT6 -> OT7 -> speaker
Mic -> IT8 -> OT9 -> Audio Streaming IN interface #2

const uint8_t USB_HSConfigDescriptor[] = {
  USB_CONFIGUARTION_DESC_SIZE,       /* bLength */
  USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
  WBVAL(                             /* wTotalLength */
    USB_CONFIGUARTION_DESC_SIZE         +
   USB_INTERFACE_ASSOCIATION_DESC_SIZE   +
   USB_INTERFACE_DESC_SIZE             +    //interface 0
    AUDIO_CONTROL_INTERFACE_DESC_SZ(2)  +
    2*AUDIO_INPUT_TERMINAL_DESC_SIZE    +
    2*AUDIO_OUTPUT_TERMINAL_DESC_SIZE   +
    USB_INTERFACE_DESC_SIZE             +    //interface 1
    USB_INTERFACE_DESC_SIZE             +
    AUDIO_STREAMING_INTERFACE_DESC_SIZE +
    AUDIO_FORMAT_TYPE_I_DESC_SZ(1)      +
    AUDIO_STANDARD_ENDPOINT_DESC_SIZE   +
    AUDIO_STREAMING_ENDPOINT_DESC_SIZE  +   
    USB_INTERFACE_DESC_SIZE             +  //interface 2
    USB_INTERFACE_DESC_SIZE             +
    AUDIO_STREAMING_INTERFACE_DESC_SIZE +
    AUDIO_FORMAT_TYPE_I_DESC_SZ(1)      +
    AUDIO_STANDARD_ENDPOINT_DESC_SIZE   +
    AUDIO_STREAMING_ENDPOINT_DESC_SIZE   
//    USB_INTERFACE_DESC_SIZE             +    // Interface 3
//     HID_DESC_SIZE                        +
//   USB_ENDPOINT_DESC_SIZE           
   
  ),
  0x03,                              /* bNumInterfaces */
  0x01,                              /* bConfigurationValue */
  0x00,                              /* iConfiguration */
  USB_CONFIG_BUS_POWERED |       /* bmAttributes */
  USB_CONFIG_REMOTE_WAKEUP,
  USB_CONFIG_POWER_MA(50),          /* bMaxPower, device power consumption is 100 mA */

/* Interface Association Descriptor (IAD) */
  USB_INTERFACE_ASSOCIATION_DESC_SIZE,            /* bLength */
  USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE,        /* bDescriptorType */
  0x00,                              /* bFirstInterface */
  0x03,                              /* bInterfaceCount */
  USB_DEVICE_CLASS_AUDIO,            /* bFunctionClass */
  AUDIO_SUBCLASS_MIDISTREAMING,      /* bFunctionSubClass */
  AUDIO_PROTOCOL_UNDEFINED,          /* bFunctionProtocol */
  0x00,                              /* iFunction */

/* Interface 0, Alternate Setting 0, Audio Control */
  USB_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 */

/* Audio Control Interface */
  AUDIO_CONTROL_INTERFACE_DESC_SZ(2),/* bLength */
  AUDIO_INTERFACE_DESCRIPTOR_TYPE,   /* bDescriptorType */
  AUDIO_CONTROL_HEADER,              /* bDescriptorSubtype */
  WBVAL(0x0100), /* 1.00 */          /* bcdADC */
  WBVAL(                             /* wTotalLength */
    AUDIO_CONTROL_INTERFACE_DESC_SZ(2) +
    2*AUDIO_INPUT_TERMINAL_DESC_SIZE     +
    2*AUDIO_OUTPUT_TERMINAL_DESC_SIZE
  ),
  0x02,                              /* bInCollection */
  0x01,                              /* baInterfaceNr */
  0x02,                              /* baInterfaceNr */

/* Audio Input Terminal: Speaker */
  AUDIO_INPUT_TERMINAL_DESC_SIZE,    /* bLength */
  AUDIO_INTERFACE_DESCRIPTOR_TYPE,   /* bDescriptorType */
  AUDIO_CONTROL_INPUT_TERMINAL,      /* bDescriptorSubtype */
  0x06,                              /* bTerminalID */
  WBVAL(AUDIO_TERMINAL_USB_STREAMING),/* wTerminalType */
  0x00,                              /* bAssocTerminal */
  0x01,                              /* bNrChannels */
  WBVAL(AUDIO_CHANNEL_M),            /* wChannelConfig */
  0x00,                              /* iChannelNames */
  0x00,                              /* iTerminal */

/* Audio Output Terminal */
  AUDIO_OUTPUT_TERMINAL_DESC_SIZE,   /* bLength */
  AUDIO_INTERFACE_DESCRIPTOR_TYPE,   /* bDescriptorType */
  AUDIO_CONTROL_OUTPUT_TERMINAL,     /* bDescriptorSubtype */
  0x07,                              /* bTerminalID */
  WBVAL(AUDIO_TERMINAL_SPEAKERPHONE),     /* wTerminalType */
  0x00,                              /* bAssocTerminal */
  0x06,                              /* bSourceID */
  0x00,                              /* iTerminal */

/* Audio Input Terminal:Microphone */
  AUDIO_INPUT_TERMINAL_DESC_SIZE,    /* bLength */
  AUDIO_INTERFACE_DESCRIPTOR_TYPE,   /* bDescriptorType */
  AUDIO_CONTROL_INPUT_TERMINAL,      /* bDescriptorSubtype */
  0x08,                              /* bTerminalID */
  WBVAL(AUDIO_TERMINAL_DESKTOP_MICROPHONE),/* wTerminalType */
  0x00,                              /* bAssocTerminal */
  0x01,                              /* bNrChannels */
  WBVAL(AUDIO_CHANNEL_M),            /* wChannelConfig */
  0x00,                              /* iChannelNames */
  0x00,                              /* iTerminal */

/* Audio Output Terminal */
  AUDIO_OUTPUT_TERMINAL_DESC_SIZE,   /* bLength */
  AUDIO_INTERFACE_DESCRIPTOR_TYPE,   /* bDescriptorType */
  AUDIO_CONTROL_OUTPUT_TERMINAL,     /* bDescriptorSubtype */
  0x09,                              /* bTerminalID */
  WBVAL(AUDIO_TERMINAL_USB_STREAMING), /* wTerminalType */
  0x00,                              /* bAssocTerminal */
  0x08,                              /* bSourceID */
  0x00,                              /* iTerminal */

/* Interface 1, Alternate Setting 0, Audio Streaming - Zero Bandwith */
  USB_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 */

/* Interface 1, Alternate Setting 1, Audio Streaming - Operational */
  USB_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 */

/* Audio Streaming Interface */
  AUDIO_STREAMING_INTERFACE_DESC_SIZE,/* bLength */
  AUDIO_INTERFACE_DESCRIPTOR_TYPE,   /* bDescriptorType */
  AUDIO_STREAMING_GENERAL,           /* bDescriptorSubtype */
  0x06,                              /* bTerminalLink */
  0x01,                              /* bDelay */
  WBVAL(AUDIO_FORMAT_PCM),           /* wFormatTag */

/* Audio Type I Format */
  AUDIO_FORMAT_TYPE_I_DESC_SZ(1),    /* bLength */
  AUDIO_INTERFACE_DESCRIPTOR_TYPE,   /* bDescriptorType */
  AUDIO_STREAMING_FORMAT_TYPE,       /* bDescriptorSubtype */
  AUDIO_FORMAT_TYPE_I,               /* bFormatType */
  0x01,                              /* bNrChannels */
  0x02,                              /* bSubFrameSize */
  16,                                /* bBitResolution */
  0x01,                              /* bSamFreqType */
  B3VAL(32000),                      /* tSamFreq */

/* Endpoint, EP2 ISO OUT - Standard Descriptor */
  AUDIO_STANDARD_ENDPOINT_DESC_SIZE, /* bLength */
  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
  USB_ENDPOINT_OUT(2),               /* bEndpointAddress */
  USB_ENDPOINT_TYPE_ISOCHRONOUS,     /* bmAttributes */
  WBVAL(64),                         /* wMaxPacketSize */
  0x01,                              /* bInterval */
  0x00,                              /* bRefresh */
  0x00,                              /* bSynchAddress */

/* Endpoint - Audio Streaming */
  AUDIO_STREAMING_ENDPOINT_DESC_SIZE,/* bLength */
  AUDIO_ENDPOINT_DESCRIPTOR_TYPE,    /* bDescriptorType */
  AUDIO_ENDPOINT_GENERAL,            /* bDescriptor */
  0x00,                              /* bmAttributes */
  0x00,                              /* bLockDelayUnits */
  WBVAL(0x0000),                     /* wLockDelay */

/* Interface 2, Alternate Setting 0, Audio Streaming - Zero Bandwith */
  USB_INTERFACE_DESC_SIZE,           /* bLength */
  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
  0x02,                              /* bInterfaceNumber */
  0x00,                              /* bAlternateSetting */
  0x00,                              /* bNumEndpoints */
  USB_DEVICE_CLASS_AUDIO,            /* bInterfaceClass */
  AUDIO_SUBCLASS_AUDIOSTREAMING,     /* bInterfaceSubClass */
  AUDIO_PROTOCOL_UNDEFINED,          /* bInterfaceProtocol */
  0x00,                              /* iInterface Microphone */

/* Interface 2, Alternate Setting 1, Audio Streaming - Operational */
  USB_INTERFACE_DESC_SIZE,           /* bLength */
  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
  0x02,                              /* bInterfaceNumber */
  0x01,                              /* bAlternateSetting */
  0x01,                              /* bNumEndpoints */
  USB_DEVICE_CLASS_AUDIO,            /* bInterfaceClass */
  AUDIO_SUBCLASS_AUDIOSTREAMING,     /* bInterfaceSubClass */
  AUDIO_PROTOCOL_UNDEFINED,          /* bInterfaceProtocol */
  0x00,                              /* iInterface Microphone */

/* Audio Streaming Interface */
  AUDIO_STREAMING_INTERFACE_DESC_SIZE,/* bLength */
  AUDIO_INTERFACE_DESCRIPTOR_TYPE,   /* bDescriptorType */
  AUDIO_STREAMING_GENERAL,           /* bDescriptorSubtype */
  0x09,                              /* bTerminalLink */
  0x01,                              /* bDelay */
  WBVAL(AUDIO_FORMAT_PCM),           /* wFormatTag */

/* Audio Type I Format */
  AUDIO_FORMAT_TYPE_I_DESC_SZ(1),    /* bLength */
  AUDIO_INTERFACE_DESCRIPTOR_TYPE,   /* bDescriptorType */
  AUDIO_STREAMING_FORMAT_TYPE,       /* bDescriptorSubtype */
  AUDIO_FORMAT_TYPE_I,               /* bFormatType */
  0x01,                              /* bNrChannels */
  0x02,                              /* bSubFrameSize */
  0x10,                                /* bBitResolution */
  0x01,                              /* bSamFreqType */
  B3VAL(16000),                      /* tSamFreq */

/* Endpoint, EP3 ISO IN - Standard Descriptor */
  AUDIO_STANDARD_ENDPOINT_DESC_SIZE, /* bLength */
  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
  USB_ENDPOINT_IN(3),               /* bEndpointAddress */
  USB_ENDPOINT_TYPE_ISOCHRONOUS,     /* bmAttributes */
  WBVAL(32),                         /* wMaxPacketSize */
  0x01,                              /* bInterval */
  0x00,                              /* bRefresh */
  0x00,                              /* bSynchAddress */

/* Endpoint - Audio Streaming */
  AUDIO_STREAMING_ENDPOINT_DESC_SIZE,/* bLength */
  AUDIO_ENDPOINT_DESCRIPTOR_TYPE,    /* bDescriptorType */
  AUDIO_ENDPOINT_GENERAL,            /* bDescriptor */
  0x00,                              /* bmAttributes */
  0x00,                              /* bLockDelayUnits */
  WBVAL(0x0000),                     /* wLockDelay */

/* Terminator */
  0                                  /* bLength */
};

Thanks,
Andy

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Get_Descriptor for Configuration has odd behavior from host
« Reply #5 on: November 14, 2011, 09:07:53 pm »
I would look at:

How many data bytes did the host request?

Does that value match what the device sent as wTotalLength in the first request?

How many data bytes did the device send? 

Did the host ACK both packets?

Jan


andychen_ca

  • Member
  • ***
  • Posts: 5
Re: Get_Descriptor for Configuration has odd behavior from host
« Reply #6 on: November 15, 2011, 12:41:05 pm »
Thanks Jan.

64 bytes is the maxPacketSize setting in the device descriptor and 182 bytes is the wTotalLength in configuration descriptor.
The Host has ACK for the first two IN packets with packet size 71 bytes (7 bytes for header and 64 bytes for data).
Then the host stalls sending IN packet for the rest of configuration descriptor data as I see in FT4USB analyzer.

It works well for individual interface (either speaker or mic interface can be reconginzed by WinXP) but not both.

Any idea about to identify which fields in descriptor setting get wrong?

Thanks,
Andy

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Get_Descriptor for Configuration has odd behavior from host
« Reply #7 on: November 15, 2011, 12:53:26 pm »
By stall, do you mean that the host sends an IN token packet and the endpoint returns STALL?

Does the host send anything at all to any of the device's endpoints after receiving the first two packets? Endpoint halt? Port reset?

Does the host make multiple attempts to enumerate?

Jan

andychen_ca

  • Member
  • ***
  • Posts: 5
Re: Get_Descriptor for Configuration has odd behavior from host
« Reply #8 on: November 15, 2011, 06:25:29 pm »
Thanks Jan for the help.
The issue has been resolved after revising the ISR code that handles Setup packet and IN packet.


Thanks everybody who helps me on this issue,
Andy

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Get_Descriptor for Configuration has odd behavior from host
« Reply #9 on: November 15, 2011, 10:12:40 pm »
Thanks for letting us know.

Jan