Is there any difference between PCI - PNP device driver installat ion and USB device driver installa

I have observed two things that I don’t fully understand. I hope somebody
can give me a hint.

I am writing a kernel driver of Cypress FX2 based device. I would like to
use one driver to handle both default VID/PID and the real VID/PID after
ReNumeration. So in my myusbdevice.inf file, I have something like this:

[USB.Mfg]
%UsbDesc% = DDInstall_USB, USB\VID_0699&PID_0361
%UsbDescDefault% = DDInstall_USB_DEFAULT, USB\VID_04B4&PID_8613

[DDInstall_USB.NTx86]
AddReg = AddRegistry_NT_Scope

[AddRegistry_NT_Scope]
HKLM,System\CurrentControlSet\Services\MyUsbDevice,PreEnum,0x00010001,0

[DDInstall_USB_DEFAULT.NTx86]
AddReg = AddRegistry_NT_Scope_Default

[AddRegistry_NT_Scope_Default]
HKLM,System\CurrentControlSet\Services\MyUsbDevice,PreEnum,0x00010001,1

So when power up, I will see the default VID/PID and the driver will run and
load the firmware based on PreEnum registry setting. After ReNumeration, the
USB device should report the real VID/PID and PreEnum registry value should
be updated by driver installation process. However, this does not work
sometimes, especially when I unplug and plug the USB device in the same USB
port. The PreEnum key is not updated after ReNumeration. Does anybody know
why?

The second question is that I am trying to use
UpdateDriverForPlugAndPlayDevices() to update the Usb device driver,
however, it never copies the driver and other firmware files to the
designated path. This works fine for PCI devices. Anybody knows anything
about it?

Thanks,

Zhongsheng Wang
PSPL Software Design Engineer
Phone: (503)627-5260
Fax: (503)627-5622
Email: xxxxx@tek.com

xxxxx@exgate.tek.com wrote:

I have observed two things that I don’t fully understand. I hope somebody
can give me a hint.

I am writing a kernel driver of Cypress FX2 based device. I would like to
use one driver to handle both default VID/PID and the real VID/PID after
ReNumeration.

Right, this is how most FX2 drivers work. Indeed, that’s how the
Cypress sample works.

So in my myusbdevice.inf file, I have something like this:

[USB.Mfg]
%UsbDesc% = DDInstall_USB, USB\VID_0699&PID_0361
%UsbDescDefault% = DDInstall_USB_DEFAULT, USB\VID_04B4&PID_8613

RED FLAG #1: You must change the VID/PID in the EEPROM away from
04B4/8613. Otherwise, your driver will glom on to EVERY unconfigured
FX2 device that gets plugged in. You need TWO custom PIDs for your device.

[DDInstall_USB.NTx86]
AddReg = AddRegistry_NT_Scope

[AddRegistry_NT_Scope]
HKLM,System\CurrentControlSet\Services\MyUsbDevice,PreEnum,0x00010001,0

[DDInstall_USB_DEFAULT.NTx86]
AddReg = AddRegistry_NT_Scope_Default

[AddRegistry_NT_Scope_Default]
HKLM,System\CurrentControlSet\Services\MyUsbDevice,PreEnum,0x00010001,1

So when power up, I will see the default VID/PID and the driver will run and
load the firmware based on PreEnum registry setting. After ReNumeration, the
USB device should report the real VID/PID and PreEnum registry value should
be updated by driver installation process. However, this does not work
sometimes, especially when I unplug and plug the USB device in the same USB
port. The PreEnum key is not updated after ReNumeration. Does anybody know
why?

Sure. The AddRegistry section is executed when the driver is installed,
NOT when the device is plugged in. If a driver is already known for a
VID/PID in a given slot, the driver is loaded without any other INF
action occurring. When you plug the device into a new slot, it is
considered a new installation, so the AddRegistry sections will be executed.

Are you handling both states with the same driver? If so, then you need
to read the device descriptors to figure out whether you are talking to
the unconfigured device or the configured device. You can’t rely on the
INF file.

If you ARE handling them both with the same driver, then you don’t need
two separate install sections. Have both USB.Mfg lines point to the
same section.

The second question is that I am trying to use
UpdateDriverForPlugAndPlayDevices() to update the Usb device driver,
however, it never copies the driver and other firmware files to the
designated path. This works fine for PCI devices. Anybody knows anything
about it?

Are you calling this while the device is plugged or unplugged?

Is this for debugging? If the device is unplugged, you can copy the
driver straight in. If the device is plugged in, you can use devcon.exe
to reload the driver.