AnsweredAssumed Answered

USB Driver Issues on K20 with KDS/KSK demo code

Question asked by Sean Bolton on Jan 21, 2016

Hi

 

I am working on a USB HID based driver for a K20 based product.

 

I am using KDS version 3.0.0 and KSDK 1.3.0

 

Starting in Processor Expert (PE) I generated the example HID code and this runs OK.

 

I then expanded the Endpoint Array and the device descriptor files to add an OUT End Point (EP1) to the HID.

 

When attached to a PC running Windows 10 the new device is detected as a USB device and it is interrogated for the device, configuration and report descriptors.  These are transferred successfully.  The device then initiates two transfers on the IN EP 81.  After 2.5 mSec these transfers are aborted for some reason.

 

See attached screenshot of the USB message trace taken from the PC.

 

At 2.770791 seconds after boot up the transfer on EP 81 is started.

 

This transfer is aborted 2.5 mSec later with a Transaction Error.

 

This only occurs once I add the additional OUT endpoint.  With the single IN endpoint the PC receives data OK on EP 81.

 

Below are my descriptors.  The main changes are to extend the Configuration descriptor to have two EPs, and to add an additional endpoint to the FS_Cfg_1_Class_0_Int_0_AltSet_0_EndpointInfoArray  Array.

 

I am now struggling to understand why the USB stack is failing in this way during initialisation.  The exact same Descriptors are used OK on another product (different processor) so I believe the descriptor format is OK.  Is there something I am missing when modifying the fsl stack module to provide the extra Endpoint.

 

Any help or advice much appreciated.

 

Thank you

 

Sean

 

 

 

below, modified descriptors from usbDsc1.c

 

// Add additional endpoint

/* hid1: FS_Cfg_1_Class_0_Int_0_AltSet_0 endpoint info array */                  

static usb_ep_struct_t FS_Cfg_1_Class_0_Int_0_AltSet_0_EndpointInfoArray [] = {

  { /* hid1_PipeIn */  

    1,                                                                /* Endpoint number */

    USB_INTERRUPT_PIPE,                                               /* Endpoint type */

    USB_SEND,                                                         /* Endpoint direction */

    64                                                                 /* Maximum packet size */

  },

  { /* hid1_PipeIn */

     1,                                                                /* Endpoint number */

     USB_INTERRUPT_PIPE,                                               /* Endpoint type */

     USB_RECV,                                                         /* Endpoint direction */

     64                                                                /* Maximum packet size */

   }

};

 

/* Full speed Configuration 0 Interface  settings */                  

static usb_if_struct_t FS_Cfg_1_Class_0_InterfaceInfoArray [] = {

  {

    0,                                                               /* Interface number */

    { /* Interface alternate setting 0 endpoints */

      2U,                                                            /* Endpoint count */

      FS_Cfg_1_Class_0_Int_0_AltSet_0_EndpointInfoArray              /* Endpoint info array address */       

    }

  }

};

 

uint8_t usbDsc1_FS_DeviceDescriptor[]={

   0x12,                                /* Descriptor size: 18 bytes */

   USB_DEVICE_DESCRIPTOR,               /* Descriptor type: Device descriptor */

   0x00,0x02,                           /* USB specification release number: USB 2.0 */

   0x00,                                /* Device class code: 0x00 Class information at interface level */

   0x00,                                /* Device subclass code: 0 */

   0x00,                                /* Device protocol code: 0 */

   0x40,                                /* EP0 maximum packet size: 8 bytes */

   0xD8,0x04,                           /* Vendor ID: 1240 */

   0x40,0xFC,                           /* Product ID: 64576 */

   0x02,0x00,                           /* Device release number in: 02.00 */

   0x01,                                /* Manufacturer string descriptor index */

   0x02,                                /* Product string descriptor index */

   0x00,                                /* Serial number string descriptor index */

   0x01                                 /* Number of possible configurations */

};

 

