visual studio-wdk8.1+vs2013中使用winusb模版开发usb设备驱动

问题描述

wdk8.1+vs2013中使用winusb模版 开发usb设备驱动

新人一只,本身是做硬件的,现在要编写硬件(USB设备)的驱动,然后想使用winusb进行快速的驱动开发。在使用winusb之前,使用了libusb-win32下的inf工具进行inf文件的生成和安装,通过bus hound可以看到枚举,并进行的bulk in/out测试(自带的send command)。目标pc是64位的win7旗舰版。
现在状况是vs2013新建了winusb模版工程,其中drivers package中的inf文件,对其修改了VID,PID,然后进行编译生成。这时候插入usb设备(已经卸载并删除了libusb生成的驱动),更新驱动程序->选择本地的驱动文件,指向了工程的生成。但是结果是安装不成功,提示是在inf中找不到所需的段落,如图。
visual studio-wdk8.1+vs2013中使用winusb模版开发usb设备驱动-visual 2013 wdk

inf文件内容如下

 ;
; ksp_daq_v11_drivers.inf
;
; Installs WinUsb
;

[Version]
Signature = "$Windows NT$"
Class     = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %ManufacturerName%
CatalogFile=ksp_daq_v11_drivers.cat

; ========== Manufacturer/Models sections ===========

[Manufacturer]
%ManufacturerName% = Standard,NT$ARCH$

[Standard.NT$ARCH$]
%DeviceName% =USB_Install, USBVID_0308&PID_0110

; ========== Class definition ===========

[ClassInstall32]
AddReg = ClassInstall_AddReg

