Hello,
We have an FX3 based design which we are running on a Windows 10 platform which has both an ASMedia 3.0 eXtensible Host Controller and an ASMedia 3.1 eXtensible Host Controller. On the ASMedia 3.0 xHCI, data will transfer but randomly hang (we cannot communicate with the FX3 over USB when this condition occurs). But on the ASMedia 3.1 xHCI controller, the FX3 will never hang/freeze. A few things to note:
Thanks in advance,
Motz
Solved! Go to Solution.
Hi Motz,
A. CY_U3P_USB_EVENT_RESET is a LTSSM Reset. This event occurs when there is a warm reset issued by the Host. CYU3P_USBEP_SS_RESET_EVT occurs when there were lot of protocol level retries and CRC happening on the USB bus. This may happens due to bad cables/bad testing environment.
B. When the USB 3.0 device has no data, it sends NRDY to the Host. And when the device is ready, it sends ERDY.
D, E and F:
So, to handle the CYU3P_USBEP_SS_RESET_EVT event: An endpoint event callback needs to be registered using CyU3PUsbRegisterEpEvtCallback(CyU3PUsbEpEvtCb_t cbFunc, uint32_t eventMask, uint16_t outEpMask, uint16_t inEpMask).
Here the eventMask indicates for which of the events, the callback needs to be raised. If CYU3P_USBEP_SS_RESET_EVT is set in the mask, then the callback comes only for the registered IN endpoints(using inEpMask) where CYU3P_USBEP_SS_RESET_EVT happens.
When this event is triggered, we need to STALL the IN endpoint.
When the stall is done, then the API in the Host which requests data from the device times out(where the API fails) indicating that there is a STALL condition on the endpoint.
On getting the same, Host needs to send CLEAR_FEATURE request to the device.
The CLEAR_FEATURE handling on the device side, should flush the endpoint memory and reset it. Doing this would recover the IN endpoint.
The following example in the FX3 SDK can be referred where the CYU3P_USBEP_SS_RESET_EVT is handled for 2 IN endpoints:
FX3_Installation_Path\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxgpiftousb
Regards,
Hemanth
Hi Motz,
1. Are you seeing any USB endpoint event(like CYU3P_USBEP_SS_RESET_EVT) when the failure happens? To know the same, please register for the endpoint event callback using the API CyU3PUsbRegisterEpEvtCallback.
2. When the hang occurs, can you send a CLEAR_FEATURE request over EP0, targeting the End Point which caused the hang (In Endpoint).
You can implement the CLEAR_FEATURE handling for the endpoint as done in the GpifToUsb example in fx3 SDK
(EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxgpiftousb)
CLEAR_FEATURE handling in the above example code:
----------------------------------------------------------
if ((bTarget == CY_U3P_USB_TARGET_ENDPT) && (bRequest == CY_U3P_USB_SC_CLEAR_FEATURE)
&& (wValue == CY_U3P_USBX_FS_EP_HALT))
{
if (glIsApplnActive)
{
if (wIndex == CY_FX_EP_CONSUMER)
{
.....
--------------------------------------------------------------
Let me know the test results and also regarding the first point.
(It would be better if you test the above when LPM is disabled)
Regards,
Hemanth
Hi Hemanth,
Thank you very much for helping us out. We have been banging our heads on this for a couple of weeks.
Thanks again,
Motz
Hi Hemanth,
I have a follow on question:
3. Do you know what would cause a CYU3P_USBEP_SS_RESET_EVT event to occur? Maybe if we know the reason for the reset, we can do something to avoid this condition.
Best,
Motz
Hello,
I have a little more information to add. Our USB IN data is burst-y. What we think is happening is that every so many hundreds of Kilo-Bytes, we have a few micro-seconds of delay before we start filling the FX3 FIFO again. We are wondering if this is causing a delay of packets to be sent to the host controller. This is hard to verify as it is difficult to get a logic analyzer (on the FX3 FIFO interface) to trigger at the right moment that the CYU3P_USBEP_SS_RESET_EVT occurs on the USB bus.
What we do notice is that there are a series of CYU3P_USBEP_NAK_EVT events before the CYU3P_USBEP_SS_RESET_EVT occurs. So we’re wondering if the host controller is getting too many NAKs, so it then throws out a reset? I do have a few follow on questions:
else if (evType == CYU3P_USBEP_NAK_EVT)
{
CyU3PDmaChannelSuspendUsbConsumer(&glChHandleSlFifoPtoU, CYU3P_WAIT_FOREVER);
status = CyU3PDmaChannelGetBuffer (&glChHandleSlFifoPtoU, &buf_p, CYU3P_WAIT_FOREVER);
if (status != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "CyU3PDmaChannelGetBuffer failed, Error code = %d\n", status);
}
CyU3PDmaChannelResumeUsbConsumer (&glChHandleSlFifoPtoU);
}
E. We are also thinking that the above code actually did nothing, but the delay (for whatever reason) was what helped things. The reason we think this, is that just putting in a simple CyU3PThreadSleep helped. But it did not help as much as the above code. When your in a CyU3PUsbRegisterEpEvtCallback, what exactly is happening with the USB bus?
F. Again, is there someway we can recover (without host intervention) from a CY_U3P_USB_EVENT_RESET. If we could do this (quickly) this would solve all our issues.
Thanks,
Motz
Hi Motz,
A. CY_U3P_USB_EVENT_RESET is a LTSSM Reset. This event occurs when there is a warm reset issued by the Host. CYU3P_USBEP_SS_RESET_EVT occurs when there were lot of protocol level retries and CRC happening on the USB bus. This may happens due to bad cables/bad testing environment.
B. When the USB 3.0 device has no data, it sends NRDY to the Host. And when the device is ready, it sends ERDY.
D, E and F:
So, to handle the CYU3P_USBEP_SS_RESET_EVT event: An endpoint event callback needs to be registered using CyU3PUsbRegisterEpEvtCallback(CyU3PUsbEpEvtCb_t cbFunc, uint32_t eventMask, uint16_t outEpMask, uint16_t inEpMask).
Here the eventMask indicates for which of the events, the callback needs to be raised. If CYU3P_USBEP_SS_RESET_EVT is set in the mask, then the callback comes only for the registered IN endpoints(using inEpMask) where CYU3P_USBEP_SS_RESET_EVT happens.
When this event is triggered, we need to STALL the IN endpoint.
When the stall is done, then the API in the Host which requests data from the device times out(where the API fails) indicating that there is a STALL condition on the endpoint.
On getting the same, Host needs to send CLEAR_FEATURE request to the device.
The CLEAR_FEATURE handling on the device side, should flush the endpoint memory and reset it. Doing this would recover the IN endpoint.
The following example in the FX3 SDK can be referred where the CYU3P_USBEP_SS_RESET_EVT is handled for 2 IN endpoints:
FX3_Installation_Path\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxgpiftousb
Regards,
Hemanth