title: Windows 10 - clean out USB enumeration/driver cruft
body: <h1>Summary</h1>
  <p>I'm developing firmware and a PC test application for a custom USB device, using the <a href="http://www.st.com/en/evaluation-tools/32f072bdiscovery.html" rel="noreferrer">STM32F072 Discovery board</a>. The device includes Microsoft <a href="https://github.com/pbatard/libwdi/wiki/WCID-Devices" rel="noreferrer">Windows Compatible IDs (WCIDs) to enable automatic installation</a> of the WinUSB driver on the PC.</p>
  <p>The device is enumerated correctly on other Windows 10 hosts, but not on my Windows 10 development PC. My development PC had previously tried to enumerate the device when it had the same VID/PID combo, but with different descriptors/metadata. If I change the PID to some other number (new to my development PC), it <em>does</em> enumerate correctly.</p>
  <h1>Questions</h1>
  <ol>
  <li>How can I get this to work with my desired VID/PID combo on my development PC?</li>
  <li>Is Windows caching USB metadata the cause of the failed enumeration on this one PC?</li>
  <li>What are best practices on the (Windows) PC-side for testing/development of USB device firmware, during the stage when device descriptors and metadata are in flux? Is it possible to avoid chewing up PIDs just to avoid the Windows caching?</li>
  </ol>
  <h1>Details</h1>
  <p>Because of the way Windows caches USB descriptors and the like from previous enumerations, during firmware development, I was incrementing the device Product ID (PID) in the firmware after each time I made other changes, to ensure that Windows wasn't caching things from previous iterations of the descriptors, and messing up stuff that would otherwise work.</p>
  <p>Now I've gotten the device to enumerate successfully on Windows 7, 8, and 10 PCs as a WinUSB device, and I've established communication. But when I change the firmware back to using the VID/PID that I started with, and then connect the device to <em>my development PC</em>, it shows up in Device Manager under &quot;Other devices&quot; with an error icon. I <em>think</em> this is because my (Windows 10) development PC previously had seen this VID/PID combo as having different descriptors, so it's getting confused by some bad cached stuff.</p>
  <p>I've tried using <code>regedit</code> to delete the device's registry keys under <code>HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_xxxx&amp;PID_yyyy</code>, but the problem persists. (Also, I get an error, because it can't delete the <code>VID_xxxx&amp;PID_yyyy\zzzzzzzzzzzzz\Properties</code> subfolders.) I also tried using <a href="http://www.nirsoft.net/utils/usb_devices_view.html" rel="noreferrer">USBDeview</a> to uninstall old iterations of the device, but that hasn't made a difference either.</p>
  <p>Also of note is that I can no longer pass the device through to Virtual Box virtual machines. I'm not sure what happened there.</p>
  <p><a href="https://i.stack.imgur.com/K5cYc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/K5cYc.png" alt="Error enumerating shown in Device Manager" /></a></p>
  <p><a href="https://i.stack.imgur.com/7FVao.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7FVao.png" alt="Device Manager Code 28 - no compatible drivers" /></a></p>
  <p><a href="https://i.stack.imgur.com/9FDuY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9FDuY.png" alt="Device Driver properties" /></a></p>