Custom USB VID/PID - make Windows 7 & 8 automatically choose usbser.sys driver

cp.engr picture cp.engr · Jan 9, 2017 · Viewed 8.1k times · Source

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?

Answer

David Grayson picture David Grayson · Jan 9, 2017

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/