Create umdf firmware update

hello everyone, I read your comments about umdf, you are very expert in the field, for that I decided to register in this site to learn from you, I am a beginner in WDF, I would like create a driver that sends specific commands to the device, for example a command that retrieves the firmware version, if someone could help me with a project as template, I would be very grateful. thank you in advance

What device? What bus? Does it already have a driver? Are you sure it has a command to fetch the firmware version?

to be sincere, for the device I don’t know what it is, but I know that it is based on USB HID, I have the commands to enter, for example to retrieve the version of the device, but for create method that use this command in UMDF i don’t know manipulated the wdf , i read in forums i had to use filewrite and fileread . Also I found this page https://learn.microsoft.com/en-us/windows-hardware/drivers/install/updating-device-firmware-using-windows-update , it contains what I want to do, but there is no code. My main problem is that the documentation is almost nowhere to be found, for what I hope found solution here. Thnks for your concern ?.

You don’t know what it is??? I don’t understand what environment you would be in where you need to access a devices firmware version and not know what it is. Are you hacking something here?

The page you linked just shows how you get hooked in to the standard Windows Update mechanism. There’s no general advice on how to update firmware because every device is different.

If you don’t know what the device is, then you are clearly not the manufacturer of the device. It already has a driver, so you can’t just insert your own. You said you already have “commands” to fetch the version. What do they look like? If they are HID commands, then you can open the device using the HID libraries and talk to it normally, with no driver involved.

Hello Tim, I’ve already the source of an application that open the device and get version from it then put the firmware in device,But now i need to do this from a driver. My command to get version look like 0x000000A6 , from the source i send it via the function Write file of fileapi.h My question is : is there any way to do the same thing in UMDF?, Is there a function in UMDF that do the same thing as write file and how to use it? as i said i am new in this domain, and i searched in web without result.

Never do anything in a driver that can be done just as well in an application. It just adds unnecessary complexity and endangers system stability. Why do you want this in UMDF? Where are you going to load the driver?

How did you open the file? Are you opening it as a HID device? You’re really making it very hard to help you, because we have to pull each piece of information one bit at a time.

1 Like

okay,i will try to be more clear, the device is attached as an hid compliant device, and i need to verify and update the firmware if necessary each time it will be connected. as you said it will be more complicated when putting the update process into driver. so I’ve 2 solution,i hope you can validate them to me if you don’t mind. 1- creating a simple hid driver that will detect the device and notify service,then from this service i will update the device. 2- Microsoft propose another method ,its about creating a CFU driver ,but its difficult to learn it ( https://github.com/microsoft/CFU/blob/master/Documentation/CFU-Driver/cfu-driver.md). for the first solution, can i create and install this service during installing the driver, and is there anything to do to communicate between them?.

You do not need a driver AT ALL. The device already HAS a driver. You can’t supply your own without replacing that one, which would of course make it non-functional, especially if you don’t know what it does. Yes, the smarter way is to install a service, and use RegisterDeviceNotification or CM_Register_Notification to get a callback when your device arrives or departs. Handle it all from user-mode.

How are you going to install firmware for a device when you don’t know what it does? This whole thing is very fishy.

hi tim, the first time i posted in this group i was a beginner. i asked how to create a driver that updates the firmware of a device. now I’m a bit of an amateur. i managed to create a hid driver that updates the firmware. but still i need your help. I’ll explain in detail. the device I use is the nuveton nu-link “https://www.nuvoton.com/tool-and-software/debugger-and-programmer/1-to-1-debugger-and-program mer/nu-link-pro/” . this device has two modes, regular mode and boot loader mode, the second mode is the one that allows us to update the firmware, each mode has its own VID:PID. so what I did was to create two hid drivers for each mode, the first driver checks the firmware version and the current version to decide to switch to boot loader mode, or the second hid driver runs to update the device and then switch to regular mode. I made both drivers, and both drivers work fine separately, that means when I install only one of them, and I check all is fine. but when i combine them, means the first one starts the second one (checking version then execute HID command to switch to boot loader mode), when the second one starts it can’t communicate with the device. i mean the hid command doesn’t pass to the device. do you have any idea about this behavior. for building my drivers i used DMF library, i used ComponentFirmwareUpdateHidTransport for HID protocol and ComponentFirmwareUpdate for updating firmware.

So, your first driver matches the normal VID/PID. It decides that an upgrade is needed. It issues the “enter boot mode” command. Then what? Does it force a reset, so the device enumerates with the new VID/PID? Remember that the first device cannot be released until your first driver unloads. Do you see that driver getting Remove requests and being unloaded?

When it issues the “enter boot mode” command ,it do reset and then a new vid:pid will be shown,so the first driver disappear and the new driver appear,this new driver inside it, it cannot execute commands . In case of uninstall the second driver and let just the first,all will be okay. I mean when there is just the first driver which issue the enter boot mode command, the hid compliant default driver get the second mode ,here I can connect and execute commands ,in that state if I install the second driver , it can too execute commands normally, weird. so my problem is when switching between the two drivers.