Tuesday, April 17, 2012

WinUSB communication with STM32 (Part 1: Intro)

Aren't you fed up with putting a USB to serial converter in your embedded design while you have a USB capable device already in the design? Any other approach opens a can of worms though. Custom driver, certificate to sign it, USB vendor ID (2000$ at the moment), how to communicate with device on a layer above USB? But it is nice when OS pops up your name when your device is plugged in USB port. WinUSB is middle ground with tradeoffs one might consider.

I wanted to test the use of WinUSB with STM32F103 for some time now. When I finally got time I created a demo project. It shows basic request - response communication.
WinUSB kernel mode driver enables raw communication through USB pipes. In other words you can communicate with your USB device directly from application on the PC. So there is only code for application and code for firmware. Presuming you are not making standard USB class device like Mass Storage or HID. You might not even need custom PC side software in this case.
Furthermore the libraries to communicate are written for both ends to some extent. There SetupAPI and WinUSB on Windows side while ST has libraries for everything.
To get a taste check images below. I will post more about it in the future and probably publish the sources after I clean and organize them.

VS showing sent data.

winIDEA showing same received data on STM32.

This is the first post in this series (of total 4 posts). See  234.

[Update - I have a new WinUSB device project with STM32F407 without the need for Windows side driver info (.inf and .cat files) ]


3 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Hi, unfortunately nor the driver, nor the python script work under W8.1. Any suggestion ?

    ReplyDelete
    Replies
    1. It has been a while since I reviewed the code for this reference project.
      Did you analyze the error messages. One of the problems with Python script could be that it uses Python 2.7 syntax.
      Regarding the driver, it might need an upgrade for W8. I never tested it with W8.
      Check the WDKPath variable in the script. Does it point to your installation of WDK?
      Also check where it is used in script. Are the relative paths for DLLs OK?
      I'm not sure that INF file needs to be updated.

      Are you locked to this reference project due to the driver for old Windows or the CPU part? BTW ST lib reference might also be outdated. I'm asking because newer Windows (from XP SP3 on I think) support so called "OS USB Descriptors" which enable the device to be associated with WinUSB driver from MS without any driver files (SYS, DLL or INF). I did a reference project for that too, but it uses newer STM32F4xx part.
      If you will update sources you are having problems with please find time to send me the updates.

      Delete