Windows OS-Sample example of Windows Firmware Update Driver - windows

I have an Windows app exe file which updates the firmware of my usb device. For example: ./fwupdater.exe <fw.bin>
Since the above command requires manual upgrade by end user. I am planning to deliver firmware update by using windows firmware update driver.
https://learn.microsoft.com/en-us/windows-hardware/drivers/install/updating-device-firmware-using-windows-update
I could not find a reference example for same publicly.
How can I achieve this updating the firmware using windows driver.

It depends on how your USB device is designed.
I would do it like that:
on D0Entry invoke WorkItem.
WorkItem will check version of the device and version of the file
if there is mismatch and can update (depend on your configuration)
Update the Device via USB Hardware function (depends on your endpoints and etc...)

Related

Without installing FTDI driver, can an application dependent on it be deployed?

I am developing a Win10 C# application dependent on a third party library, which enables me to control a USB3 device.
By trial and error, I found that I needed to run FTD3XXDriver_WHQLCertified_v1.3.0.4_Installer.exe, which in the end populated the SysWOW64 with FTD3XX.dll and System32\Drivers with FTDIBUS3.sys and the ancillary files and folder.
I would like to run my application from a USB thumb drive on different PC's in my organization without installing any of the drivers. Is there a way to do that?
Bad news: To the best of my knowledge you cannot address an FTDI device if the driver is not installed.
But windows normally install the driver automatically via the windows updater. At least, this is the case for the USB 2 devices of FTDI i.e. 232 family. I do not have a FT60X here to test if the windows updater has a driver ready for this as well.
If the driver is installed via the updater you have to bundle the FTD3XX.DLL with your application as it is not part of the "windows standard" driver. At least this was the case for the FTD2XX.DLL.
Long story short: connect your device to a computer without preinstalled driver. Check if the driver is installed via the windows updater. If this is the case, you mostlikely just need to bundle the FTD3XX.DLL with you application.

How can I create a Bulk USB Gadget WinUSB Device

I created an small embedded WinUSB device which offers 2 bulk endpoints. This device can communicate with Linux and with Windows10 without installing driver, or a .inf file.
Now we want to use the same API with a embedded Linux. The USB-Gadget mode offers Serial CDC/ACM and RNDIS-Ethernet and many more.
I was able to create a USB-Gadget with the gadgetfs which had only bulk ep. I could communicate with Linux and Windows host. The USB-Device had /dev/ttyGS0 to communicate. But in Windows I had to install WinUSB driver manually.
I work with yocto to create embedded kernel.
I added some line of code here: /linux-imx/drivers/usb/gadget/legacy/serial.c , f_serial.c, u_serial.h to add additional variable os_desc and parameter use_winusb. But the resulting g_serial still creates a COM-Port in Windows10 or a no WinUSB device. For our device we need WinUSB-Device only.
The RNDIS Gadget does has WinUSB support. So I tried to create a own USB-Gadget device with https://github.com/libusbgx/libusbgx. But if I use the USBG_F_SERIAL function type then it can't create WinUSB. See error:
Error setting function OS desc
Error: USBG_ERROR_NOT_FOUND : Not found (file or directory removed)
If I use USBG_F_RNDIS, it works, and with manipulated USB descriptor it'll recognized by Windows as WinUSB device. But Linux implement's it as USB-ETH ethernet device. The USB-Device get's no /dev/ttyGS0 serial connection to communicate.
I'm reading the Linux kernel driver source now, to find the position, where I can simply ann this WinUSB os-descriptor stuff into the USBG_F_SERIAL type. But I think it'll take month to get through.
Any solution would be ok. Patch for the Linux driver sources g_serial or how to configure a USB-Gadgetfs would be great. Any hint, where to put additional code would also be fine.
I wanted to change the kernel, but fortunately found this:
https://blog.soutade.fr/post/2016/07/create-your-own-usb-gadget-with-gadgetfs.html
This code made it easy to add WinUSB features.
Source of modified Version for WinUSB: https://github.com/rundekugel/gadgetfsd/tree/WinUSB

Change installed device driver

I am trying to change the installed driver for a device using SetupAPI. The driver is already present on the PC, just not currently selected.
More specifically, I am trying undo the installation of a third-party driver for a USB composite device, and install the default windows driver instead.
I already got it almost working like this: First, find the device using
SetupDiGetClassDevs
SetupDiEnumDeviceInfo
SetupDiGetDeviceInstanceId
to find the device.
Next, find the default USB composite device driver I want to install using
SetupDiBuildDriverInfoList
SetupDiEnumDriverInfo
SetupDiGetDriverInfoDetail
Once I found the driver, I call
SetupDiSetSelectedDriver
SetupDiInstallDevice
This actually does switch the driver back, as can be observed in device manager.
However, the third party driver put the device into its own group/category, and this change is not undone when using my approach.
Manually selecting the standard USB composite device driver in the device manager does restore the device category back to USB Controllers, which is why I think my driver installation process is incomplete. What might I be missing?
Turns out the working installation sequence is
SetupDiSetSelectedDevice
SetupDiSetSelectedDriver
InstallSelectedDriver // From newdev.dll, not in a public header

Remove incorrect binding of composite device to custom driver

Our latest WHQL'ed custom driver has an incorrect entry for one of our upcoming product. The upcoming product is composite device and our WHQL'ed driver has an entry which matches the device ID for the composite device instead of the individual interfaces.
When the new device is connected to machines which have the WHQL'ed driver, the device gets binded to our driver and not to Windows Generic Parent Driver (usbccgp.sys). This prevents the interfaces in the device from being listed.
We could manually fix this by uninstalling the driver for the device and making it to bind to usbccgp.sys driver. In Vista and higher versions, we could delete the driver binaries at the time of uninstall. But there is no direct way to completely delete the driver binaries in XP. This makes it very difficult to cleanly uninstall the driver
Can this be fixed using an uninstaller? What is the best way to fix the affected machine in an automated way?
Download the Windows Driver Development Kit (Win DDK) and locate the devcon.exe executable for your architecture. Then, from an elevated command prompt:
devcon.exe find =usb
To list all of your current devices.
devcon.exe -r remove =usb *YOUR_HARDWARE_ID*
Will complete disassociate the device and driver from the target machine. If you have trouble getting the hardware id you can blow away all your USB drivers and let Windows auto-detect them after reboot.
devcon.exe -r remove =usb *
Extreme, yes. Effective, yes. We work with virtual comm ports all day and our test machines often experience your same issue. This technique has yet to fail.

Faking the presence of a USB device in order to test driver installation on Windows

I've been asked to help with some problems that a company are having with an Windows installer they have that includes some custom driver installation for some hardware they make.
I've got access to the source code to build the software and installer (which is an WIX/MSI one), but don't have access to the hardware, so can't actually test it properly.
Is it possible (either with a toolkit, or without) to trick windows into thinking that a specific device USB device has been attached to the computer in order to trigger Windows into trying to install the drivers? . I've got access to all the Vendoer Id, DeviceID, etc information.
Thanks
Tom
That should be possible. Take a look at WDK USBSamp and NDIS Virtual miniport (or virtual serial driver) samples. The first one is a USB driver sample and second one demonstrates how to build virtual driver. You should be able to combine the two to create a virtual USB driver.

Resources