[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%system32setupapi.dll,-20"
HKR,,LowerLogoVersion,,5.2

; =================== Installation ===================

[USB_Install]
Include=winusb.inf
Needs=WINUSB.NT

[USB_Install.Services]
Include=winusb.inf
AddService=WinUsb,0x00000002,WinUsb_ServiceInstall

[WinUsb_ServiceInstall]
DisplayName     = %WinUsb_SvcDesc%
ServiceType     = 1
StartType       = 3
ErrorControl    = 1
ServiceBinary   = %12%WinUSB.sys

[USB_Install.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
; By default, USBDevice class uses iProduct descriptor to name the device in
; Device Manager on Windows 8 and higher.
; Uncomment for this device to use %DeviceName% on Windows 8 and higher:
;HKR,,FriendlyName,,%DeviceName%
HKR,,DeviceInterfaceGUIDs,0x10000,"{fc47c010-ea60-4bed-9e8f-820bee86e7eb}"

[USB_Install.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll,WdfCoInstaller"

[CoInstallers_CopyFiles]
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

; ================= Source Media Section =====================

[SourceDisksNames]
1 = %DiskName%

[SourceDisksFiles]
WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1

; =================== Strings ===================

[Strings]
ManufacturerName="ksp"
ClassName="Universal Serial Bus devices"
DiskName="ksp_daq_v11_drivers Installation Disk"
WinUsb_SvcDesc="WinUSB Driver"
DeviceName="ksp_daq_v11_drivers Device"
REG_MULTI_SZ = 0x00010000


解决方案配置如下
visual studio-wdk8.1+vs2013中使用winusb模版开发usb设备驱动-visual studio

我查找了windows的log文件setupact.log(位于C:Windows下)

 WdfCoInstaller: [03/15/2016 20:12.05.288] DIF_INSTALLDEVICE: Pre-Processing

WdfCoInstaller: [03/15/2016 20:12.05.706] error locating section [USB_Install.Wdf] in inf C:WindowsINFoem107.inf - status(E0000101) <no error text>

WdfCoInstaller: [03/15/2016 20:12.05.849] DIF_INSTALLDEVICE: Pre-Processing

WdfCoInstaller: [03/15/2016 20:12.05.937] GetDriverDetailsData: SetupDiGetSelectedDriver: status(E0000203) <no error text>

WdfCoInstaller: [03/15/2016 20:12.05.993] DIF_INSTALLDEVICE: No action taken for NULL driver

在出现了这个问题之后,我对比了ST-Link v2(ST公司的硬件仿真器)的inf文件(因为stlink貌似也是基于winusb开发的驱动),模版自动生成的inf文件之间的区别在于。模版的inf文件某几节中少了WinUSBCoInstaller2.dll这个文件,我向模版inf文件中添加了这些部分,但是编译不通过。报错信息如下

 22.9.1: winusbcoinstaller2.dll in [coinstallers_copyfiles] of ksp_daq_v11_drivers.inf is missing or cannot be decompressed from source media.  Please verify all path values specified in SourceDisksNames, SouceDisksFiles, and CopyFiles sections resolve to the actual location of the file, and are expressed in terms relative to the location of the inf.

状况描述如上,求各位给点idea

解决方案

问题已经解决。使用了zadig提供的工具生成了inf文件,再对其修改后,使用wdk的inf2cat工具生成数字目录。安装成功。
具体inf内容为:

 ; Ksp_DAQ_v1.1.inf
; Copyright (c) 2010-2016 Pete Batard <pete@akeo.ie> (GNU LGPL)
[Strings]
DeviceName = "Ksp DAQ v1.1"
VendorName = "Ksp"
SourceName = "Ksp DAQ v1.1 Install Disk"
DeviceID   = "VID_0308&PID_0110"
DeviceGUID = "{4AAD13DD-7D64-41AD-A015-01D19A4B7D3F}"

[Version]
Signature   = "$Windows NT$"
Class       = "USBDevice"
ClassGuid   = {88bae032-5a81-49f0-bc3d-a4ff138216d6}
Provider    = %VendorName%
CatalogFile = Ksp_DAQ_v1.1.cat
DriverVer   = 03/31/2015, 6.1.7600.16385

[ClassInstall32]
Addreg = WinUSBDeviceClassReg

[WinUSBDeviceClassReg]
HKR,,,0,"Universal Serial Bus devices"
HKR,,Icon,,-20

[Manufacturer]
%VendorName% = libusbDevice_WinUSB,NTx86,NTamd64,NTarm

[libusbDevice_WinUSB.NTx86]
%DeviceName% = USB_Install, USB%DeviceID%

[libusbDevice_WinUSB.NTamd64]
%DeviceName% = USB_Install, USB%DeviceID%

[libusbDevice_WinUSB.NTarm]
%DeviceName% = USB_Install, USB%DeviceID%

[USB_Install]
Include = winusb.inf
Needs   = WINUSB.NT

[USB_Install.Services]
Include    = winusb.inf
AddService = WinUSB,0x00000002,WinUSB_ServiceInstall

[WinUSB_ServiceInstall]
DisplayName   = "WinUSB - Kernel Driver 03/31/2015 6.1.7600.16385"
ServiceType   = 1
StartType     = 3
ErrorControl  = 1
ServiceBinary = %12%WinUSB.sys

[USB_Install.Wdf]
KmdfService = WINUSB, WinUsb_Install

[WinUSB_Install]
KmdfLibraryVersion = 1.11

[USB_Install.HW]
AddReg = AddDeviceInterfaceGUID

[NoDeviceInterfaceGUID]
; Avoids adding a DeviceInterfaceGUID for generic driver

[AddDeviceInterfaceGUID]
HKR,,DeviceInterfaceGUIDs,0x10000,%DeviceGUID%

[USB_Install.CoInstallers]
AddReg    = CoInstallers_AddReg
CopyFiles = CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WdfCoInstaller01011.dll,WdfCoInstaller","WinUSBCoInstaller2.dll"

[CoInstallers_CopyFiles]
WinUSBCoInstaller2.dll
WdfCoInstaller01011.dll

[DestinationDirs]
CoInstallers_CopyFiles = 11

[SourceDisksNames]
1 = %SourceName%

[SourceDisksFiles.x86]
WinUSBCoInstaller2.dll = 1,x86
WdfCoInstaller01011.dll = 1,x86

[SourceDisksFiles.amd64]
WinUSBCoInstaller2.dll = 1,amd64
WdfCoInstaller01011.dll = 1,amd64

[SourceDisksFiles.arm]
WinUSBCoInstaller2.dll = 1,arm
WdfCoInstaller01011.dll = 1,arm
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值