• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

nrComm Lib WinUSB driver interface - not getting it to work!!

Started by symo000, June 09, 2021, 08:53:48 am

Previous topic - Next topic

symo000

Hi Roman,
I have sent several e-mails to you with regards the issue I describe here. However to-date I have not received any replies so am unsure as to whether you received the e-mails or not. Hence I decided to post the problem on the nrComm Lib (USB) forum in the hope of resolving the issue. The lack of adequate documentation makes it very difficult for someone not familiar with the operation of the nrComm Lib code to methodically debug problems. Whilst I purchased a copy of nrComm Lib with the source code I really do not want to spend any time having to trace through it to understand it in an attempt to solve the issue.

OS, development environment and tools:
- Windows 8.1
- Embarcadero XE7 (C++ Builder) - nrComm Lib correctly installed
- SysNucleus USBTrace version 3.0.1.82 (http://www.sysnucleus.com) - Windows USB stack level analyzer
- TotalPhase Beagle USB 12 Protocol Analyzer (https://www.totalphase.com/products/beagle-usb12/) - Physical USB bus level analyzer

Details:
I have correctly implemented the Windows OS descriptors on an STMicroelectronics STM32F4-Discovery board (https://www.st.com/en/evaluation-tools/stm32f4discovery.html) such that when the board is attached to my notebook, on device enumeration Windows automatically loads the winusb.sys kernel driver. Looking at the corresponding device driver properties all is in order. To test the interface I am able to use Keil's WinUSB_Test utility. By entering the DeviceInterfaceGUID (that is hard coded in the firmware) into WinUSB_Test I am able to communicate with the target and using USBTrace I am able to log the Windows USB stack level transactions. I have been able to test different control setup requests as-well-as bulk transfer, again monitoring/capturing the results with USBTrace. Since everything seems to be working I have not (yet) had a need to look at the USB transactions at the physical bus level.

The ultimate goal is to use the winusb capability of nrComm Lib's TnrUSB component to talk to USB-based embedded devices.

With the knowledge and confidence that the winusb.sys driver is correctly installed and as a starting point, I decided to compile and run the BCB usbdevicedemo example that is supplied with the nrComm Lib install. The demo compiles and runs. In the USB device box it lists all attached/enumerated USB devices, including the STMicroelectronics STLink dongle which is the debug/programming interface on the STM32F4-Discovery board and (my implemented) WinUsb device STM32F-DISCO. These USB devices both being winusb-based.

When I click on the different (non winusb-based devices) they correctly report the device properties, settings and descriptors. However when I click the winusb-based devices, the service (WinUSB) is never reported. On debugging, the service is always null along with various other device instantiation properties. To me this indicates that something (whatever it is!) is not getting initialized and as such TnrUSB doesn't see the device as being winusb-based. As a result it is impossible to go further as the device cannot be enabled if it is not recognized!!

Sadly the supporting nrComm Lib nrcomm.chm help file doesn't supply adequate information to help debug this problem. I wonder how many users have banged their heads on this problem as I cannot believe that I would be the only one.

Not having an OSR (Open System Resources) FX2 Learning Kit Demo (http://osrfx2.sourceforge.net/) I cannot use the supplied WinUsb-based USBOsrKitDemo program to validate the TnrUSB component on my machine. (I do realize the example is in Delphi - I would just have to install the Delphi component of Embarcadero XE7).

I am acutely aware that I may be doing something silly from the VCL side of things so your help in resolving this matter would be greatly appreciated. Now sorting out this problem is not urgent at the moment but I will need it in the not too distant future. If you are happy to get an STM32F4-Discovery board I am happy to send you the generated hex file. You can use the free to download utility STM32 ST-LINK (https://www.st.com/en/development-tools/stsw-link004.html) to program the device. You may then, hopefully**, be able to replicate the problem I have.

**Just thinking about it, if you have the WinUSB interface working with the OSR kit on your machine(s) then replicating the problem is a moot point.

Kind regards,
Paul

symo000

Hi Roman,

I have had a bit of spare time at hand so looked a little deeper into the above problem and am happy to report that it is solved. It will however require a couple of additions to your code.

The STM32F4_DISCO is an unclassified (USB) device. The OS descriptors embedded in the firmware allow the OS to identify the device as being MS compatible and as such the device is installed under the USBDevice class which has the ClassGUID {88bae032-5a81-49f0-bc3d-a4ff138216d6}.  I refer you to this link for interest: https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-to-install-winusb-sys-without-a-custom-inf/ba-p/270769.

On debugging your code I realized that the Class and ClassGUID I was using weren't supported, so I added them.

In nrwin32.pas I added the following line (at the appropriate place):
GUID_DEVCLASS_USBDEVICE       :TGUID = '{88bae032-5a81-49f0-bc3d-a4ff138216d6}';

and in nrusbman.pas in the procedure TnrUSBManager.ReloadHosts I added the following line of code (at the appropriate place):
DiEnumInstalledDevices(@GUID_DEVCLASS_USBDEVICE, True, True, false, slClassDevices);

I compiled my test application in which I have instantiated the TnrUSB object manually and now my embedded target board is visible with the service correctly reported as WINUSB.

Can you make the changes to your master code please and send me the recompiled nrComm Lib suite as I would now like to press on with testing/using the USB capability it offers.

Regards,
Paul
 

Roman Novgorodov

June 29, 2021, 07:56:31 am #2 Last Edit: June 29, 2021, 09:55:01 am by Roman Novgorodov
Hello Paul

Thank you for the information.

I always reply to email messages.
In your case, the message was returned with SMTP error:

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

 pauls@cu***n.net
    host cu***n.net [162.241.216.215]
    SMTP error from remote mail server after RCPT TO:<pauls@cu***n.net>:
    550-"JunkMail rejected - business18-5.web-hosting.com [198.54.116.254]:38256 is
    550-in an RBL on csi.cloudmark.com/reset-request/?ip=198.54.116.254 , see Poor
    550 Reputation Sender"

It is strange ERROR because we use dedicated hosting and our IP address is exclusive ours.
And we have no problem with others users.

It seems like your sysadmin uses non-actual anti-spam database.

Possible I repost over gmail later, but was no news from you.

Anyway:
We will add a new GUID into next release of nrComm Lib.
Thank you very much!

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

symo000

Hi Roman,

Good to hear from you. That issue with my e-mail address is a bit of a worry - I need to look into it and sort it out. Thanks for letting me know - I thought it odd not hearing from you. Anyway the forum works well as an alternative means of communication.

Awesome, I look forward to getting an updated version of nrComm Lib when you release it (hopefully that is not too far away!!). Very keen to get up and running with the WinUSB driver support as it will simplify things for me in the long run.

Keep up the good work.

Kind regards,
Paul

symo000

Hi Roman,

Just downloaded nrCommLib V9.60. Compiled and ran the basic USBDeviceDemoBCB with my WinUSB-enabled embedded target plugged in. The device is now recognized and is reported as a WinUSB device which is great as I can now move forward with using the WinUSB driver. Thanks for fixing the code.

Will be in touch via the forum should I encounter any problems that I can't resolve.

Kind regards,
Paul

Roman Novgorodov

Hello Paul

Thank you too and Yes of course I will try to help you with any future issues.


Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.