2

I'm developing firmware for a USB device with an STM32F070 microcontroller. I generated a bare-metal (no-OS) code base with STM32CubeMX, setting the device up as a USB CDC (Communications Device Class), so that it is automatically detected as a VCP (Virtual COM Port) by Windows 7, 8, and 10. Driver Details shows that it is using the Windows usbser.sys driver.

USB CDC configuration in STM32CubeMX

USB Serial Device detected in Windows Device Manager

When I change the USB Vendor ID (VID) or Product ID (PID) or Manufacturer String, it is still quickly detected as a USB Serial Device by Windows 10 Device Manager, but not by Windows 7 or 8. Windows 7 and 8 spend a long time searching Windows Update for a driver, and then are unable to find one.

How can I modify the device firmware/descriptors to enable Windows 7 and 8 hosts to automatically install the usbser.sys driver for the device when it has vendor-specific values for the USB VID, PID, and Manufacturer String?

cp.engr
  • 2,291
  • 4
  • 28
  • 42

2 Answers2

4

Windows 10 comes with a new driver named usbser.inf that will match devices conforming to the USB CDC ACM specification and cause the usbser.sys driver to be loaded for them.

To get your USB CDC ACM device working on older versions of Windows, you will need to provide an INF file yourself that tells Windows to load usbser.sys when it sees a USB device with your vendor ID and product ID. For Windows 7, Vista, and XP, this is just a simple matter of writing the INF file and distributing it to your customers. For Windows 8 and later, you will need to purchase a code signing certificate and then sign the INF file (or look into software utilities like zadig and libwdi that let you bypass the signature checks).

Please note that signing is different from WHQL. Once you have the signing certificate, you can sign the driver yourself without any waiting time or any approval from Microsoft.

Here is an example of an INF file that uses usbser.sys:

https://github.com/pololu/a-star/blob/master/drivers/a-star.inf

I wrote a lot about how to sign driver packages in this article:

http://www.davidegrayson.com/signing/

David Grayson
  • 84,103
  • 24
  • 152
  • 189
  • Thank you very much for your multiple helpful answers to me on USB questions over the last several months. :) – cp.engr Jan 09 '17 at 18:57
  • I'd just like to note that the a-star.inf file did work for me. All I had to do was change the VID/PID values. Thanks so much! – hacksoi Jan 18 '19 at 21:40
1

the problem is the .inf file. in win 10 there is a new one (usbser.inf) that loads the driver usbser.sys automatically in win 7 and 8 you have to write your own .inf file that links your PID and VID to the usbser.sys driver, see https://msdn.microsoft.com/de-de/library/windows/hardware/ff538820%28v=vs.85%29.aspx and https://msdn.microsoft.com/de-de/library/windows/hardware/dn707976%28v=vs.85%29.aspx

In Windows 8.1 and earlier versions of the operating system, Usbser.sys is not automatically loaded when a USB-to-serial device is attached to a computer. To load the driver, you need to write an INF that references the modem INF (mdmcpq.inf) and includes [Install] and [Needs] sections. Those sections are required for instantiating the service, copying inbox binaries, and registering a device interface GUID that applications require to find the device and talk to it. That INF specifies "Usbser" as a lower filter driver in a device stack.

source: https://msdn.microsoft.com/de-de/library/windows/hardware/dn707976%28v=vs.85%29.aspx

In https://msdn.microsoft.com/de-de/library/windows/hardware/dn707976%28v=vs.85%29.aspx, Do I need to write my own host side USB driver for a CDC device and https://community.nxp.com/thread/301439 are example .inf files for win 7 and 8.

Community
  • 1
  • 1
ralf htp
  • 9,149
  • 4
  • 22
  • 34
  • Do I understand correctly that in Win7 & 8, the `.inf` file is chosen based on the {VID, PID, MfrString}, so that what I've asked for is impossible? Unless we get the device WHQL certified and have its `.inf` added to Windows Update - then windows would install the driver automatically upon enumerating the device, right? Or instead of WHQL, could we use Microsoft OS Descriptors in the device to have it present a WCID to the host, such that the host would know to choose `usbser.sys` as the driver, and no `.inf` would be needed at all? – cp.engr Jan 09 '17 at 06:36
  • 1
    either you need the .inf file (WHQL) or the MS OS descriptors. in case of the MS OS descriptors no .inf is needed (http://www.microchip.com/forums/m707870.aspx). So with the MS OS descriptors this is possible without custom .inf – ralf htp Jan 09 '17 at 07:08
  • An INF file is not the same thing as WHQL. You can use unsigned INF files on Windows 7 or below, and even on Windows 8 and above, the signing process is a simple thing you can do yourself after purchasing a code signing certificate and does not require approval from Microsoft. – David Grayson Jan 09 '17 at 16:20