我会写BUG 2016-03-15 14:18 采纳率: 0%
浏览 4833
已结题

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中找不到所需的段落,如图。
图片说明

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, USB\VID_0308&PID_0110

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

[ClassInstall32]
AddReg = ClassInstall_AddReg

[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%\system32\setupapi.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


解决方案配置如下
图片说明

我查找了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:\Windows\INF\oem107.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

  • 写回答

2条回答 默认 最新

  • 我会写BUG 2016-03-17 15:30
    关注

    问题已经解决。使用了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
    
    
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!