Failure for SuiteUSB using .NET API for PassMark USB 3.0 plug

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

cross mob
MaSy_4695346
Level 2
Level 2
10 sign-ins 10 replies posted 5 replies posted

Dear all,     (and @YatheeshD_36)

Almost 18 months ago I was having some issues in using the .Net Api for Cypress EZ-USB FX3 SDK.

However I got some really nice help in this thread:
https://community.infineon.com/t5/USB-Low-Full-High-Speed/SuiteUSB-using-NET-API-for-PassMark-USB-3-...

The issue was resolved and everything has been running smoothly for the last 18 months until the other day.
What has changed? Nothing obvious that I'm aware of, but our IT department has updated machines with Windows security patches if that could make a difference. 

 

What seems to happen is the following:

  1. The device (Passmark USB3.0) inserted into the machine.
  2. My code is using the CyUSB  .Net interface for the CyUsb3.sys driver.
    MaSy_4695346_5-1635173899511.png
  3. My code checks that the endpoints are USB 3.0 by checking the size of the MaxPktSize of the endpoint and making sure that it is not below 0x4000.
    MaSy_4695346_0-1635172580370.png

     

  4. This is all good. Then my program creates an arbitrary buffer of 65k data and calls the
    endpoint function XferData.
    MaSy_4695346_1-1635172688221.png
  5. This fails and if I debug fairly deep down in CyEndPoints.cs (at line 367 in function BeginDataXfer) I can see that _lastError is set to 997. The function returns a true so this might be as expected.
  6. After this the function FinishDataXfer is called to get the overlapped result.  However the rResult from the GetOverlappedResult function returns false and the len is set to 0 bytes.
  7. No bytes are being transmitted.
  8. One observation is that after the device was inserted the Cypress Control Center reports a descriptor info with a Bulk channel with MaxPktSize of 16384.
    MaSy_4695346_2-1635173200977.png
  9. After the transmittal failure the device info reports just a bulk channel of 1024 bytes (which is what I interpret as HS instead of SS)
    MaSy_4695346_3-1635173277037.png
  10. However the device still seems to be enumerated at SS from what it will let you know through its display.
    MaSy_4695346_4-1635173434563.png

    (The Passmark testprogram does not show any errors and happily runs at SuperSpeed (USB3.0))

  • There have been no code changes for my code. 
  • From what I can tell there are no updates to the Cypress / Infineon SDK (EZ-USB FX3 SDK 1.3.4 for Windows)
  • There are no updates to the FW of the Passmark adapter nor to their driver during the last 18 months.

If someone has any idea what I should try to look further into, or has any advice on how to move forward,  it would be greatly appreciated.

King regards
Magnus

 

0 Likes
1 Solution

Hi Magnus,

I went through the source code, 

if I comment the line, 
SelectedUSBDevice.ReConnect();

The xferData API runs successfully. When this line is uncommented, the failure happens.

Could you please check why renumeration of FX3 with a new firmware is required?

Best Regards,
AliAsgar

View solution in original post

0 Likes
17 Replies
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Magnus,

Could you try performing xferData(..) without the third argument (packetMode) and let us know if the issue persists?
var writeDataResultStatus = outEndPoint.XferData(ref dataToSend, ref currentTransferSize)

Best Regards,
AliAsgar

Best Regards,
AliAsgar

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

Hi AliAsgar,

Thank you very much for your reply !

I tried your suggestion, to use the overloaded function without packetMode,

 

MaSy_4695346_1-1635238822016.png

but this does not seem to make any difference.
I tried to debug down and I see that the rResult (at line 387) from the GetOverlappedResult function returns false (which I assume is not good). However the GetLastError returns 0 which I assume that means that Windows thinks that all is good.

MaSy_4695346_2-1635239115287.png

The len parameter (at line 391) is then set to the bytes array buffer which contains only 0 and later on the _bytesWritten is also set to zero. Both _usbdStatus and _ntStatus are 0.

I have attached a zip file with the small testprogram I use. You probably don't have a Passmark dongle, but I assume that you have something with a FX3 chip that might do as a "getting started hardware".
You can compile the solution using Visual Studio 2019 and the required packages should be automatically downloaded via the NuGet package manager.

if you run the console application you should see something like 

MaSy_4695346_3-1635241706857.png

where you can press T to get started. Since you don't have the same hardware as I do I'm not sure how far you will get, but hopefully the source code can give you some idea of what is happening.

Let me know if there is anything else you need from me.

Again, thank you very much for your help !

King regards
Magnus

0 Likes

Hi Magnus,

1. MaxPktSize of 1024 bytes is also SS USB itself. It is not HS. MaxPktSize of 16KB is seen when packet size of 1024 has a burst size of 16.

2. Could you let us know how you were able to debug inside the CyEndpoiny.cs file?

3. Could you share with us the snippet of the terminal when the test fails?

Best Regards,
AliAsgar

0 Likes

Hello AliAsgar,

1) Okay, this is probably true but when I developed my C# code (14 months ago) the packet size was always 16kB for USB3 no matter what. If I plugged in the PassMark (PM) device to a USB2 hub it was always 1024 bytes.
Today the packet size is always 16 kB the first time I insert the PM device (in a USB3 slot) and then when data sending process fails it always reverts back to 1024 bytes. The only way to get it back to 16 kB is to physically remove the PM device and re-insert it. (The PM device still says it's connected as a USB3 device)
This behaviour is new to me.

 

2) Visual Studio does this right out of the box (by using reflection) since it decompiles your dll. Another way of just looking at the code is to download dotPeek from JetBrains and just load the CyUSB.dll, which then enables you to browse the code.
https://www.jetbrains.com/decompiler/download/#section=web-installer

