I am using a fully-embedded USB-based system in a product development.
The product line includes both Windows-XP and Windows-7 hosts and the
embedded USB device is completely inside and not physically accessible.
Most of time the USB device acts as an HD camera using the UVC
protocol. But if the camera firmware needs to be updated then there is
a method by which the camera can be commanded to go into firmware update
mode. When this command is received, the USB (camera) device shuts down
and disconnects and then reconfigures itself as a thumb drive … i.e.
it appears on he same USB port as a USB file storage gadget. When
Windows sees this “new” device it properly assigns a drive letter and
opens Windows Explorer to allow file transfers. All of this works like
a charm.
A problem arises, however, when a Windows-7 based system attempts to
“safely remove” the file storage device. This action (under Win-XP)
causes a USB suspend condition and that condition triggers the USB
device to finalize its firmware update and reboot itself, coming back
again as a UVC camera. Everything works well under Windows-XP. But,
with Windows-7, the “safely remove” action seems to do nothing as far as
the embedded file storage gadget device is concerned. The device
apparently doesn’t see a USB suspend so it just sits there forever
waiting for one. Since the device is completely embedded, it isn’t
possible to unplug its USB connection. That action, if we could do it,
would generate a USB disconnect event and that would work OK as well
… but, alas, we cannot do it.
My question is “How can I programmatically cause a Windows-7 machine to
generate a USB suspend (or a USB disconnect) condition on a USB file
storage gadget?” I’ve tried a few of the public domain programs that
claim to do this (e.g. EjectUSB) and I’ve also tried “devcon” from the
WinDDK package. With devcon it is possible to shutdown the entire host
controller and then do a rescan to put it back together. That scenario
does accomplish what I need but it is very invasive to the overall
system and thus isn’t a good solution.
Any advice, help, or pointers on how to write a program (hopefully at
user level) to generate a USB-suspend or USB-disconnect condition would
be greatly appreciated.
Steve B