0

UPDATE: Thanks to the answer below I managed to get this to work on Windows 7. I have since realized that Windows 10 installs but overrides my driver with the OEM USB Serial driver. Please see: Trouble installing custom inf in Windows 10 Professional. Windows overrides it with OEM driver

-

I attempted to make an Inf file that installs a usb-serial device using the standard windows usb-serial driver. This file successfully installs the driver on Windows 8.1 and Windows 10 but fails in Windows 7 32bit and Windows 7 64 bit. I attempted to right-click install the driver from the desktop (default install). The first time I attempted this I was presented with the error "The inf file you suggested does not support this method of installation". I added the defaultInstall sections to the inf file. After I did this the error disappeared but the system could not find usbser.sys. "The file 'usbser.sys' on windows cd is needed."

What do I need to add to the inf file below in order to make this successfully install from Windows 7?

Current inf file:

;************************************************************
; Windows USB CDC ACM Setup File
; Copyright (c) 2000 Microsoft Corporation

; Version v1.1, updated 17 April 2013

[Version]
Signature="$Windows NT$"
Class=Ports
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
Provider=%MFGNAME%
LayoutFile=layout.inf
CatalogFile=%MFGFILENAME%.cat
DriverVer=11/15/2007,5.1.2600.0

[Manufacturer]
%MFGNAME%=DeviceList, NTamd64

[DestinationDirs]
DefaultDestDir=12

;------------------------------------------------------------------------------
;  Windows 2000/XP/Vista-32bit Sections
;------------------------------------------------------------------------------

;DEFAULT SECTION ADDED
;---------------------------------------------
[DefaultInstall.nt]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.nt
AddReg=DriverInstall.nt.AddReg

[DefaultInstall.nt.Services]
AddService=usbser, 0x00000002, DriverService.nt
;---------------------------------------------

[DriverInstall.nt]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.nt
AddReg=DriverInstall.nt.AddReg

[DriverCopyFiles.nt]
usbser.sys,,,0x20

