Author Topic: Windows & USB, problems & two utilities  (Read 263 times)

Renate

  • Member
  • ***
  • Posts: 43
Windows & USB, problems & two utilities
« on: October 31, 2020, 01:56:47 pm »
Windows handling of USB is inconvenient at times, here are two problems.

Ever go to the device manager (devmgmt.msc) and see a long list of things like "Input Device" or "Composite USB Device".
That's not very helpful, is it?
You can name your devices yourself or use a utility.
USB devices (and USB device interfaces) can have a "FriendlyName". Usually it's not set.
You can set it yourself using regedit.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_0403&PID_6001\A015VB4E => FriendlyName
(The above example is an FTDI UART. A015VB4E is the serial string.)

As always, having USB devices with serial strings is important (even if you are making something custom and there will only be one in the universe).
If you plug something into Windows that has a serial string, then plug it into a different hub port then Windows will say, "Oh, I know this one".
If your device does not have a serial string and you plug it into a different hub port then Windows will say, "Wow, a brand new device!"
In this case it will assign a fake serial string (actually, they call it location) with something like "7&279c4dc7&1&7"
If you go to DeviceManager and View > Hidden Devices you will see lots of entries for anything that you ever plugged in.
Things with a serial string will only appear once. Things without a serial string will show up for each time you plugged it in a different port.

Now, if you care and get tired of all this clutter you can actually delete all the keys under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB
No, that's really not radical, Windows just figures it out all by itself the next time you boot.
One other reason to delete some of these keys if you are developing a USB device and you make a radical change in the number/type of interfaces
I've found that sometimes Windows gets confused unless you delete those keys.
You don't need to do this for minor changes like HID report descriptors.

So I have one little utility for listing, naming & deleting these entries, enumusb.exe
Code: [Select]
C:\>enumusb /l <-- list everything
0403:6001     A015VB4E            2020-09-22 11:21  FTDI #1
0403:6010     210918DE7013        2020-09-23 04:04  CMOD A7
0403:6010:00  8&22ffbf39&0&0000   2020-09-23 04:04  CMOD A7 JTAG
0403:6010:01  8&22ffbf39&0&0001   2020-09-23 04:04  CMOD A7 UART
0409:0050     6&2760bdae&0&3      2020-09-19 09:41  StarTech 7 port hub
...
C:\>enumusb /v0403 /p6001 /sA015VB4E /f"My little UART" <-- rename specific
C:\>enumusb /v8087 /f"AMD is better than Intel" <-- rename everything by 8087
C:\>enumusb /d /v8087 <-- delete everything by 8087
(I should document this but enumusb /? will get you started.)
If your devices have no serial string then friendly naming will name all the devices of that Vid/Pid.
If you plug the serial-less device into another hub port then you will have to do another naming operation.
You could put all your naming operations into a batch file to run again.

The other thing that drives me crazy is that you are sitting at your desk and Windows gives a flurry of USB "bongs".
What just happened? What disconnected? What connected?
You'd think that the Event Log would have it. Nope. (At least not by default.)
So if you have a wonky cable somewhere you'll have a hard time figuring out which one it is.
The other utility that I have is usblog.exe
It's simple, logs what is connecting and disconnecting (and using those FriendlyNames that you put in).

The two utilities can be downloaded at http://www.temblast.com/windows.htm

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 2952
    • Lakeview Research
Re: Windows & USB, problems & two utilities
« Reply #1 on: October 31, 2020, 05:46:18 pm »
Nice! Thank you for creating these and making them available!

bpaddock

  • Frequent Contributor
  • ****
  • Posts: 53
Re: Windows & USB, problems & two utilities
« Reply #2 on: November 04, 2020, 08:34:41 am »
Thank you, looks very useful.

Two other useful utilities are GhostBuster and USBdeView.

GhostBuster enumerates all devices, detects ghosted devices and removes these
if they match selectable devices types and/or devices classes with a single mouse-click.
I suggest the 'Portable' version under Installers:

https://bitbucket.org/wvd-vegt/ghostbuster/src/master/

USBdeView shows the USB database of devices that are attached or have been attached (it is selectable):

https://www.nirsoft.net/utils/usb_devices_view.html


bpaddock

  • Frequent Contributor
  • ****
  • Posts: 53
Re: Windows & USB, problems & two utilities
« Reply #3 on: November 04, 2020, 08:54:49 am »
enumusb requires admin privileges to set the friendly name.
No surprise.

What was a bit of a surprise was setting the friendly name,
changed the Device Name as shown in USBdeView.

The Device Name went from the correct "WF2" to
Port_#002.Hub_#007, when the Friendly name went from blank
to "WF2usbenum".

?

After removing the device and reconnecting (as shown by USB Event Logger, very useful)
the Device Name did return to the correct "WF2".  Probably just one of those Wonders of Windows.
I wonder why it did that?

USBdeView shows hubs in the Port_# style if that is a clue to anything.

« Last Edit: November 04, 2020, 08:58:30 am by bpaddock »

jb

  • Member
  • ***
  • Posts: 17
Re: Windows & USB, problems & two utilities
« Reply #4 on: November 04, 2020, 11:44:49 am »
If you list Device Manager "View Devices by Connection", it shows the actual names of things underneath the "USB Composite Device" entry.

USBDeview lets you uninstall a bunch of devices, too.

Renate

  • Member
  • ***
  • Posts: 43
Re: Windows & USB, problems & two utilities
« Reply #5 on: November 05, 2020, 10:38:33 am »
I made a few tweaks and a new version of usblog.exe is available at the same link. (enumusb.exe is still the same).

Yes, undoubtedly there are tons of similar utilities.
Among those is the venerable (20 years old) Microsoft usbview.exe

USBdeView shows hubs in the Port_# style if that is a clue to anything.
That's the value of "LocationInformation" adjacent to "FriendlyName" in the registry.
I'm not sure if Windows uses that for any particular reason or whether you could also just change that to whatever suits you.

If you list Device Manager "View Devices by Connection", it shows the actual names of things underneath the "USB Composite Device" entry.
Yes, it will list the different interfaces and even the different top-level collections underneath.
FriendlyName-ing only extends to devices and interfaces.
Still, I find that view a bit cumbersome.
In Device Manager you always have to hit Properties > Details > Device instance path to get the simplest information.

I'll add one caveat to usblog.exe
It only indicates arrival of a USB device when the driver is loaded.
If you have some device that has no driver it will not indicate in usblog.exe
I could make it so that usblog.exe does active scanning and detects those sort of things.
Right now, usblog.exe is passive and doesn't do anything in the idle state.

Active scanning would be useful if you plug in something that has a bootloader interface (but no drivers) that only appears for a second or two.
Of course, you could look through enumusb.exe /l for the new mystery.
Using Show hidden devices in DeviceManager you can install the driver so that's it's there the next time the device pops up.

jb

  • Member
  • ***
  • Posts: 17
Re: Windows & USB, problems & two utilities
« Reply #6 on: November 05, 2020, 11:12:39 am »
Quote
One other reason to delete some of these keys if you are developing a USB device and you make a radical change in the number/type of interfaces
I've found that sometimes Windows gets confused unless you delete those keys.

Also if you change audio Feature Units, Windows won't catch on until it's uninstalled and reinstalled.

Quote
Among those is the venerable (20 years old) Microsoft usbview.exe

https://www.uwe-sieber.de/usbtreeview_e.html is a better fork of it