AnsweredAssumed Answered

[MQX 4.1.1]: is USB host stack able to control the start of D+ activity?

Question asked by Hui Shao on Oct 10, 2014
Latest reply on Oct 23, 2014 by Radek Sestak

Hi-

 

My project includes a USB CDC host and USB CDC device. Host is k20d72m based while device is k20d50m powered. I have upgraded both USB stacks to MQX4.1.1 version. When device is attached to host, host is to power on and  off periodically the device for measurement polling. Once the device is plugged in, the USB host stack is loaded and stays for next round of poweron - enumeration - poweroff - "detach", until device is detached physically. My problem is that this operation only works for the first time when device is plugged in and fails on all subsequent "attachment".

 

Further investigation shows the problem is due to the fact that device bootup latency is over 150ms and that makes it miss the USB BUS Reset Condition from the host. The consequence is the device refuses the enumeration process. So question is, is there a way to postpone USB activities on the bus, particularly on D+ until my device is properly finishes bootup?

 

What I can share with folks is that as a workaround, I hacked the USB host stack in khci.c to postpone the appearance of Reset Condition:

 

static void _usb_khci_attach(USB_KHCI_HOST_STATE_STRUCT_PTR usb_host_ptr) {
    USB_MemMapPtr usb_ptr = (USB_MemMapPtr) usb_host_ptr->G.DEV_PTR;

    usb_ptr->ADDR = 0;
    _time_delay(300); /* orig 100 */

    // speed check, set
    usb_host_ptr->G.SPEED = (uint_8)((usb_ptr->CTL & USB_CTL_JSTATE_MASK) ? USB_SPEED_FULL : USB_SPEED_LOW);
    if (usb_host_ptr->G.SPEED == USB_SPEED_FULL)

 

Another issue with the USB host stack is that many times of loading/unloading stack will cause system crash on my host. I am wondering if this is the case someone else have seen. Load the stack at USB plugin and unload it at USB plugout, try this many times.

 

Thanks!

 

Hui

Outcomes