1 2 3 4 Previous Next 47 Replies Latest reply on Nov 15, 2019 11:32 AM by maVa_1182686

    Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))

    maVa_1182686

      Hi,

      I had a spartan 7 fpga dumping data into the FX3 and was reading the data with a modified version of STREAMER C#.

      The protocol was BULKtransfer. I was seeing some dataloss on some computers so I needed to move Isochronous protocol.

       

      In bulk i was using 64*1024byte DMA buffers.

       

      In bulktransfer the data that gets put into xBufs[k] is always exactly the amount of data I suspect =>

      The amount of Packets per Xfer*1024.

       

      For my current application that was 19 packets of 1024. Worked like a charm

      Just go USB_data_frame = xBufs[k]

       

       

      Now that I've changed the FX3 code to ISOCHRONOUS this is not longer true.

      I had to increase the DMA buffer size as isochronous is really slow with small buffers.

       

      Currently I still need to send dataframes of 19kB but I have to send at least 8 packets per Xfer (isochronous demands this) but i also had to increase the buffersize to 4KB instead of 1024.

      Therefore, I'm sending at least 32KB every Xfer.

      This is not a problem. I can deal with this on another level.

       

      I do notice however that the packets that are coming in through

      isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))

      aren NOT 32 KB anymore.

      They're alternating between 8KB and 12KB which makes me think it's sending either 2 or 3 bursts of the 4KB dma buffers.

       

      To makes things worse, it seems that the data is skipping randomly.

      Does that have anything to do with the "overlaps"?

      USB_data_frame = xBufs[k]  does not work for sure

       

      I only have been programming C# since last week so I'm quite in over my head.

      Can anybody point me in the right direction as far as the inner workings of isoc.FinishDataXfer goes.

      The manual is sooo incredibly short and explains nothing.

       

      Thank You!!!!!!!!!!!!!!!!!!!!!

        • 1. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
          HemanthR_06

          Hi,

           

          Please provide the below info:

          1. What is the packets per xfer setting?

          2. ISOC Endpoint and Endpoint Companion Descriptor.

          3. USB trace (if possible - You can take a USB trace using Wireshark).

           

          Regards,

          Hemanth

          • 2. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
            maVa_1182686

            Hi,

            I have tried all sorts of combinations.

            4,8,16 bursts and 1 to 3 packets per uFrame.

            It all seems to be fine at the FPGA side. Flow control works as it should.I have one thread with an auto DMA channel so my FLAG(b) goes high for a brief moment indicating that the SLAVE is not ready every DMA buffer size amount of transfers.

             

            The FlagB I have assigned does also reflect the DMA buffers size increases or decreases according to DMA size = 1024*burst*packs (per uframe).

             

            A colleague, unlike me a good programmer ,  has a program he wrote in C++ (as opposed to my C# code) and it appears that the data is not like it should be in his program too. I therefore do not think that I did something wrong with finishDataXfer()

             

            Basically we now assume that something is wrong in the FX3 firmware or GPIFII statemachine hardware and that the problems start when the buffersize is a multiple of 1024.

             

            The firmware works as it should in BULK with 1024byte sized dma buffers. We changed that piece of firmware from BULK to ISO.

            The problems came when we needed to increase the buffersizes from 1024 to a multiple of this.

             

            We can't find the reason for this. It seems the GPIFII is not aware of how big buffers are. Increasing them from within the firmware is also reflected in the way flag B acts. It seems logical to me that that means that the GPIFII "knows enough" to handle the full and empty buffers at other side (where the USB portion takes data from those buffers)

             

            We are pretty much stuck now.

            • 3. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
              maVa_1182686

              Hi,

              I seemed to have replied not to you but to my original question.

              I also failed to answer correctly and assumed you asked me about the amount of data in my uFrames when instead you asked for Xfer per packet.

               

              In my app that would be 8 xfers per packet.

              In my colleques, i'm not sure.

              • 4. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                HemanthR_06

                Hi,

                 

                - In your firmware, what are the parameters passed to CyU3PDeviceCacheControl()?

                - Can you please take an USB trace when you see the problem?

                - Try with 7 burst and 0 mult setting. Packets per xfer =8 and 8KB DMA buffer size.

                 

                Regards,

                Hemanth

                • 6. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                  maVa_1182686

                  I've tried all sorts of cache combinations also. Now it is set to:

                  status = CyU3PDeviceCacheControl (CyTrue, CyFalse, CyFalse);

                   

                  We don't care about firmware performance and good caching. It's set and forget in firmware.

                   

                  How can the DMA buffer size be 8K when you the multiplier is 0, CY_FX_ISO_BURST = 7  and CY_FX_ISO_PKTS is 1,2 or 3

                  Will the buffer not be either 7, 14 or 21 KB because of which of the latler you choose?

                  • 7. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                    maVa_1182686

                    Hi,

                    I've installed the USB cap functionality in wireshark and with the following settings:

                     

                    #define CY_FX_DMA_BUF_COUNT      (2)

                    #define CY_FX_DMA_TX_SIZE        (0)    /* DMA transfer size is set to infinite */

                    #define CY_FX_ISO_PKTS                  (1)    /* Number of bursts per microframe. */

                    #define CY_FX_ISO_BURST                 (8)    /* Number of packets per burst. */

                    #define CY_FX_DMA_SIZE_MULTIPLIER       (1)

                     

                    I get packets of 16kB and 24kB. This is weird to me as I thought setting ISO PKTS would prohibit USB making 2* or 3* uFrames.

                    In my Descriptor file I also seem to indicate that USB can't make bigger than 8KB Frames.

                     

                    0x06,                           /* Descriptor size */

                        CY_U3P_SS_EP_COMPN_DESCR,       /* SS endpoint companion descriptor type */

                        (CY_FX_ISO_BURST - 1),          /* Max no. of packets in a burst(0-15) - 0: burst 1 packet at a time */

                        0,                              /* Only one 16KB burst per micro-frame. */

                        0x00, (0x04 * CY_FX_ISO_BURST), /* Bytes per interval : 1024 * 1 * burst */

                     

                     

                    Here is my Wireshark screendgrab showing the 16 and 24kB

                    Could this be the reason that my DMA engine is sending weird out of order data? It's grabbing two or three times more data from the buffers than it shoudl?

                     

                    wireshark screengrab.jpg

                    • 9. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                      HemanthR_06

                      Hi,

                       

                      Can you please share the wireshark trace file (corresponding to the image posted above)?

                       

                      Regards,

                      Hemanth

                      • 10. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                        maVa_1182686

                        Hi HemanthR.

                        I have completely started from scratch and made a new test setup with an FPGA connected to on of the FX3 devkits.

                        I started with very simple testcode on the FPGA and a completely new firmware on the FX3.

                        It's the syncslaveFIFO example from the application note but turned into a ISO souce of testdata.

                         

                        Every 1024 byes i increment a counter with the FPGA and i'm dumping into 16*1024*1 DMA buffers.

                        I know now that there is nothing wrong with the transmission.

                        You can clearly see the right data is being sent from the FPGA through the FX3 to the computer: wireshark 1.png

                        wireshark 2.pngwireshark 3.png

                         

                        As you can see, the packets are 16kB and because i increment the data every 1KB there is a 16 jump in the data from 16KB packet to the next.

                        (I'm not sending fast enough to have them aggregated. When i send data faster the packets become 8 times bigger)

                        Eitherway, when I print the test byte in the streamerexample in C# like so:

                        USBpacket = xBufs[k];

                        Console.WriteLine(USBpacket[2000].ToString());

                        inside the

                        if (isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k])) - LOOP

                         

                        The result is completely erratic (RED)

                        I expect there to be a nice increment of 16 every new time I go through the loop and

                        if (isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))    len is 16k

                         

                        length pkts=

                        16384

                        test:

                        162

                        length xBuf=

                        131072

                         

                         

                        length pkts=

                        16384

                        test:

                        242

                        length xBuf=

                        131072

                         

                         

                        length pkts=

                        0

                        length xBuf=

                        131072

                         

                         

                        length pkts=

                        16384

                        test:

                        114

                        length xBuf=

                        131072

                         

                         

                        length pkts=

                        0

                        length xBuf=

                        131072

                         

                         

                        length pkts=

                        16384

                        test:

                        2

                        length xBuf=

                        131072

                         

                         

                        length pkts=

                        16384

                        test:

                        34

                        length xBuf=

                        131072

                         

                         

                        This makes me conclude that i fail to understand how isoc.FinishDataXfer works.

                         

                        I added the trace too.

                         

                        I hope you can help me!

                        Thanks.

                        • 11. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                          maVa_1182686

                          I noticed that when i send at full speed and maximize the allocated bandwidth the DATA does make sense!

                          I increased the speed on the 16bit GPIFII bus from 5 to 75Mhz.

                           

                          I'm asking for 8 Xfers per packet.

                          When I'm sending data into the FX3 at 5 Mhz the packets on USB are only 16kB (the size of the buffer, n ot the size of 8 buffers - Xfers per packet) .

                           

                          When I'm saturating the GPIF the packets are in fact 8*16KB instead of 1*16kB.

                           

                          The data makes perfect sense:

                           

                            for (int i = 0; i < 8; i++)  //8 packets per Xfer

                                                      {

                                                          a = (USBpacket[2000 + i * 16 * 1024]);

                          //scanning the data to see if every 1024 bytes there is an increment

                                                          Console.WriteLine((a/16).ToString());

                          //devide the incremented data by 16 to remove increment of 16 and make it increment of 1

                                                      

                                                      }

                           

                          Yields

                          length pkts=

                          131072

                          test:

                          0

                          1

                          2

                          3

                          4

                          5

                          6

                          7

                          length xBuf=

                          131072

                           

                           

                          length pkts=

                          131072

                          test:

                          8

                          9

                          10

                          11

                          12

                          13

                          14

                          15

                          length xBuf=

                          131072

                           

                          Consistend behaviour inside a 131072 uFRAME (0 = > 7 ) and from one uFrame to the next (7 => 8)

                           

                          So the question remains...

                          How do you use isoc.FinishDataXfer when you are not saturating the usb bus and "incomplete" Xfers occur that are not

                           

                          packets per Xfer * DMA buffer

                           

                          in size but smaller.

                          Either 1*DMA buffer size or anything in between 1 and packets per Xfer - 1

                          • 13. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                            HemanthR_06

                            Hi,

                             

                            In ISOC transfers, it is necessary to make sure that the data is available at the device to match the rate at which Host is asking (which is according to the configuration we choose during enumeration - burst and mult). If data is not available at that rate, then we are not sure as of now about the Windows OS behavior - it has to be tested.

                             

                            From the cyusb3 driver point of view, an URB is submitted with the request equal to the size mentioned in BeginDataXfer. After the URB is submitted, then if the data is not available from the device for the requests made, then we cannot predict howmuch FinishDataXfer will return.

                             

                            So, we need to modify the endpoint configuration as per the data availability. Let me know your comments on this.

                             

                            Regards,

                            Hemanth

                            • 14. Re: Issues with isoc.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k], ref pktsInfo[k]))
                              maVa_1182686

                              Hi,

                              When i'm not reaching the correct bandwidth and the packets are smaller than expected, they still ARE coming into the computer in a logical fashion.

                              Wireshark sees them and the data in them is correct. There does not seem to be a problem with this at all.

                               

                              How can it be that it is not possible to get them out of the API  in a reliable manner when wireshark sees them without a problem?

                               

                              I don't get this.

                              1 2 3 4 Previous Next