Crash when reading from EP0 during streaming

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
wudic_1035111
Level 1
Level 1

Hello,

I'm using CYUSB3014 working with FPGA. One Bulk ep is used as the data interface, and EP0 is only used to transfer control commands that is of 4 bytes length of both read and write direction.

When testing the system, I found that if EP0 is reading data from FX3 to PC during data transfer, FX3 could fail after several thousands of runs. When it fails, EP0 and streaming doesn't work any more, and the device cannot be listed if I restart the application(also cannot be seen on the control center, but still can be seen in the OS device manager). Even I reconnect the U3 cable, it still cannot be recognized by the driver. Only if I restart FX3, it can work again. It seems that the driver or the firmware is crashed.

I'm using CyAPI on C++ console application. One thread is streaming thread, and the other thread continuously to send read request to EP0 with no interval:

m_USBDevice->ControlEndPt->XferData(ControlBuffer, XferLen, NULL);

There is no other thread calling XferData of EP0, And there is no EP0 operation called inside the streaming thread.

If I write instead of read from EP0, it does not fail. If I read in the callback function called from the streaming thread after a frame is transferred, it also does not fail. But in real application, EP0 transfer could be called during streaming. If I keep streaming thread running but no data is transferred from FPGA while read action runs continuously, it also doesn't fail.

Thanks

W.D.

0 Likes
3 Replies
wudic_1035111
Level 1
Level 1

For more information, I added some debug print in the firmware, and found that the firmware crashed.

I added a hart beat print in the CyFxAppThread_Entry thread for loop. Each 1 sec prints once. And I found that when the communication stops, the firmware is stuck at CyU3PUsbSendEP0Data. In 5 seconds, the heart beat still works. But after 5 seconds, the debug print after CyU3PUsbSendEP0Data does not appear, and the heart beat print also stops.

0 Likes

Have you tried capturing the USB 3.0 Trace and looked into it?

Regards,

Sridhar

0 Likes

What do you mean by USB3.0 Trace? I've tried to print out the state machine state of GPIF. And I found that when it stuck, the state machine is always at wait for SLWR states. The DMA is auto, and no callback from DMA is used. I added judgement of GPIF state before sending back data to PC through EP0 to avoid EP0 and GPIF sending data to PC at the same time, and this work-around action works, after tried over 100k times no crash happened. I think there must be something wrong. The work-around can only reduce the possibility, but cannot solve the problem, as the GPIF state could be changed after checking.

Best Regards,

W.D.

0 Likes