Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > XferData() stalls if data in buffer larger than requested byte count

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



XferData() stalls if data in buffer larger than requested byte count
Moderator:
RSKV

Post Reply
Follow this topic



XferData() stalls if data in buffer larger than requested byte count

Sil posted on 13 Feb 2012 7:50 AM PST
Top Contributor
93 Forum Posts

Hi

If I send let's say 128 Bytes upstream from the slave fifo interface by pulling low PKTEND and then want to read 12 Bytes (len=12) using XferData(buf,len), the upstream link stalls until the FX3 is reset.

I can understand that XferData(buf,len) returns 0 for len in this case because it is less than the packet size. Nevertheless, I was surprised to learn that from this instant I was not able to read data at all, even if len>=128 (larger or equal than the packet size). I was required to reset the FX3 to get the upstream link working again.

Has somebody observed this behaviour as well? I am using the V1.0 SDK.

 

-Silvio




Re: XferData() stalls if data in buffer larger than requested byte count

aasi posted on 13 Feb 2012 10:15 AM PST
Cypress Employee
1073 Forum Posts

What is happening here is when you request for 12 bytes you've allocated space for 12 bytes and the device is sending 128 bytes which will cause overflow. Even then I wouldn't expect it to stall the pipe.

Have you tried calling Abortpipe() when this occurs?

Have you tried using control center to see if the behavior is the same?

Regards,

Anand

 



Re: XferData() stalls if data in buffer larger than requested byte count

Sil posted on 14 Feb 2012 11:12 PM PST
Top Contributor
93 Forum Posts

I get the same issue when using the ControlCenter. The error reported is:

"BULK IN transfer failed with Error Code:997"

Abort() does not help to unstall the pipe. Reset() does but then I am loosing data. Please advice if you can reproduce the error.

 

-Silvio



Re: XferData() stalls if data in buffer larger than requested byte count

dekui posted on 20 Apr 2012 11:24 PM PST
Member
10 Forum Posts

 Hi!

I meet the similiar problem with cypress CY3014. Have you solved your problem?? Wish to connect with you . Many thanks1

 

Dekui



Re: XferData() stalls if data in buffer larger than requested byte count

Sil posted on 23 Apr 2012 02:34 AM PST
Top Contributor
93 Forum Posts

Unfortunately I was never able to solve this problem. Even Cypress was not able to help me. To get around this problem I do not use the PKTEND# signal anymore and make sure that there is always 1024 Bytes transferred at once (insert padding data if necessary).

 

-Silvio



Re: XferData() stalls if data in buffer larger than requested byte count

sodafarl posted on 23 Apr 2012 05:32 AM PST
Top Contributor
128 Forum Posts

Hi Silvio,

Here is how I hope to use pktend. For example if I want to send 8292 bytes (8 x 1024  + 100). The software XferData(buf,len) asks for 9216 bytes (9 x 1024). At the FX3 side the FPGA will write 8 x 1024 bytes to the FX3, it will then write 100 bytes and assert pktend. This 100 bytes will go to the host which then sees an incomplete packet which means this transfer is complete. Is this not a better way of doing things than having to pack your data up to 1024 bytes. I've tested the above process and it seems to work.

Sodafarl



Re: XferData() stalls if data in buffer larger than requested byte count

Sil posted on 23 Apr 2012 07:02 AM PST
Top Contributor
93 Forum Posts

Hello Sodafarl

But when you request more bytes than there are available, doesn't XferData() block until the timeout is reached? Ok, you could set the timeout to 0 but this brings for sure other disadvantages.

Just now I tried to request more bytes (available: 16384, requested: 17408) on my machine and stil I got 0 Bytes back. However, this was without using PKTEND# and using overlapped transactions. Nevertheless, I expected to get at least the 16384 Bytes back which wasn't the case.

 

-Silvio



Re: XferData() stalls if data in buffer larger than requested byte count

sodafarl posted on 23 Apr 2012 07:39 AM PST
Top Contributor
128 Forum Posts

Silvio,

Yes, if you ask for more bytes than are available then XferData will block, so for transfers that are made up of complete packets ask for exactly the right number of bytes but for transfers that contain an incomplete packet XferData should round up the number of bytes to the next packet size and then on device side use pktend to kick the small packet across USB to XferData. Because it  gets a small packet the driver knows this transfer is complete and XferData returns with the exact number of bytes you sent - not the number that was asked for in the XferData(buf,len).  In the example you give if you want 16384 or 17408  then XferData should ask for this but if it is a number in between then set  XferData to ask for 17408, transfer 16 packets of 1024 and then after  the smaller packet  is in FX3 use pktend to send across USB.

Sodafarl



Re: XferData() stalls if data in buffer larger than requested byte count

Sil posted on 24 Apr 2012 10:58 PM PST
Top Contributor
93 Forum Posts

Ok, this makes sense. But what I do not understand is why XferData() reads 0 Bytes if I request more bytes than are available in the input buffer. I would expect that after the timeout is reached, XferData() returns all bytes in the buffer and modifies the len parameter accordingly.

 

In addition, it makes absolutely no sense that XferData() stalls if there is more data in the input buffer than requested.

 

-Silvio



Re: XferData() stalls if data in buffer larger than requested byte count

ProHerz posted on 15 May 2012 06:29 AM PST
Member
8 Forum Posts

We are experiencing the same problem. Any good solutions or workarounds for this? Thank you!



Re: XferData() stalls if data in buffer larger than requested byte count

Sil posted on 15 May 2012 06:52 AM PST
Top Contributor
93 Forum Posts

Please Cypress people fix this annoying bug!



Re: XferData() stalls if data in buffer larger than requested byte count

Chris R. posted on 15 May 2012 12:53 PM PST
Top Contributor
135 Forum Posts

I´m not sure, but as I think, the behavior is the same as on FX2. If you request more bytes then available, the transfer only succeed if the packet end was used, even if there are n x packet size bytes available. We use packet end in nearly the same manner as on FX2 and it works without software modification (WinUSB). We request always huge data packets (1 MByte), regardless of the real ammount delivered by the FPGA. This works very well with packet end. The length variable is updated in this case.



Re: XferData() stalls if data in buffer larger than requested byte count

lanxiang posted on 02 Nov 2012 06:13 AM PST
Senior Member
17 Forum Posts

Hi everyone,

I encountered the same problem. Cy68013's almost full flag is active, that means there are enough data(512*3) in the in endpoint buffer, but in the PC's software, xFerData's returen value len=0, and can not read in any data from cy68013, it is stange. Because, at begin, it can read in data, after transfer a while,  xFerData's returen value len=0. In the firmware, the package size is 512B. And PC's software read 1024 every time. By the way, we use PKTEND# .

Could any one solve the problem? Please give me some hints. Thanks.






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.