Author Topic: Find HUB Port that a HID USB device is attached to - driverkeys do not match  (Read 18382 times)

E4dev

  • Member
  • ***
  • Posts: 6
Hello all:

I want to find the Hub/Port that a USB device is attached to.

The USB FAQ describes a way to match devices enumerated through the interface through the driverkey (with SetupDiGetClassDevs - flag DIGCF_DEVICEINTERFACE/SetupDiEnumDeviceInterfaces/SetupDiGetDeviceInterfaceDetail) and then SetupDiGetDeviceRegistryPropertyA with option SPDRP_DEVICEDESC) and match this to the driverkey from DeviceIOCtl (IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME) for each hub port.  Unfortunately the driverkeys do not match because the Hub returns the driverkey (for the same device) enumerated in the USB category (HKLM\System\CurentControlSet\Enum\USB\) while the DeviceInterface enumeration returns the driverkey that is enumerated under HID (HKLM\System\CurentControlSet\Enum\HID).

Purpose of this task: I need to find a USB device that first starts in a custom HID mode which allows me to read configuration data. I will then switch it over to DFU mode, find the same device and install new device firmware (Windows XP) Unfortunately in DFU mode, with the small bootload programm, there is no device serial number stored in the USB descriptor.

Any help - or a different approach to the problem - is appreciated.

Thanks,
H.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
How is the host switching it over to DFU mode? Is it sending a Dfu_detach request or are you using your own protocol?

Jan

E4dev

  • Member
  • ***
  • Posts: 6
We are using our own protocol. We issue a command which starts the boot loader code. This part works very well and the system reconnects in DFU mode.
Thanks for trying to help and for writing such an excellent book.
H.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
You send a command in a HID report that tells the device to simulate detach and reattach in DFU mode?

What does the device enumerate as on reattach? For example, if it's a vendor-defined device with a vendor-specific driver, the INF file can identify the device by VID and PID.

I'm glad to hear you like my books!

Jan


E4dev

  • Member
  • ***
  • Posts: 6
The problem occurs when you have two of the same devices attached at the same time. How do I find the one device that I was just communicating with in HID mode. With just one device attached it is simple and I can just look for the vendor/product Id. If I cannot find a solution we will just have to restrict SW. upgrade to one at a time.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
I see. I don't know of a way for a Windows application to match a port to a detected device. Maybe the HID command could send a unique identifier that the device could save just long enough to get the upgrade started?
 
How much faster you can do the upgrades with multiple devices will depend in part on if the system has multiple buses or low- or full-speed devices attached to different hubs or hubs with multiple transaction translators. Otherwise all of the devices share the same bus bandwidth.

Jan

E4dev

  • Member
  • ***
  • Posts: 6
Thanks Jan. I guess the solution will be to only allow one device attached for now and later fix the firmware to have a unique serial number in both DFU mode and HID mode.
H.