USB Driver Issues on K20 with KDS/KSK demo code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB Driver Issues on K20 with KDS/KSK demo code

1,353 Views
seanbolton
Contributor III

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

Labels (1)
0 Kudos
6 Replies

922 Views
seanbolton
Contributor III

Just to add some additional information to this problem.

I went back to the PE/KSDK USB HID Demo and generated the HID Thermometer.  This works fine.

I then make the changes I think I need to add a second EndPoint.  These are all in usbDsc1.c

See attached copies of usbDsc1_OneEP.c   and usb_TwoEP.c   to see the changes.

In summary these are ;

1.  Add additional USB_RECV endpoint to the FS_Cfg_1_Class_0_Int_0_AltSet_0_EndpointInfoArray  Array

2.  Change from 1U to 2U the number of endpoints in FS_Cfg_1_Class_0_InterfaceInfoArray

3.  In the Config Descriptor change the descriptor length from 0x22 to 0x29  (7 bytes for additional endpoint)

4. In the Interface Descriptor change the number of endpoints field from 0x01 to 0x02

5.  The EP 1 OUT descriptor is added/enabled at the end of the Config Descriptor

The effect is that whilst the one EP build works ok (see attached USB trace screenshot  ThermometerOneEP.jpg ) the build with two EPs fails with the first USB transaction on EP 0x81  (see screenshot ThermometerTwoEP.jpg)

So do I need to make any additional changes to the FSL USB driver code to support two endpoints?

Any advice much appreciated.  If you can explain how to modify the USB Demo code to add the additional OUT EP that would be really helpful.

regards


Sean

p.s.  Just realized I can't add attachments to a reply so I will attempt to add my screenshots and example code to the original post.

0 Kudos

922 Views
isaacavila
NXP Employee
NXP Employee

Hello Sean,

could you please attach your whole project? I can make some tests on TWR-K60D100M (compatible board) and try to see what the problem is.

Best Regards,

Isaac

0 Kudos

922 Views
seanbolton
Contributor III

Hi Isaac

I have been doing some more testing today and I can now get the Thermometer

demo to expand to two endpoints without the USB connection failing.

I am not sure what I changed to achieve this! I am investigating further

to understand why this is.

So please don't spend any time on this at the moment, I will get in touch

again if I find a definitive problem.

Thank you

regards

Sean

On Tue, Jan 26, 2016 at 8:29 PM, isaacavila <admin@community.freescale.com>

0 Kudos

922 Views
isaacavila
NXP Employee
NXP Employee

Hello Sean,

It is great that you could solve your problem! Yes you can contact us if further assistance is needed!

Best Regards,

Isaac

0 Kudos

922 Views
seanbolton
Contributor III

Thanks Isaac

I will be in touch if I have further issues.

Sean

On Wed, Jan 27, 2016 at 6:47 PM, isaacavila <admin@community.freescale.com>

0 Kudos

922 Views
seanbolton
Contributor III

Hi Isaac

Yes I can do that. I will upload the project tomorrow, it is a bit late

now in the UK.

Many thanks for your help.

regards

Sean

On Tue, Jan 26, 2016 at 8:29 PM, isaacavila <admin@community.freescale.com>

0 Kudos