阅读:2525回复:13
请教一个USB驱动开发的问题(新手上路)
我现在用DS2.6生成了一个USB驱动,用于AT91SAM7X256自带的USB调试,但上电提示安装驱动时,我用做好的驱动安装失败。我是参考网上提供的《30分钟开发USB设备》进行操作的,VID和PID与AT91芯片提供的是一致的(VID:0X03EB;PID:0X6124),CLASSGUID是自动生成的(ClassGUID={ff646f80-8def-11d2-9449-00105a075f6b}),但我一直不知道它是由什么决定的,读写文件我没有修改,请问以上工作是否能让设备认可我的驱动,如果不能,还需要做哪些工作。谢谢
我的INF如下: ;; Usbdriver.inf ;; ********* PLEASE READ *********** ;; The wizard cannot create exact INF files for all buses and device types. ;; You may have to make changes to this file in order to get your device to ;; install. In particular, hardware IDs and logical configurations require ;; intervention. ;; ;; The Win2K DDK documentation contains an excellent INF reference. ;--------- Version Section --------------------------------------------------- [Version] Signature="$Windows NT$" Provider=%JIM-GAO% ; If device fits one of the standard classes, use the name and GUID here, ; otherwise create your own device class and GUID as this example shows. Class=USB ClassGUID={ff646f80-8def-11d2-9449-00105a075f6b} ;--------- SourceDiskNames and SourceDiskFiles Section ----------------------- ; These sections identify source disks and files for installation. They are ; shown here as an example, but commented out. ;[SourceDisksNames] ;1 = "Install Disk",Disk1,, ;[SourceDisksFiles] ;Usbdriver.sys = 1,, ;--------- ClassInstall/ClassInstall32 Section ------------------------------- ; Not necessary if using a standard class ; 9X Style [ClassInstall] Addreg=Class_AddReg ; NT Style [ClassInstall32] Addreg=Class_AddReg [Class_AddReg] HKR,,,,%DeviceClassName% HKR,,Icon,,"-18" ;--------- DestinationDirs Section ------------------------------------------- [DestinationDirs] Usbdriver_Files_Driver = 10,System32\Drivers ;--------- Manufacturer and Models Sections ---------------------------------- [Manufacturer] %MfgName%=Mfg0 [Mfg0] %DeviceDesc%=Usbdriver_DDI, USB\VID_0471&PID_0222 ;---------- DDInstall Sections ----------------------------------------------- ; --------- Windows 9X ----------------- ; Experimentation has shown that DDInstall root names greater than 19 characters ; cause problems in Windows 98 [Usbdriver_DDI] CopyFiles=Usbdriver_Files_Driver AddReg=Usbdriver_9X_AddReg [Usbdriver_9X_AddReg] HKR,,DevLoader,,*ntkern HKR,,NTMPDriver,,Usbdriver.sys HKR, "Parameters", "BreakOnEntry", 0x00010001, 0 ; --------- Windows NT ----------------- [Usbdriver_DDI.NT] CopyFiles=Usbdriver_Files_Driver AddReg=Usbdriver_NT_AddReg [Usbdriver_DDI.NT.Services] Addservice = Usbdriver, 0x00000002, Usbdriver_AddService [Usbdriver_AddService] DisplayName = %SvcDesc% ServiceType = 1 ; SERVICE_KERNEL_DRIVER StartType = 3 ; SERVICE_DEMAND_START ErrorControl = 1 ; SERVICE_ERROR_NORMAL ServiceBinary = %10%\System32\Drivers\Usbdriver.sys [Usbdriver_NT_AddReg] HKLM, "System\CurrentControlSet\Services\Usbdriver\Parameters",\ "BreakOnEntry", 0x00010001, 0 ; --------- Files (common) ------------- [Usbdriver_Files_Driver] Usbdriver.sys ;--------- Strings Section --------------------------------------------------- [Strings] ProviderName="Your Company Name here" MfgName="Name of HW Manufacturer here" DeviceDesc="Description of Device here" DeviceClassName="Description of Device class here" SvcDesc="Description of NT service here" |
|
沙发#
发布于:2008-04-08 12:51
[Mfg0]
%DeviceDesc%=Usbdriver_DDI, USB\VID_0471&PID_0222 改成你自己的vid,pid |
|
板凳#
发布于:2008-04-08 13:49
谢谢,那GUID是否要修改,另外USB能否被识别安装,只与INF文件有关吗?
|
|
地板#
发布于:2008-04-08 14:51
ClassGUID指明你的设备属于那个设备类目录下,你打开设备管理器,可以看到“通用串口总线”,“磁盘驱动器”等等一系列目录,这些目录都由一个GUID制定
你的设备属于那个设备类,就指明哪个GUID |
|
地下室#
发布于:2008-04-08 15:34
谢谢,那按您的说法,我是否可以理解为我用到的USB属于通用串口总线,那它对应的CLASSGUID应是一个唯一值。
另外,我在编译时出现如下错误: -------------------Configuration: at91_usb - Win32 Checked-------------------- Linking... Microsoft (R) Incremental Linker Version 6.00.8168 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. LINK : fatal error LNK1146: no argument specified with option "/libpath:" Error executing link.exe. at91_usb.sys - 1 error(s), 0 warning(s) The following environment variables were not found $(TARGET_LIB_PATH) $(BASEDIR) $(CPU) 请教是哪出了问题 |
|
5楼#
发布于:2008-04-08 16:21
上面问题解决了,是没有将DDK路径设置。编译成功后,我将INF文件放到WINNT下的INF文件夹中,将SYS文件放到SYSTEM32\DRIVER文件夹中。接上设备后,USB自动找到我的驱动,但是设备不能用(打着问号),属性中显示:“设备无法启动(代码10)”,不知是什么原因
|
|
6楼#
发布于:2008-04-08 22:22
这样放进去没用的,系统肯定不认
需要安装驱动,或者你胆子够大也可以直接改注册表,不过我不推荐你直接改,危险系数太高 开发过程中可以手动安装驱动,就是在打问号的那个设备上点右键,更新驱动 开发完了需要提供安装程序的话,推荐直接用InstallShield,省时省力,不重复发明轮子 嫌InstallShield贵非自己做的话,用DiUpdatePlugAndPlayDevice(具体函数名记不到很清楚)函数 手动改注册表看这个帖子http://bbs.driverdevelop.com/htm_data/81/0802/109285.html |
|
7楼#
发布于:2008-04-09 00:50
引用第5楼qudong2008于2008-04-08 16:21发表的 : 把你的驱动和INF放到一个目录下,插入设备,手动安装驱动 |
|
8楼#
发布于:2008-04-09 08:37
谢谢,首先我手动安装的驱动(自动生成的),但还是有问题;我又按楼上说的方法试了,问题依旧。我有几个问题请教:
1. 用DS生成的SYS和INF文件,如果能安装成功,SYS内容需要修改吗(SYS自动生成后未做任何改动)?它是否只与INF有关? 2. 每次手动安装完驱动后,都要求重新启动计算机,请问能否不用重启动系统就能让驱动生效? 3. 每次退出USB设备时,右下角的图标仍然存在,不能去掉,请问有什么办法能去掉它? 下面是我的INF内容,真诚希望在这里能得到高手的指点: ; Installation inf for the ATMEL AT91xxxxx Test Board ; ; (c) Copyright 2008 D&S ; [Version] Signature="$WINDOWS NT$" Class=USB ClassGUID={36FC9E60-C465-11CF-8056-444553540000} Provider=%ProviderName% DriverVer=04/08/2008 [SourceDisksNames] 1 = "AT91SAM7X256 Installation Disk",,, [SourceDisksFiles] At91_usb.sys = 1 At91_usb.inf = 1 ;--------- ClassInstall/ClassInstall32 Section ------------------------------- ; Not necessary if using a standard class ; 9X Style [ClassInstall] Addreg=Class_AddReg ; NT Style [ClassInstall32] Addreg=Class_AddReg [Class_AddReg] HKR,,,,%DeviceClassName% HKR,,Icon,,"-18" ;--------- DestinationDirs Section ------------------------------------------- [DestinationDirs] At91_usb_Files_Driver = 10,System32\Drivers ;--------- Manufacturer and Models Sections ---------------------------------- [Manufacturer] %MfgName%=Mfg0 [Mfg0] %DeviceDesc%=At91_usb_DDI, USB\VID_03EB&PID_6124 ;---------- DDInstall Sections ----------------------------------------------- ; --------- Windows 9X ----------------- ; Experimentation has shown that DDInstall root names greater than 19 characters ; cause problems in Windows 98 [At91_usb_DDI] CopyFiles=At91_usb_Files_Driver AddReg=At91_usb_9X_AddReg [At91_usb_9X_AddReg] HKR,,DevLoader,,*ntkern HKR,,NTMPDriver,,At91_usb.sys HKR, "Parameters", "BreakOnEntry", 0x00010001, 0 ; --------- Windows NT ----------------- [At91_usb_DDI.NT] CopyFiles=At91_usb_Files_Driver AddReg=At91_usb_NT_AddReg [At91_usb_DDI.NT.Services] Addservice = At91_usb, 0x00000002, At91_usb_AddService [At91_usb_AddService] DisplayName = %SvcDesc% ServiceType = 1 ; SERVICE_KERNEL_DRIVER StartType = 3 ; SERVICE_DEMAND_START ErrorControl = 1 ; SERVICE_ERROR_NORMAL ServiceBinary = %10%\System32\Drivers\At91_usb.sys [At91_usb_NT_AddReg] HKLM, "System\CurrentControlSet\Services\At91_usb\Parameters",\ "BreakOnEntry", 0x00010001, 0 ; --------- Files (common) ------------- [At91_usb_Files_Driver] At91_usb.sys ;--------- Strings Section --------------------------------------------------- [Strings] ProviderName="D&S,INC." MfgName="D&S" DeviceDesc="AT91SAM7X256 USB TESTING" DeviceClassName="CDC USB" SvcDesc="AT91USB.SYS AT91 USB DRIVER" |
|
9楼#
发布于:2008-04-09 17:45
另外还有一个问题:
BUS HOUND中CONTROL代码:80 06 01 03 00 00 00 00数据分别代表什么意思,从哪里能够找到。 谢谢 |
|
驱动牛犊
|
10楼#
发布于:2008-04-10 10:01
哈哈
还是没看好 INF文件直接确定注册表,尤其是[Mfg0] %DeviceDesc%=Usbdriver_DDI, USB\VID_0471&PID_0222 这句话,如果你不知道设备的VID&PID,驱动是不会生效的 原因是: 设备被总线识别后,需要去注册表搜索该设备的VID&PID,如果没有搜到就说无法识别的设备. 开发驱动的另一个关键因素是你必须知道设备的配置,否则你就无的放失. 因为你必须用到象端点地址和其他的信息 |
11楼#
发布于:2008-04-10 12:09
谢谢,我的VID和PID是芯片自身定义的,不会有错,上电后能自动找到INF,属性里也有我的注册信息,但安装并不成功(带感叹号),我怀疑是否与SYS文件有关,我用DS2.6自动生成驱动后,并未对CPP文件做任何修改。
|
|
12楼#
发布于:2008-04-11 15:09
我已经困在这里两三天了,急得直上火,真诚盼望高手能指点迷津,谢谢
|
|
13楼#
发布于:2008-04-15 17:15
我将自动生成的工程发出来,希望在这里能得到高手指点
谢谢 |
|
|