AnsweredAssumed Answered

USB Generic HID+MSD Composite enumeration problems

Question asked by TERRY COOKE on Dec 18, 2015
Latest reply on Jan 20, 2016 by TERRY COOKE

I am re-posting from the Kinetis Fourm:

USB Generic HID+MSD Composite enumeration problems

 

I am having some strange issues:

I have a strange USB enumeration problem with a MK22FN512. It took a long time but I got the USB to enumerate properly and working, but unfortunately it only works when I have USBlyzer running to see enumeration issues. If USBlyzer is closed the device will not enumerate properly and it will always times out with a USB_PRINTF("not find interface"); in the USB_Class_Hid_Event() function in usb_hid.c.

 

With USBlyzer open it does the following in hid1_application_callback, and properly enumerates:

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

USB_HID_SET_IDLE_REQUEST

* attached is a USBlyzer capture file when it works.

 

With USBlyzer closed it does the following before timing out in hid1_application_callback:

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

USB_DEV_EVENT_BUS_RESET

and then times out at:

not find interface

 

@Mark Butcher found:

Your problem is that when the host sends a SetConfiguration (interface 1) your device is responding with a zero data paket (correct) but is it responding with a DATA0 packet, rather than a DATA1 packet and the host rejects this because it is incorrect.

After 5s or so of waiting (the device doesn't send anything else) the host restets the connection and tries again. The same repeats after the reset but sometimes also the SetAddress fails with the device returning malformed frames back - this again causes reset and it goes on forever like this (randomly failing on the SetAddress or the SetInterface).

 

This is also seen at the semi-hosting output:

 

SEGGER J-Link GDB Server V4.98b - Terminal output channel

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_DATA_RECEIVED

USB_DEV_EVENT_SEND_COMPLETE

got one raw packet

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_DATA_RECEIVED

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

got one raw packet

USB_DEV_EVENT_BUS_RESET

 

 

I have no explanation as to why it works with the analyser operating, unless it puts the interface into a promiscuous mode of some sort that allows receiving incorrect DATA packets (?)

 

Unfortunately these are fairly low-level driver problems - unless you broke something you may have uncovered latent bugs by changing the enumeration sequence length, for example.

 

So I am re-posting here because there may be some issues with the KSDK Usb drivers. I need some help tracking this down, I am completely stuck and don't know where to go from here.

Outcomes