[DriverInstall.nt.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"

[DriverInstall.nt.Services]
AddService=usbser, 0x00000002, DriverService.nt

[DriverService.nt]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\%DRIVERFILENAME%.sys

;------------------------------------------------------------------------------
;  Vista-64bit Sections
;------------------------------------------------------------------------------

;DEFAULT SECTION ADDED
;---------------------------------
[DefaultInstall.NTamd64]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.NTamd64
AddReg=DriverInstall.NTamd64.AddReg

[DefaultInstall.NTamd64.Services]
AddService=usbser, 0x00000002, DriverService.NTamd64
;----------------------------------

[DriverInstall.NTamd64]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.NTamd64
AddReg=DriverInstall.NTamd64.AddReg

[DriverCopyFiles.NTamd64]
%DRIVERFILENAME%.sys,,,0x20

[DriverInstall.NTamd64.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"

[DriverInstall.NTamd64.Services]
AddService=usbser, 0x00000002, DriverService.NTamd64

[DriverService.NTamd64]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\%DRIVERFILENAME%.sys


;------------------------------------------------------------------------------
;  Vendor and Product ID Definitions
;------------------------------------------------------------------------------
; When developing your USB device, the VID and PID used in the PC side
; application program and the firmware on the microcontroller must match.
; Modify the below line to use your VID and PID.  Use the format as shown below.
; Note: One INF file can be used for multiple devices with different VID and PIDs.
; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
;------------------------------------------------------------------------------
[SourceDisksFiles]
[SourceDisksNames]
[DeviceList]
%linux.gserial%=DriverInstall, USB\VID_1FC9&PID_816A, USB\VID_1FC9&PID_816A&MI_00

[DeviceList.NTamd64]
%linux.gserial%=DriverInstall, USB\VID_1FC9&PID_816A, USB\VID_1FC9&PID_816A&MI_00

;------------------------------------------------------------------------------
;  String Definitions
;------------------------------------------------------------------------------
;Modify these strings to customize your device
;------------------------------------------------------------------------------
[Strings]
MFGFILENAME="c500"
DRIVERFILENAME ="usbser"
MFGNAME="Rinstrum Pty Ltd"
INSTDISK="Rinstrum USB Gadget Serial Driver Installer"
linux.gserial="Rinstrum USB Gadget Serial"
SERVICE="USB RS-232 Emulation Driver"

If I then use the command RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 c500.inf on the command line I'm prompted with the error "Installation failed".

Community
  • 1
  • 1
Luke Allison
  • 3,118
  • 3
  • 24
  • 40

2 Answers2

0

I've made plenty of usbser.sys-based drivers that work on Windows 7. Here is an example: https://github.com/pololu/p-star-examples/blob/master/drivers/p-star-serial.inf

I think you don't need to have your "DriverCopyFiles.nt" section and the references to it. Look at the driver I linked to above which shows how to refer to a "FakeModemCopyFileSection" instead.

Also, one thing that looks fishy about yours is that you chose to make "usbser" by a string in the "Strings" section. I really don't see the point of that and the whitespace near for the definition of that string is messed up. You can just write "usbser" in the places where it is used.

David Grayson
  • 84,103
  • 24
  • 152
  • 189
  • Thank you for your answer. I noticed you had called your inf file directly in the CopyFiles section. Isn't this bad practice? "Note The CopyFiles directive should not refer to the catalog file or the INF file itself; SetupAPI copies these files automatically." - https://msdn.microsoft.com/en-us/windows/hardware/drivers/ifs/creating-an-inf-file-for-a-file-system-filter-driver – Luke Allison Feb 01 '17 at 01:59
  • Look again, I don't have a `CopyFiles` directive that refers to my own INF file. – David Grayson Feb 01 '17 at 02:04
  • Sorry about that. I seem to be having some success with Win7 32 after following your template. Now to try the other OS. – Luke Allison Feb 01 '17 at 05:40
  • This doesn't work in Windows 10 though. Even if I run the inf file before plugging in the USB device it will just use the generic usb serial driver and show as "USB serial device" instead of the proper driver name I'm using in the inf file. Any idea what is missing for windows 10? – Luke Allison Feb 01 '17 at 06:53
  • You plugged your device into Windows 10 before the proper driver was installed, so it went with the generic driver that comes with Windows 10 (usbser.inf). Your device is perfectly usable, but if you want to see the right name in the Device Manager, right click on it and select Uninstall, then unplug and replug. – David Grayson Feb 01 '17 at 15:13
  • This isn't the case. I ran the installer then plugged the device in and regardless it has just installed the Microsoft version. The Manufacturer is listed as "Microsoft". I'm going to sign it and try again but with the other OS I avoided this by enabling "test mode", which doesn't check for certificates – Luke Allison Feb 01 '17 at 21:41
  • Just to clarify, I'm using VMs with snapshots of clean installs of the operating systems. I restore them every time I test. – Luke Allison Feb 01 '17 at 22:36
  • Yes, it definitely does. – David Grayson Feb 02 '17 at 14:47
  • http://stackoverflow.com/questions/42014826/trouble-installing-custom-inf-in-windows-10-professional-windows-overrides-it-w . No such luck for me – Luke Allison Feb 03 '17 at 00:36
0

This in addition to David Grayson's answer. I used his example at https://github.com/pololu/p-star-examples/blob/master/drivers/p-star-serial.inf as basis for my inf files.

Make sure that whatever identification information you specify in the .inf file matches exactly what is shown as the Hardware Ids in Device Manager. For instance, I had some &MI_00 or &MI_01 stuff in the Hardware Ids once and that made Windows to not match the device.

Hardware Ids in Device Manager

Hmm, it seems that the &REV_0000 was not required.

PkP
  • 418
  • 3
  • 10