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

USB superspeed peripherals Forum Discussions

Sebe_1916866
Level 1
Level 1
Welcome! 5 replies posted First question asked

Although I'm running .NET C#, I had this issue initially when trying to run in x64: CyUSB.dll - x64 - Matlab problem

Any CPU would work.

Anyway, I followed the advice to try CyUSB 1.2.3.0 and now I'm getting "Attempted to read or write protected memory"... no matter what configuration I build with.

NameValueType
StackTrace" at CyUSB.PInvoke.HidD_FreePreparsedData(Byte* data)\r\n at CyUSB.CyHidDevice.Open(Byte dev)\r\n at CyUSB.USBDeviceList..ctor(Byte DeviceMask, App_PnP_Callback fnCallBack)\r\n at CyUSB.USBDeviceList..ctor(Byte DeviceMask)\r\n at USBBootloaderHost.Form1..ctor() in C:\\CyBootloaderHost\\USBBootloaderHost\\Form1.cs:line 57\r\n at USBBootloaderHost.Program.Main() in C:\\CyBootloaderHost\\USBBootloaderHost\\Program.cs:line 18"string

Any advice appreciated.

My final goal is to add a feature to my app to program PSoC over USB.

Are there any examples I can download?

Thanks!

0 Likes
1 Solution

Hello,

The exception is because you are not using the proper CYUSB.dll which is compatible to both the architectures: x86 and x64.

Please follow the below steps:

1) In the current C# project remove the CyUSB present under the References.

2) Copy the CyUSB.dll present in the FX3 SDK 1.3.4 (path: <installation directory>\Cypress\EZ-USB FX3 SDK\1.3\library\c_sharp\lib) into you project folder and paste it with the other project files.

3)  Right click on the References in the solution explorer -> add reference -> Browser-> Right click on the CyUSB.dll if present and select "clear recent references"

4) Click on Browse option and browse to the CyUSB.dll present in your project folder and ADD it. Click OK.

5) Build the solution.

This should be able to build the application.

Please let me know if this was able to resolve the issue.

Thanks,

Yatheesh

View solution in original post

0 Likes
11 Replies
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

Can you please share the snippet of your application code or the entire application for us to reproduce the same.

Thanks,

Yatheesh

0 Likes

Hello,

I attached the entire test project.  Just in case I included project with the original issue using CyUSB.dll 3.4.7.0 because this was my starting point and perhaps I screwed something up by using 1.2.3.0.

Form1.cs Line 57 is where this happens if you build in x64

    usbHIDDevices = new USBDeviceList(CyConst.DEVICES_HID);

This is just a test project and I would like to eventually port this (refactored) code into our "utility" DLL, which is built in x64 and .NET 4.7.2.

Thank you for looking into this!

0 Likes

This is with 1.2.3.0 DLL

0 Likes

Hello,

The exception is because you are not using the proper CYUSB.dll which is compatible to both the architectures: x86 and x64.

Please follow the below steps:

1) In the current C# project remove the CyUSB present under the References.

2) Copy the CyUSB.dll present in the FX3 SDK 1.3.4 (path: <installation directory>\Cypress\EZ-USB FX3 SDK\1.3\library\c_sharp\lib) into you project folder and paste it with the other project files.

3)  Right click on the References in the solution explorer -> add reference -> Browser-> Right click on the CyUSB.dll if present and select "clear recent references"

4) Click on Browse option and browse to the CyUSB.dll present in your project folder and ADD it. Click OK.

5) Build the solution.

This should be able to build the application.

Please let me know if this was able to resolve the issue.

Thanks,

Yatheesh

0 Likes

Hello,

I did just that and nothing changed.  Have you tried the attached project?  I'm running VS2017, .NET 2.7.2 x64

Thanks

0 Likes

Hello,

Yes,I did work on my system. I use .NET framework 4.7.2 and Visual Studios 2019.

Refer to the screen shots below:

I have altered the application to detect the mouse connected to PC.

framework:

pastedImage_0.png

Any CPU(x86) build and debug:

pastedImage_1.png

X64 build:

pastedImage_2.png

Thanks,

Yatheesh

0 Likes

So strange and incredibly frustrating.  I simply doesn't work as you describe on your end.

Could you please zip up the entire project you have in your screenshot and upload it here?

I get the same message in 2019, Debug, AnyCPU, .NET2.7.2 as well:

pastedImage_0.png

By the way, I'm running all of this on a computer where there are no traces of FX3 SDK 1.3.4

I installed SDK on another machine just to grab DLLs.

Could it be some dependency that's missing and instead it defaults to a non-compatible Windows DLL?

Thank you for troubleshooting this with me.

0 Likes

Hello,

Please make sure that copy Local is set to true in your project under CyUSB.dll properties.

pastedImage_0.png

Please find the attached project.

0 Likes

Used your attachment and still same issue.

My next step to try is to install SDK on my computer where I'm running all this and see if it fixes the issue.

If it does, there must be some dependency on SDK that's not accounted for.

I will report later on.

Thanks!

0 Likes

Hello,

Please try using a newer version of the .NET framework. I have used 4.7.2 for building the application.

Thanks,

Yatheesh

0 Likes

Update:

I still have no idea what's so special about my laptop, I simply cannot make this work.  BUT, I decided to just try my Release build on the target machine and it does work.  It actually works on other 3 different laptops and it works there as well.  So I'm not going to waste time on this anymore because it's like finding a needle in a haystack.

Thank you for the help looking into this.  My final goal of running on .NET 4.7.2 x64 is achieved.

0 Likes