AUTOIN, synchronous slave fifo enters stall state

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

cross mob
Anonymous
Not applicable

I'm working on my own streaming application (we're collecting high speed serial bitstream, converting it to parallel, and shipping it up USB).  We have an FPGA doing the serial->parallel conversion,  doing its own internal FIFOing, and feeding the FX2 slave interface as a master. (8 bit bus, synchronous--i think--, 40Mhz IFC clock sourced by the FPGA, SLWR pulsed when there's data to feed, etc).

   

When I use the cyconsole, my device shows up, reports my in end points, and is able to read 512 bytes when I do a bulk in.

   

I can write an application using CYApi to repeatedly do XferData() 512 bytes at a time.   My data stream is fast enough, however, that the FX2 fifo gets full and I'm forced to drop data. (I manage about 4MB/s)

   

So, I switched to overlapped IO (BeginXfer, WaitForXfer, FinishXfer) again with 512 bytes, and I can manage about 8MB/s, but I'm still being forced to drop data (we generate about 10MB/s).

   

So I started using large transfers (32KB, for example), at this point FX2/FPGA operate for a short time, and then would fall over and enter a stall state.  I don't know if this is normal or not.

   

I suspect this is when the FX2 FIFO becomes empty (which only happens when I'm transferring  enough data out of the system that I can drain the FX2 FIFO and the 4KB fifo on the FPGA) and I'm not doing something right at that point.  

   

TL;DR:   what can cause a bulk in endpoint in AUTOIN Slave FIFO mode to enter stall state?   I would have expected the endpont to NAK until data became ready, not stall.  (full disclosure, I haven't examined the USB bus, but when I get the URB stat after the pipe locks up it says stalled)

   

I can post the entirity of my slave.c and my win32 C simple streaming source code on monday when I get into the office.

0 Likes
13 Replies
Anonymous
Not applicable

 Please post your FX2LP project here.

0 Likes
Anonymous
Not applicable

 The data loss might occur if the rate at which your application is reading the data is not almost same as the rate at which you are pumping the data from FPGA.

   

You might want to to try and use Streamer application instead of your application, to see if there is a data loss.( Just change VID PID in streamer source code so that the Streamer application detects your device.)

   

Regarding why FX2LP is stalling the requests, looking into your firmware might help. So please post your code here.

   

Before that you might probably want to check if you are messing around with control and status register of IN end point in the firmware.

   

 

   

Thanks

   

Nikhil

0 Likes
Anonymous
Not applicable

 Also please post your OS specifications.

   

See if the below link helps you in any way:

   

http://msdn.microsoft.com/en-us/library/ff538112.aspx

0 Likes
Anonymous
Not applicable

Things seem to be working better today, but I'll post my code for posterity.

   

I started with AN61345, and used "slave_syncB".   Mostly, I modified it to have 2 bulk in endpoints (I'll be collecting data from two different sources and want to keep the data separated by endpoint), and changed the startup code to use my polarities, etc.

   

Attached to this message is my dscr.a51 file

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 slave.c

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 host streamer code (simple win32 console)

0 Likes
Anonymous
Not applicable

 hmmm, the descriptor file attachment didn't work:

0 Likes
Anonymous
Not applicable

 ok, apparently .a51 files can't be attached.

   

 

   

 

   
 ;;----------------------------------------------------------------------------- ;;   File:      dscr.a51 ;;   Contents:  This file contains descriptor data tables.   ;; ;;   Copyright (c) 2003 Cypress Semiconductor, Inc. All rights reserved ;;-----------------------------------------------------------------------------     DSCR_DEVICE   equ   1  ;; Descriptor type: Device DSCR_CONFIG   equ   2  ;; Descriptor type: Configuration DSCR_STRING   equ   3  ;; Descriptor type: String DSCR_INTRFC   equ   4  ;; Descriptor type: Interface DSCR_ENDPNT   equ   5  ;; Descriptor type: Endpoint DSCR_DEVQUAL  equ   6  ;; Descriptor type: Device Qualifier  DSCR_DEVICE_LEN   equ   18 DSCR_CONFIG_LEN   equ    9 DSCR_INTRFC_LEN   equ    9 DSCR_ENDPNT_LEN   equ    7 DSCR_DEVQUAL_LEN  equ   10  ET_CONTROL   equ   0   ;; Endpoint type: Control ET_ISO       equ   1   ;; Endpoint type: Isochronous ET_BULK      equ   2   ;; Endpoint type: Bulk ET_INT       equ   3   ;; Endpoint type: Interrupt  public      DeviceDscr, DeviceQualDscr, HighSpeedConfigDscr, FullSpeedConfigDscr, StringDscr, UserDscr  ;; TGE  DSCR   SEGMENT   CODE  ;;----------------------------------------------------------------------------- ;; Global Variables ;;-----------------------------------------------------------------------------  ;; TGE      rseg DSCR                 ;; locate the descriptor table in on-part memory.              cseg at 100H               ;; TODO: this needs to be changed before release DeviceDscr:          db   DSCR_DEVICE_LEN      ;; Descriptor length       db   DSCR_DEVICE          ;; Decriptor type       dw   0002H                ;; Specification Version (BCD)       db   00H                  ;; Device class       db   00H                  ;; Device sub-class       db   00H                  ;; Device sub-sub-class       db   64                   ;; Maximum packet size       dw  0c410H                ;; Vendor ID       dw   5486H                ;; Product ID (Sample Device)       dw   0000H                ;; Product version ID       db   1                    ;; Manufacturer string index       db   2                    ;; Product string index       db   0                    ;; Serial number string index       db   1                    ;; Number of configurations  DeviceQualDscr:       db   DSCR_DEVQUAL_LEN     ;; Descriptor length       db   DSCR_DEVQUAL         ;; Decriptor type       dw   0002H                ;; Specification Version (BCD)       db   00H                  ;; Device class       db   00H                  ;; Device sub-class       db   00H                  ;; Device sub-sub-class       db   64                   ;; Maximum packet size       db   1                    ;; Number of configurations       db   0                    ;; Reserved  HighSpeedConfigDscr:          db   DSCR_CONFIG_LEN      ;; Descriptor length       db   DSCR_CONFIG          ;; Descriptor type       db   (HighSpeedConfigDscrEnd-HighSpeedConfigDscr) mod 256 ;; Total Length (LSB)       db   (HighSpeedConfigDscrEnd-HighSpeedConfigDscr)  /  256 ;; Total Length (MSB)       db   1                    ;; Number of interfaces       db   1                    ;; Configuration number       db   0                    ;; Configuration string       db   10100000b            ;; Attributes (b7 - buspwr, b6 - selfpwr, b5 - rwu)       db   250                   ;; Power requirement (div 2 ma)  ;; Interface Descriptor       db   DSCR_INTRFC_LEN      ;; Descriptor length       db   DSCR_INTRFC          ;; Descriptor type       db   0                    ;; Zero-based index of this interface       db   0                    ;; Alternate setting       db   2                    ;; Number of end points        db   0ffH                 ;; Interface class       db   00H                  ;; Interface sub class       db   00H                  ;; Interface sub sub class       db   0                    ;; Interface descriptor string index        ;; Endpoint Descriptor       db   DSCR_ENDPNT_LEN      ;; Descriptor length       db   DSCR_ENDPNT          ;; Descriptor type       db   82H                  ;; Endpoint number, and direction       db   ET_BULK              ;; Endpoint type       db   00H                  ;; Maximum packet size (LSB)       db   02H                  ;; Maximum packet size (MSB)       db   00H                  ;; Polling interval   ;; Endpoint Descriptor       db   DSCR_ENDPNT_LEN      ;; Descriptor length       db   DSCR_ENDPNT          ;; Descriptor type       db   86H                  ;; Endpoint number, and direction       db   ET_BULK              ;; Endpoint type       db   00H                  ;; Maximum packet size (LSB)       db   02H                  ;; Maximum packet size (MSB)       db   00H                  ;; Polling interval  HighSpeedConfigDscrEnd:     FullSpeedConfigDscr:          db   DSCR_CONFIG_LEN      ;; Descriptor length       db   DSCR_CONFIG          ;; Descriptor type       db   (FullSpeedConfigDscrEnd-FullSpeedConfigDscr) mod 256 ;; Total Length (LSB)       db   (FullSpeedConfigDscrEnd-FullSpeedConfigDscr)  /  256 ;; Total Length (MSB)       db   1                    ;; Number of interfaces       db   1                    ;; Configuration number       db   0                    ;; Configuration string       db   10100000b            ;; Attributes (b7 - buspwr, b6 - selfpwr, b5 - rwu)       db   50                   ;; Power requirement (div 2 ma)  ;; Interface Descriptor       db   DSCR_INTRFC_LEN      ;; Descriptor length       db   DSCR_INTRFC          ;; Descriptor type       db   0                    ;; Zero-based index of this interface       db   0                    ;; Alternate setting       db   2                    ;; Number of end points        db   0ffH                 ;; Interface class       db   00H                  ;; Interface sub class       db   00H                  ;; Interface sub sub class       db   0                    ;; Interface descriptor string index        ;; Endpoint Descriptor       db   DSCR_ENDPNT_LEN      ;; Descriptor length       db   DSCR_ENDPNT          ;; Descriptor type       db   84H                  ;; Endpoint number, and direction       db   ET_BULK              ;; Endpoint type       db   40H                  ;; Maximum packet size (LSB)       db   00H                  ;; Maximum packet size (MSB)       db   00H                  ;; Polling interval  ;; Endpoint Descriptor       db   DSCR_ENDPNT_LEN      ;; Descriptor length       db   DSCR_ENDPNT          ;; Descriptor type       db   88H                  ;; Endpoint number, and direction       db   ET_BULK              ;; Endpoint type       db   40H                  ;; Maximum packet size (LSB)       db   00H                  ;; Maximum packet size (MSB)       db   00H                  ;; Polling interval  FullSpeedConfigDscrEnd:     StringDscr:  StringDscr0:          db   StringDscr0End-StringDscr0      ;; String descriptor length       db   DSCR_STRING       db   09H,04H StringDscr0End:  StringDscr1:          db   StringDscr1End-StringDscr1      ;; String descriptor length       db   DSCR_STRING       db   'C',00       db   'y',00       db   'p',00       db   'r',00       db   'e',00       db   's',00       db   's',00 StringDscr1End:  StringDscr2:          db   StringDscr2End-StringDscr2      ;; Descriptor length       db   DSCR_STRING       db   'A',00       db   'B',00       db   '-',00       db   'U',00       db   'S',00       db   'D',00       db   ' ',00       db   'F',00       db   'X',00       db   '2',00       db   ' ',00       db   'G',00       db   'P',00       db   'I',00       db   'F',00       db   ' ',00       db   't',00       db   'o',00       db   ' ',00       db   'E',00       db   'x',00       db   't',00       db   ' ',00       db   'F',00       db   'I',00       db   'F',00       db   'O',00       db   ' ',00       db   'E',00       db   'x',00       db   'a',00       db   'm',00       db   'p',00       db   'l',00       db   'e',00       db   ' ',00       db   'u',00       db   's',00       db   'i',00       db   'n',00       db   'g',00       db   ' ',00       db   'S',00       db   'i',00       db   'n',00       db   'g',00       db   'l',00       db   'e',00       db   ' ',00       db   'T',00       db   'r',00       db   'a',00       db   'n',00       db   's',00       db   'a',00       db   'c',00       db   't',00       db   'i',00       db   'o',00       db   'n',00       db   's',00 StringDscr2End:  UserDscr:             dw   0000H       end
   

 

   
    
    

 

   
0 Likes
Anonymous
Not applicable

 Now that that's all attached, I am able to send a lot of data, but occasionally it will stall (like very occasionally, and I have no idea what causes it).  I haven't checked for data integrity, but none of the win32 calls failed and I was able to transfer multiple terabytes over several hours.

   

When it does stall, the call to WaitforXfer() returns false, and then the next FinishDataXfer returns false as well.

   

The NtStatus and USBR status after WaitforXfer is 0, but "STALLED" when it returns from the failed FinishDataXfer.

   

I will say that the FPGA I'm using (Microsemi ProAsic3 starter kit) and the Daleda Dl380C ez-usb development board is a VERY noisy environment, so it might be the cause of the instability.

0 Likes
Anonymous
Not applicable

 Exact error code when it happens:

   

   

Ntstatus:   0x00000000 [[state=SUCCESS status=USBD_STATUS_SUCCESS]]

   

UsbdStatus: 0x00000000 [[state=SUCCESS status=USBD_STATUS_SUCCESS]]

   

Ntstatus:   0xc0000120 [ [state=STALLED status=UNKNOWN]]

   

UsbdStatus: 0xc0010000 [ [state=STALLED status=UNKNOWN]]

   

 

   

And it seems like it happens when I do things on my PC (like open projects, or web pages with java, etc), but not always.

   

I've tried adding '->Reset() and/or ->Abort()' but neither of those seem to clear the bad condition on the USB pipes appropriately.  I always seem to need to quit my daemon and reset my FX2/FPGA contraption to get data moving again.

   

 

   

 

   

.

0 Likes
Anonymous
Not applicable

Hi, 

   

I was wondering if you ever were able to resolve your issue. I am facing a similar problem but with the FX3. I experience a stall in both 2.0 and 3.0 modes (more frequent in 3.0). Have you come up with a workaround? The only thing we are able to do right now is close the device handle and reopen it to clear the stall. After this we have to regenerate the request. 

   

Anything Helps.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 See attached file.

   

Hope it will help.

   

Sebastien

0 Likes
Anonymous
Not applicable

 We noticed the problem on USB 3.0 but not on the USB 2.0 until now.

   

 

   

Thanks for your help.

   

 

   

Sebastien

0 Likes