问题描述
我与恩智浦LPC1788微控制器的工作,我试图创建主机计算机上的驱动器通过USB与它通信。我相信,我已经成功地获取设备妥善处理标准USB请求(PC机能够正常读取的字符串描述符)。
我无法写一个样品的USB驱动程序并安装它的设备,虽然。我与Microsoft Visual Studio 2013年的工作我的步骤是:
-
创建了WinUSB应用,其产生的驱动程序和驱动程序包项目。
-
修改生成的INF文件,用我的设备的VID和PID。
-
建设项目 - 无论成功打造。输出文件夹中包含一个INF文件,目录文件和WdfCoinstaller01011.dll。
-
在堵漏通过USB微控制器,将设备管理器→更新驱动程序软件... ,浏览到包含INF文件,并选择它的文件夹
-
这会导致下面的屏幕出现:
- 我选择始终安装此驱动程序软件。片刻之后,presents此屏幕:
我下面的INF文件中给出:
;
; TestCubeDriver.inf
;
;安装了WinUSB
;[版]
签名=$的Windows NT $
CLASS = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
供应商=%ManufacturerName%
CatalogFile = TestCubeDriver.cat
DriverVer = 4月16日/ 2014,15.55.4.44; ==========制造商/型号部分===========[生产企业]
%ManufacturerName%=标准,NTamd64[Standard.NTamd64]
%设备名称%= USB_Install,USB \\ VID_0483&安培; PID_5720; ==========类定义===========[ClassInstall32]
的AddReg = ClassInstall_AddReg[ClassInstall_AddReg]
HKR ,,,,%类名%
HKR ,, NoInstallClass ,, 1
HKR ,, IconPath,REG_MULTI_SZ%%的%SystemRoot%\\ SYSTEM32 \\ setupapi.dll,-20
HKR ,, LowerLogoVersion ,, 5.2; ===================安装===================[USB_Install]
包括= winusb.inf
需求= WINUSB.NT[USB_Install.Services]
包括= winusb.inf
AddService =了WinUSB,0x00000002,WinUsb_ServiceInstall[WinUsb_ServiceInstall]
显示名称=%WinUsb_SvcDesc%
服务类型= 1
StartType = 3
错误控制= 1
ServiceBinary =%12%\\ WinUSB.sys[USB_Install.HW]
的AddReg = Dev_AddReg[Dev_AddReg]
;默认情况下,USBDevice类使用iProduct描述符来命名设备
;在Windows 8和更高的设备管理器。
;取消注释此设备在Windows 8和更高版本使用%设备名称%:
; HKR ,, ,,的FriendlyName%设备名称%
HKR ,, DeviceInterfaceGUIDs,为0x10000,{fcb251a5-6a1f-4e5b-9df8-e8de91d04cfe}[USB_Install.CoInstallers]
的AddReg = CoInstallers_AddReg
CopyFiles = CoInstallers_CopyFiles[CoInstallers_AddReg]
HKR ,, CoInstallers32,0x00010000,WdfCoInstaller01011.dll,WdfCoInstaller[CoInstallers_CopyFiles]
WdfCoInstaller01011.dll[DestinationDirs]
CoInstallers_CopyFiles = 11; =================源媒体节=====================[SourceDisksNames]
1 =%DiskName%[SourceDisksFiles]
WdfCoInstaller01011.dll = 1; ===================字符串===================[字符串]
ManufacturerName =
类名=通用串行总线设备
DiskName =TestCubeDriver安装盘
WinUsb_SvcDesc =了WinUSB驱动程序
设备名称=TestCubeDriver设备
REG_MULTI_SZ = 0x00010000在
我setupapi.dev.log文件的相关部分此处给出的用我自己的配置:
;此.inf文件的例子INF的修改版本提供
;微软文件中:
;如何使用了WinUSB与USB设备进行通信
[版]
签名=$的Windows NT $
CLASS = USBDevices
ClassGuid = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
供应商=%MFGNAME%
DriverVer = 4月17日/ 2014,1.0.0.0
CatalogFile = winusb.cat;需要签名的驱动程序pacakage CAT文件
; ------------------------------------------------- -----------------------------
; ==========制造商/型号部分===========
; ------------------------------------------------- -----------------------------
[生产企业]
%MFGNAME%= MyDevice_WinUSB,NTx86,NTamd64; ------------------------------------------------- -----------------------------
;供应商和产品ID定义
; ------------------------------------------------- -----------------------------
;当开发自定义的USB设备,VID和PID在PC端使用
;应用程序,并在微控制器固件必须匹配。
;修改下面的线条中使用的VID和PID。如下所示使用的格式。
;注意:一个INF文件可以被用于与不同的VID和PID的多个设备。
;为每个支持的设备,追加,USB \\ VID_xxxx&放大器; PID_yyyy到行的结尾。
;有可以每行然而被支持的设备的最大数量。
;如果你有大量的VID / PID的追加到行的末尾,并获得:
; 传递给系统调用的数据区域太小。试图安装时出错
; INF文件,请尝试删除一些的VID / PID的。
; ------------------------------------------------- -----------------------------
[MyDevice_WinUSB.NTx86]
%描述%= USB_Install,USB \\ VID_0483&安培; PID_5720[MyDevice_WinUSB.NTamd64]
%描述%= USB_Install,USB \\ VID_0483&安培; PID_5720
; ================================================= ========================================
; ClassInstall32和ClassInstall_AddReg部分用于制造新的设备管理器类别。
; ================================================= ========================================
[ClassInstall32]
的AddReg = ClassInstall_AddReg[ClassInstall_AddReg]
HKR ,,,,%DEVICEMANAGERCATEGORY%
HKR ,,图标,, - 20
; ===================安装===================[USB_Install]
包括= winusb.inf
需求= WINUSB.NT[USB_Install.Services]
包括= winusb.inf
AddService =了WinUSB,0x00000002,WinUSB_ServiceInstall[WinUSB_ServiceInstall]
显示名称=%WinUSB_SvcDesc%
服务类型= 1
StartType = 3
错误控制= 1
ServiceBinary =%12%\\ WinUSB.sys[USB_Install.Wdf]
KmdfService =了WinUSB,WinUsb_Install[WinUSB_Install]
KmdfLibraryVersion = 1.11[USB_Install.HW]
的AddReg = Dev_AddReg[Dev_AddReg]
HKR ,, DeviceInterfaceGUIDs,为0x10000,{fcb251a5-6a1f-4e5b-9df8-e8de91d04cfe}
;当与破折号编辑GUID(大十六进制数字的波浪里
;大括号),请务必写预期的PC应用程序使用相同的GUID。
;否则,应用程序将不能正确地找到USB设备。[USB_Install.CoInstallers]
的AddReg = CoInstallers_AddReg
CopyFiles = CoInstallers_CopyFiles[CoInstallers_AddReg]
HKR ,, CoInstallers32,0x00010000,WdfCoInstaller01011.dll,WdfCoInstaller[CoInstallers_CopyFiles]
; WinUSBCoInstaller2.dll
WdfCoInstaller01011.dll[DestinationDirs]
CoInstallers_CopyFiles = 11; =================源媒体节=====================[SourceDisksNames]
1 =%DISK_NAME%[SourceDisksFiles]
WdfCoInstaller01011.dll = 1; ===================字符串===================[字符串]
MFGNAME =ATP工业集团; ManufacturerName
DESCRIPTION =TestCube;设备名称
WinUSB_SvcDesc =了WinUSB设备
DISK_NAME =TestCubeDriver安装盘; DiskName
DEVICEMANAGERCATEGORY =通用串行总线设备;班级名称
我的设备驱动程序成功安装和设备管理器报告该设备是否工作正常。我试图运行我的应用程序,它是能够找到我的设备并检索其详细信息。这一切工作,现在,我终于可以开始对物联网的应用端的工作。
编辑:即使它所有现在的工作,我不知道什么是错的原始模板 - 任何人都可以请解释我为什么第二个模板工程,而不是第一个
I'm working with the NXP LPC1788 microcontroller and I'm trying to create a driver on the host computer to communicate with it via USB. I believe that I've managed to get the device handling standard USB requests properly (the PC is able to read the string descriptors properly).
I'm having trouble writing a sample USB driver and installing it for the device, though. I'm working with Microsoft Visual Studio 2013. My steps were:
Creating a WinUSB Application, which produces a "Driver" and "Driver Package" project.
Modifying the generated INF file to use my device's VID and PID.
Building the projects - both build successfully. The output folder contains an INF file, a catalog file and WdfCoinstaller01011.dll.
Plugging in the microcontroller via USB, going to Device Manager → Update Driver Software..., browsing to the folder containing the INF file and selecting it.
This causes the following screen to appear:
- I select "Install this driver software anyway". After a short while, it presents this screen:
My INF file is given below:
;
; TestCubeDriver.inf
;
; Installs WinUsb
;
[Version]
Signature = "$Windows NT$"
Class = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %ManufacturerName%
CatalogFile=TestCubeDriver.cat
DriverVer=04/16/2014,15.55.4.44
; ========== Manufacturer/Models sections ===========
[Manufacturer]
%ManufacturerName% = Standard,NTamd64
[Standard.NTamd64]
%DeviceName% =USB_Install, USB\VID_0483&PID_5720
; ========== 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,"{fcb251a5-6a1f-4e5b-9df8-e8de91d04cfe}"
[USB_Install.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles
[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WdfCoInstaller01011.dll,WdfCoInstaller"
[CoInstallers_CopyFiles]
WdfCoInstaller01011.dll
[DestinationDirs]
CoInstallers_CopyFiles=11
; ================= Source Media Section =====================
[SourceDisksNames]
1 = %DiskName%
[SourceDisksFiles]
WdfCoInstaller01011.dll=1
; =================== Strings ===================
[Strings]
ManufacturerName=""
ClassName="Universal Serial Bus devices"
DiskName="TestCubeDriver Installation Disk"
WinUsb_SvcDesc="WinUSB Driver"
DeviceName="TestCubeDriver Device"
REG_MULTI_SZ = 0x00010000
.
The relevant part of my setupapi.dev.log file is given here. The following kind of lines appeared multiple times in the log:
sig: Key = testcubedriver.inf
sig: FilePath = C:\Windows\System32\DriverStore\Temp\{1bf7c0e3-30cb-6135-d9b8-7d1ac87a6c7c}\testcubedriver.inf
sig: Catalog = C:\Windows\System32\DriverStore\Temp\{1bf7c0e3-30cb-6135-d9b8-7d1ac87a6c7c}\TestCubeDriver.cat
! sig: Verifying file against specific (valid) catalog failed! (0x800b0109)
! sig: Error 0x800b0109: A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
The following also appeared:
ndv: Installing device...
dvi: {DIF_INSTALLDEVICE} 09:58:11.087
dvi: No class installer for 'TestCubeDriver Device'
dvi: CoInstaller 1: Enter 09:58:11.087
inf: Opened PNF: 'C:\Windows\INF\oem68.inf' ([strings])
!!! dvi: CoInstaller 1: failed(0xe0000101)!
!!! dvi: Error 0xe0000101: The required section was not found in the INF.
dvi: {DIF_INSTALLDEVICE - exit(0xe0000101)} 09:58:11.907
!!! ndv: Error(e0000101) installing device!
.
I use the following descriptors for my USB device:
/*----------------------------------------------------------------------------
* U S B - K e r n e l
*----------------------------------------------------------------------------
* Name: USBDESC.C
* Purpose: USB Descriptors
* Version: V1.10
*----------------------------------------------------------------------------
* This software is supplied "AS IS" without any warranties, express,
* implied or statutory, including but not limited to the implied
* warranties of fitness for purpose, satisfactory quality and
* noninfringement. Keil extends you a royalty-free right to reproduce
* and distribute executable files created using this software for use
* on NXP Semiconductors LPC family microcontroller devices only. Nothing
* else gives you the right to use this software.
*
* Copyright (c) 2005-2009 Keil Software.
*---------------------------------------------------------------------------*/
#include "lpc_types.h"
#include "usb.h"
#include "usbcore.h"
#include "usbhw.h"
/* USB Standard Device Descriptor */
const uint8_t USB_DeviceDescriptor[] = {
USB_DEVICE_DESC_SIZE, /* bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL(0x0200), /* 2.00 */ /* bcdUSB */
0xFF, /* bDeviceClass */
0x00, /* bDeviceSubClass */
0x00, /* bDeviceProtocol */
USB_MAX_PACKET_SIZE, /* bMaxPacketSize0 */
WBVAL(0x0483), /* idVendor */
WBVAL(0x5720), /* idProduct */
WBVAL(0x0100), /* 1.00 */ /* bcdDevice */
0x04, /* iManufacturer */
0x30, /* iProduct */
0x42, /* iSerialNumber */
0x01 /* bNumConfigurations */
};
/* USB Configuration Descriptor */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const uint8_t USB_ConfigDescriptor[] = {
/* Configuration 1 */
USB_CONFIGURATION_DESC_SIZE, /* bDescriptorType */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL( /* wTotalLength */
1*USB_CONFIGURATION_DESC_SIZE +
1*USB_INTERFACE_DESC_SIZE +
2*USB_ENDPOINT_DESC_SIZE
),
0x01, /* bNumInterfaces */
0x01, /* bConfigurationValue */
0x00, /* iConfiguration */
USB_CONFIG_SELF_POWERED /*|*/ /* bmAttributes */
/*USB_CONFIG_REMOTE_WAKEUP*/,
USB_CONFIG_POWER_MA(100), /* bMaxPower */
/* Interface 0, Alternate Setting 0, MSC Class */
USB_INTERFACE_DESC_SIZE, /* bLength */
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
0x00, /* bInterfaceNumber */
0x00, /* bAlternateSetting */
0x02, /* bNumEndpoints */
0xFF, /* bInterfaceClass */
0x0, /* bInterfaceSubClass */
0x0, /* bInterfaceProtocol */
0x5C, /* iInterface */
/* Interrupt In Endpoint */
USB_ENDPOINT_DESC_SIZE, /* bLength */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
USB_ENDPOINT_IN(2), /* bEndpointAddress */
USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */
WBVAL(0x0040), /* wMaxPacketSize */
0xA, /* bInterval */
/* Interrupt Out Endpoint */
USB_ENDPOINT_DESC_SIZE, /* bLength */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
USB_ENDPOINT_OUT(2), /* bEndpointAddress */
USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */
WBVAL(0x0040), /* wMaxPacketSize */
0xA, /* bInterval */
/* Terminator */
0 /* bLength */
};
/* USB String Descriptor (optional) */
const uint8_t USB_StringDescriptor[] = {
/* Index 0x00: LANGID Codes */
0x04, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
WBVAL(0x0409), /* US English */ /* wLANGID */
/* Index 0x04: Manufacturer */
0x2C, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
'A',0,
'T',0,
'P',0,
' ',0,
'I',0,
'n',0,
'd',0,
'u',0,
's',0,
't',0,
'r',0,
'i',0,
'e',0,
's',0,
' ',0,
'G',0,
'r',0,
'o',0,
'u',0,
'p',0,
' ',0,
/* Index 0x30: Product */
0x12, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
'T',0,
'e',0,
's',0,
't',0,
'C',0,
'u',0,
'b',0,
'e',0,
' ',0,
/* Index 0x42: Serial Number */
0x1A, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
'D',0,
'E',0,
'M',0,
'O',0,
'0',0,
'0',0,
'0',0,
'0',0,
'0',0,
'0',0,
'0',0,
'0',0,
/* Index 0x5C: Interface 0, Alternate Setting 0 */
0x0E, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
'M',0,
'e',0,
'm',0,
'o',0,
'r',0,
'y',0,
};
I tried out the INF template that Daniel K suggested here with my own configurations:
;This .inf file is a modified version of the example INF provided
;in the Microsoft document:
;"How to Use WinUSB to Communicate with a USB Device"
[Version]
Signature = "$Windows NT$"
Class = USBDevices
ClassGuid= {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %MFGNAME%
DriverVer=04/17/2014,1.0.0.0
CatalogFile=winusb.cat ;CAT file needed for a signed driver pacakage
;------------------------------------------------------------------------------
; ========== Manufacturer/Models sections ===========
;------------------------------------------------------------------------------
[Manufacturer]
%MFGNAME% = MyDevice_WinUSB,NTx86,NTamd64
;------------------------------------------------------------------------------
; Vendor and Product ID Definitions
;------------------------------------------------------------------------------
; When developing your custom USB device, the VID and PID used in the PC side
; application program and the firmware on the microcontroller must match.
; Modify the below lines 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.
; There is a maximum number of devices that can be supported per line however.
; If you append a large number of VID/PIDs to the end of the line, and get a:
; "The data area passed to a system call is too small." error when trying to install
; the INF, try removing some of the VIDs/PIDs.
;------------------------------------------------------------------------------
[MyDevice_WinUSB.NTx86]
%DESCRIPTION% =USB_Install, USB\VID_0483&PID_5720
[MyDevice_WinUSB.NTamd64]
%DESCRIPTION% =USB_Install, USB\VID_0483&PID_5720
;=========================================================================================
;ClassInstall32 and ClassInstall_AddReg sections used to make new device manager category.
;=========================================================================================
[ClassInstall32]
AddReg=ClassInstall_AddReg
[ClassInstall_AddReg]
HKR,,,,%DEVICEMANAGERCATEGORY%
HKR,,Icon,,"-20"
; =================== 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.Wdf]
KmdfService=WINUSB, WinUsb_Install
[WinUSB_Install]
KmdfLibraryVersion=1.11
[USB_Install.HW]
AddReg=Dev_AddReg
[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{fcb251a5-6a1f-4e5b-9df8-e8de91d04cfe}"
;When editing the GUID (the big hex number with dashes inside the squiggly
;braces), make sure to write the intended PC application to use the same GUID.
;Otherwise the application won't be able to find the USB device properly.
[USB_Install.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles
[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WdfCoInstaller01011.dll,WdfCoInstaller",
[CoInstallers_CopyFiles]
;WinUSBCoInstaller2.dll
WdfCoInstaller01011.dll
[DestinationDirs]
CoInstallers_CopyFiles=11
; ================= Source Media Section =====================
[SourceDisksNames]
1 = %DISK_NAME%
[SourceDisksFiles]
WdfCoInstaller01011.dll=1
; =================== Strings ===================
[Strings]
MFGNAME="ATP Industries Group" ; ManufacturerName
DESCRIPTION="TestCube" ; DeviceName
WinUSB_SvcDesc="WinUSB Device"
DISK_NAME="TestCubeDriver Installation Disk" ; DiskName
DEVICEMANAGERCATEGORY="Universal Serial Bus devices" ; ClassName
My device driver installed successfully and Device Manager reports that the device is working properly. I tried running my application and it's able to find my device and retrieve details about it. It all works now, and I can finally start working on the application-side of things.
Edit: Even though it's all working now, I have no idea what was wrong with the original template - could anyone please explain to me why the second template works and not the first?
这篇关于使用自定义INF用于微控制器的USB驱动程序安装问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!