We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello Guys,
I am working on USB CDC application. I am using Windows XP and usbser.sys driver at host side. I am trying to run a loopback in which host initiated a write of 64K to USB device over BULK OUT Endpoint and then read it back over BULK IN Endpoint. This loop should be able to run indefinitely.
Now the problem is after some time, HOST stops sending IN token to device. hence device stop sending data over IN Endpoint. There is no ERR or STALL messages are being sent by either device. HOST just stops sending IN token to device.
I am not seeing this problem for small packet size like 512 bytes, 1K bytes. For these packet size loopback runs for a long time.
Kindly help me if anyone has any clue. I have read so many forum but didn't get the clue for this issue. Any help is highly appreciated.
Regards, Gaurav
Maybe see this:
http://www.keil.com/forum/16477/
search "Tsuneo Chinzei", "1-Mar-2010 16:06 GMT", "CDC device driver polls bulk IN endpoint (Polling IN transactions) repeatedly."
" While the bus is not busy, you'll see 30-40 times of IN-NAKs on the bulk IN endpoint in a 1ms USB frame. You have chances to start IN transfer on each IN transaction. But once you finishes the IN transfer (end with short packet), you don't see any IN-NAK until next frame. This behavior makes 1 transfer per 1 frame feature. "
I guess, 1. HOST is busy. 2. HOST considers your USB-CDC device is down.
Hi John,
Thanks for taking out time and replying the query.
I have checked the post and feel that it is related to the basic working of USB-CDC example. Yes, I do agree that I got an answer to a question why Host keep sending IN tokens to device? (Answer: Polling IN transactions from HOST).
In my case, USB-CDC implementation is workig fine and I am able to read/write data from/to device. The issue is when I initiates a loopback of large packets (like 4K, 64K etc), in between IN transfer, Host stops sending IN token to device. Since device is not getting IN token, transfer stops. I have checked that IN endpoint FIFO at device side has data.
Just for an additional information, following Endpoints are configured- Endpoint 0 - Control Endpoint Endpoint 1 - Interrupt Endpoint to poll device every 4ms Endpoint 5 - Bulk IN Endpoint Endpoint 6 - Bulk OUT Endpoint
I don't think Host is busy because in the protocol analyzer after host stops sending IN token to USB device for Endpoint 5, I am seeing traffic related to interrupt endpoint 1 (IN token from host and NAK token from device).
I am not able to find the reason why Host abruptly stops sending IN token to USB device? Kindly help.
Best Regards, Gaurav
1) What is the RX buffer size on Windows CDC class driver? The size is set by SetupComm() (WinAPI) or SerialPort.ReadBufferSize (.NET).
2) Depending on Windows version (Win2K or older), you may need to insert ZLP (Zero-Length Packet) to bulk IN at every 4K bytes transfer.
Tsuneo
Hi Tsuneo,
Thanks for your reply to the query.
I have not used this function and settings are default only.
I am testing this on windows Xp and handling the received ZLP from Host to device. Also I am sending ZLP to host after completion of transfer. Just to add, ZLP handling is done only in case of transfer size equal to integral multiple of endpoint size.
I think issue may be related to Rx buffer as you have mentioned. I have read your other posts and set Rx buffer as 65536 bytes using SetupComm. I ran the test case for 64K loopback, but it is still showing the same issue. Host stop sending IN packets to IN endpoint after some time.
I am studying through this buffer usage.
Please help me out.
Hmmm.. Sound like bulk IN error case.
Windows CDC driver, usbser.sys, silently stops bulk IN transactions on error. It doesn't do any error recovery, like reset_pipe. For the details, visit to this post
CDC - stalled bulk IN www.microchip.com/.../m538194.aspx
Noise on USB line is often the cause of this error. But this error is also caused when device drops bulk IN endpoint into disabled.
If you see this trouble randomly, noise may be the culprit. But if it occurs regularly, disabled bulk IN EP may be the cause.
i am seeing that this issue is coming for every test case. I checked in the analyzer, only the expected packets are seen for the device. Does it means NO noise?
How can I detect that device has disabled a specific IN endpoint? I checked, but this information is not provided in any USB registers. What could be the reason for device to disable the Bulk IN end points?
Sorry for asking you too many questions. I am bit new to USB stuff.
Thanks, Gaurav
Is there any driver which I can use instead of Usbser.sys for USB CDC?
Maybe try it with Linux or with Mac OS?