MaSy_4695346_1-1635407872152.png

The reason that this is possible is (I assume) that you might have the dll delivered in debug mode. Also your code is most likely not obfuscated. 

 

3)

MaSy_4695346_0-1635407833175.png

 

My manager is pushing really hard on me to get this back to a working state. This gives me only one or two days before I will have to try a different approach. This approach would be to leave the Cypress/Infineon .NET implementation and start to try to convert the PassMark  C++ code to something that I can run in my environment.

Looking forward hearing from you.

King regards
Magnus

0 Likes

Hi Magnus,

I went through the source code, 

if I comment the line, 
SelectedUSBDevice.ReConnect();

The xferData API runs successfully. When this line is uncommented, the failure happens.

Could you please check why renumeration of FX3 with a new firmware is required?

Best Regards,
AliAsgar

0 Likes
MaSy_4695346
Level 2
Level 2
10 sign-ins 10 replies posted 5 replies posted

Hello AliAsgar,

Thank you for your reply !

This is a really good question. I can see that the PassMark company does this in their C++ implementation, but it turns out that they only do if they fail to open the device after the configuration of the device has been done.

MaSy_4695346_0-1635758701373.png

I'm not even sure what this configuration does. It obviously sets something in their device (or the FX3 chip) but I have no idea if this is needed or not.

 

I have tried to remove the call "ConfigurePlug(device, USB30_SPEED.USB30ST_SS);" in my code I don't have any problems running the tests now. I'm not sure why the code was even there but it might have been something I tried previously to get things working before you guys helped me last time. (Still a big thank you for that)


However there seem to be some discrepancies regarding the throughput that I really can't get my head around.

When I run my testprogram (using your .NET implementation) I get the following:

MaSy_4695346_1-1635759094164.png


When I run PassMarks Windows UI program on the same hardware I get

MaSy_4695346_3-1635759167425.png

and when I run PassMark:s C++ console test application I get

MaSy_4695346_4-1635759243786.png
(which equates to 497614848/1000/1000/10 = 49MiB/s or 47MB/s)

For a connection test this is probably good enough but if someone wants my test to be a performance test I'm not sure what to say. What is the speed that can be expected? (As a ballpark I mean, I understand that it is somewhat dependant on your hardware in general)

 

King regards
Magnus

0 Likes

Hi Magnus,

Could you test the throughput with our streamer application provided with the FX3 SDK?

Also please look at the application note given in the link: https://www.cypress.com/documentation/application-notes/an86947-optimizing-usb-30-throughput-ez-usb-...

Best Regards,
AliAsgar

0 Likes

Hello AliAsgar,

I've been trying to use your Streamer test application but no matter what I set the properties to I can't seem to get a single byte through.... 😞

MaSy_4695346_0-1635782064916.png

I've hadn't had time to look into the source so I can't really tell what the problem is, but just running your executable from the location
C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\application\cpp\streamer\x86\Release
does not seem to work for me...

King regards
Magnus

0 Likes

Hi Magnus, 

If the firmware used on the FX3 has a loopback application,
Could you instead use the bulkloop application and let us know if the transfers are success there and what is the data rate in that case?

Best Regards,
AliAsgar

 

0 Likes
MaSy_4695346
Level 2
Level 2
10 sign-ins 10 replies posted 5 replies posted

Hello AliAsgar,

I'm not sure how I even would check if the fw on the FX3 has a bulk application or not. My guess would be it does, since the PassMark UI software provides a loopback test.
Here I was running the test for 13 seconds:

MaSy_4695346_0-1635863592301.png

with the following test condition.

MaSy_4695346_1-1635863628231.png

I hope this helps.

King regards
Magnus

0 Likes

Hi Magnus,

I tried running the shared host application with the UsbBulkLoopAuto firmware example provided in the FX3 SDK.

I have got the below results.

 

Capture.PNG

Can you confirm if  "if(!writeDataResultStatus)" as shown in the picture below is present in your source code too?

Capture2.PNG

If possible, could you share the firmware .img file used to program the fx3 hardware?

Best Regards,
AliAsgar

0 Likes

Hello AliAsgar,

Thanks for your tests. They results you get are quite interesting !! Your numbers are more in line with what I would expect.

Yes, I can confirm that my source code is like the one you have.

MaSy_4695346_0-1635929581516.png

However, my speed is still about half of what you are getting.

MaSy_4695346_1-1635929739362.png

We don't program the FX3 hardware with anything. We use the Passmark device  as is (it is pre-programmed from the vendor).
My PM device has the latest available firmware that PM has on their homepage.
https://www.passmark.com/products/usb3loopback/download.php

I hope that the above helps !

King regards
Magnus

 

0 Likes

... and setting packetMode to false does not seem to make any difference

MaSy_4695346_2-1635930408053.png

MaSy_4695346_3-1635930507258.png

when compared to setting packetMode to true.

MaSy_4695346_4-1635930594242.png

King regards
Magnus

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

Hi,

Could you program the PassMark device using the attached .img file and let us know the data rate in the host application, if you are successfully being able to program the device with the image file.

Best Regards,
AliAsgar

0 Likes

Hello AliAsgar,

I will probably have to hold this test off a couple of days. The reason is that currently I only have one PassMark device and if I screw it up in some way, I'll be in big trouble for my current work.
We're expecting more PassMark devices to arrive but ETA is currently unclear. 

King regards
Magnus

 

0 Likes

Hi Magnus,

Shall I close this thread for now? You could always open a new thread.

Best Regards,
AliAsgar

0 Likes

Hello AliAsgar,

Yes, close the thread for now. I'll open a new thread when I have the chance !

Thanks for all your help!

King regards
Magnus

0 Likes