uint8_t usbDsc1_Full_Speed_Configuration_1[]={

  /***************************************************************************/

  /* Configuration 1 Descriptor    Latitude                                  */

  /***************************************************************************/

  0x09,                                /* Descriptor size: 9 bytes */

  USB_CONFIGURATION_DESCRIPTOR,        /* Descriptor type: Configuration descriptor */

  0x29,0x00,                           /* Total length of data for this configuration: 41 bytes */

  0x01,                                /* No of interfaces supported by this configuration */

  0x01,                                /* Designator value for this configuration */

  0x00,                                /* Configuration string descriptor index */

  0xC0,                                /* Power source: self powered, remote wake-up: yes */

  0x32,                                /* Max. power consumption: 50 mA */

  /***************************************************************************/

  /* hid1: Interface 0 Alternate setting 0 Descriptor                        */

  /***************************************************************************/

  0x09,                                /* Descriptor size: 9 bytes */

  USB_INTERFACE_DESCRIPTOR,            /* Descriptor type: INTERFACE descriptor */

  0x00,                                /* Interface number: 0 */

  0x00,                                /* Alternative setting number: 0 */

  0x02,                                /* Number of EPs(excluding EP0): 2 */

  0x03,                                /* Class code: 0x00 HID */

  0x00,                                /* Subclass code: 0x00 No Subclass */

  0x00,                                /* Protocol code: 0x00 None */

  0x00,                                /* String descriptor index */

  /***************************************************************************/

  /* HID Descriptor                                                          */

  /***************************************************************************/

  0x09,                                /* Descriptor size: 9 bytes */

  USB_HID_DESCRIPTOR,                  /* Descriptor type: HID descriptor */

  0x11,0x01,                           /* HID specification release number: 1.11 */

  0x00,                                /* Country code: 0x00 Not Supported bytes */

  0x01,                                /* Number of class descriptors : 1 */

  USB_HID_REPORT_DESCRIPTOR,           /* Descriptor type: HID_REPORT descriptor */

  0x1D,0x00,                           /* Descriptor size: 29 bytes */

  /***************************************************************************/

  /* hid1: Endpoint FS Interrupt EP1 IN, 62.5 B/s Descriptor                 */

  /***************************************************************************/

  0x07,                                /* Descriptor size: 7 bytes */

  USB_ENDPOINT_DESCRIPTOR,             /* Descriptor type: ENDPOINT descriptor */

  0x81,                                /* Address: 1 EP IN */

  0x03,                                /* Transfer type: 3=Interrupt  2=Bulk */

  0x40,0x00,                           /* Max. packet size: 64 byte(s) */

  0x01,                                /* Polling interval: 128 ms */

  /***************************************************************************/

  /* hid2: Endpoint FS Interrupt EP2 OUT, 62.5 B/s Descriptor                 */

  /***************************************************************************/

  0x07,                                /* Descriptor size: 7 bytes */

  USB_ENDPOINT_DESCRIPTOR,             /* Descriptor type: ENDPOINT descriptor */

  0x01,                                /* Address: 1 EP OUT */

  0x03,                                /* Transfer type: 3=Interrupt 2=Bulk */

  0x40,0x00,                           /* Max. packet size: 64 byte(s) */

  0x01                                 /* Polling interval: 128 ms */

};

 

uint8_t hid1_ReportDescriptor[] = {

 

 

0x06, 0x00, 0xFF,       // Usage Page = 0xFF00 (Vendor Defined Page 1)

0x09, 0x01,             // Usage (Vendor Usage 1)

0xA1, 0x01,             // Collection (Application)

0x19, 0x01,             //      Usage Minimum

0x29, 0x40,             //      Usage Maximum //64 input usages total (0x01 to 0x40)

0x15, 0x00,             //      Logical Minimum (data bytes in the report may have minimum value = 0x00)

0x26, 0xFF, 0x00,   //      Logical Maximum (data bytes in the report may have maximum value = 0x00FF = unsigned 255)

0x75, 0x08,             //      Report Size: 8-bit field size

0x95, 0x40,             //      Report Count: Make sixty-four 8-bit fields (the next time the parser hits an "Input", "Output", or "Feature" item)

0x81, 0x00,             //      Input (Data, Array, Abs): Instantiates input packet fields based on the above report size, count, logical min/max, and usage.

0x19, 0x01,             //      Usage Minimum

0x29, 0x40,             //      Usage Maximum //64 output usages total (0x01 to 0x40)

0x91, 0x00,             //      Output (Data, Array, Abs): Instantiates output packet fields.  Uses same report size and count as "Input" fields, since nothing new/different was specified to the parser since the "Input" item.

0xC0                   // End Collection

 

 

}; /* End of Report Descriptor */

 

 

UPDATE:  Now added comparison code of UsbDsc1.c for one or two EPs with Demo Thermometer.  One EP works, Two EP fails.  See attached Screenshots.

 

Message was edited by: Sean Bolton  added test info of trying to adapt demo Thermometer code from one to two EPs.

Original Attachment has been moved to: UsbDsc1_TwoEP.c.zip

Original Attachment has been moved to: UsbDsc1_OneEP.c.zip

Outcomes