阅读:3852回复:25
在5.0上实现通过USB device访问SD卡
大家好,我在PC端通过USB device可以访问到CE端的SD卡(不用activesync),看到前面的帖子,CE本身的公共驱动oak/driver下USB驱动调用OpenStore函数打开了DSK1:,如下设置。
[HKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers\Mass_Storage_Class] "Dll"="usbmsfn.dll" "InterfaceSubClass"=dword:06 "InterfaceProtocol"=dword:50 "DeviceName"="DSK1:" "FriendlyName"="Mass Storage" ; idVendor must be changed. 045E belongs to Microsoft and is only to be used for ; prototype devices in your labs. Visit http://www.usb.org to obtain a vendor id. "idVendor"=dword:045E "Manufacturer"="Generic Manufacturer (PROTOTYPE--Remember to change idVendor)" "idProduct"=dword:FFFF "Product"="Generic Mass Storage (PROTOTYPE--Remember to change idVendor)" "bcdDevice"=dword:0 ; @CESYSGEN ENDIF CE_MODULES_USBMSFN 我的SD卡的注册表设置如下, ; SD Memory Storage class driver [HKEY_LOCAL_MACHINE\Drivers\SDCARD\ClientDrivers\Class\SDMemory_Class] "Dll"="SDMemory.dll" "Prefix"="DSK" "BlockTransferSize"=dword:40 ; send no more than 64 blocks of data per bus transfer ;"SingleBlockWrites"=dword:1 ; alternatively force the driver to use single block access ;"IdleTimeout"=dword:7D0 ; 2000 milliseconds ;"IdlePowerState"=dword:2 ; 0 == D0, 1 == D1, etc. ;"DisablePowerManagement"="" ; if value present, then disable (remove value to enable) "Profile"="SDMemory" "IClass"=multi_sz:"{A4E7EDDA-E575-4252-9D6B-4195D48BB865}", "{A32942B7-920C-486b-B0E6-92A702A99B35}" 我目前的困惑是我的SD卡的Prefix是DSK,又不是DSK1,系统是如何关联他们的,现在我想再打开一个设备(如第二个SD卡),我的Prefix应该设为多少?在什么地方设置。 谢谢! |
|
沙发#
发布于:2007-11-13 10:55
呃 是只要 注册表加上这条 就能实现吗?我这边接上电脑后,能检测到,但就是盘符半天不出来!!!! 会是哪里出问题呢?~?
|
|
板凳#
发布于:2007-11-13 11:23
用户被禁言,该主题自动屏蔽! |
|
地板#
发布于:2007-11-13 12:02
楼主,不一定要是DSK1啊,如果你前面还有一个DSK,SD就变成了DSK2,这个要根据自己的情况来设定,目的是得到szDeviceName这个,OpenStore时候要用的,
搭车问一下:有没有做过Multi-Lun的朋友?device端除了在 bmRequestType = a1,bRequest = fe,wIndex = 0, wLength=1,wValue =0 回应1(我是两个),还需要做什么?我的情况是这种情况下PC发过来的CBW还是只有lun=0? |
|
地下室#
发布于:2007-11-14 09:29
呃……加了啊……他是等很久很久才出来盘符,如后访问不到里面,也看不到属性……
|
|
5楼#
发布于:2007-11-14 09:44
找到干这个的组织了啊
俺是在4.2上搞的 不像5.0上啥啥注册表的全没有 已经基本(因为Write10还没写完)实现了访问SD卡功能, 现在就是想搞个再把nand flash也开放的功能 也跟werna兄有同样的困惑啊 除了get max lun回复1外,还需要做什么?怎么让PC那边来读两个MBR呢? SD卡一个nand flash一个 |
|
|
6楼#
发布于:2007-11-14 10:02
我是要读两个SD卡,我在我的板子上面实现了双SD卡的功能,通过测试,我确定这两个设备一个是DSK1:,一个是DSK2:,
然后按照以前帖子的回复,我在public/oak/driver/usbfn/class/storage/scsi2/block.cpp下面修改Store_init的代码,g_hStore = OpenStore(g_szDeviceName);是实现打开store的地方,注册表默认是打开DSK1:,然后我自己在后面加注了OpenStore(“DSK2:");想实现打开DSK2:,并且通过调试,好像OpenStore(“DSK2:");成功了,但是编译完成后,连接PC,还是只能看到一个盘(DSK1:),大家可否给我一个思路,如何让PC端认到我的DSK2. 多谢 |
|
7楼#
发布于:2007-11-14 10:14
光是多OpenStore一个还不行哦
我现在是想不明白怎么让PC知道你这边有两个SD卡,如何让他发两个read10来读MBR |
|
|
8楼#
发布于:2007-11-14 11:01
那还需要做些什么工作,可否提示一下。
|
|
9楼#
发布于:2007-11-14 11:52
微软有没有相关的资料?
|
|
10楼#
发布于:2007-11-14 14:55
怎么搞我也想不明白啊
我是觉得光是多OpenStore一个应该不行哦 PC怎么知道? |
|
|
11楼#
发布于:2007-11-14 17:31
理论上PC Get Max Lun以后,PC就知道有几个了,但是我的问题它不发lun=1 的CBW下来??郁闷了
20.0 DI 09 02 20 00 01 01 00 c0 00 .. ...... 30.3.0 20.0 CTL 80 06 00 02 00 00 20 00 GET DESCRIPTOR 31.1.0 20.0 LEN 20 00 00 00 32 31.2.0 20.0 DI 09 02 20 00 01 01 00 c0 00 09 04 00 00 02 08 06 50 00 07 05 81 02 00 02 00 07 05 02 02 00 02 00 .. ............. 31.3.0 20.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 32.1.0 20.0 CTL 01 0b 00 00 00 00 00 00 SET INTERFACE 33.1.0 20.0 CTL a1 fe 00 00 00 00 01 00 GET MAX LUN 34.1.0 20.0 LEN 01 00 00 00 1 34.2.0 20.0 DI 01 . 34.3.0 20.2 LEN 1f 00 00 00 31 35.1.0 20.2 DO 55 53 42 43 a8 78 a2 83 24 00 00 00 80 00 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 USBC.x..$....... 35.2.0 20.1 LEN 24 00 00 00 36 36.1.0 20.1 DI 00 80 02 02 1f 00 00 00 4e 61 6e 44 20 46 6c 61 73 48 20 20 20 20 20 20 31 2e 30 30 4e 4f 56 41 ........NanD Fla 36.2.0 20.1 LEN 0d 00 00 00 13 37.1.0 20.1 DI 55 53 42 53 a8 78 a2 83 00 00 00 00 00 USBS.x....... 37.2.0 20.2 LEN 1f 00 00 00 31 38.1.0 20.2 DO 55 53 42 43 a8 78 a2 83 fc 00 00 00 80 00 0a 23 00 00 00 00 00 00 00 fc 00 00 00 00 00 00 00 USBC.x.........# 38.2.0 20.1 LEN 0c 00 00 00 12 39.1.0 20.1 DI 00 00 00 08 00 07 b4 3f 02 00 08 00 .......?.... 39.2.0 20.1 LEN 0d 00 00 00 13 40.1.0 20.1 DI 55 53 42 53 a8 78 a2 83 f0 00 00 00 00 USBS.x....... 40.2.0 20.2 LEN 1f 00 00 00 31 41.1.0 20.2 DO 55 53 42 43 a8 78 a2 83 08 00 00 00 80 00 0a 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 USBC.x.........% 41.2.0 20.1 LEN 08 00 00 00 8 42.1.0 20.1 DI 00 07 b4 3f 00 00 08 00 ...?.... 42.2.0 20.1 LEN 0d 00 00 00 13 43.1.0 20.1 DI 55 53 42 53 a8 78 a2 83 00 00 00 00 00 USBS.x....... 43.2.0 20.2 LEN 1f 00 00 00 31 44.1.0 20.2 DO 55 53 42 43 a8 78 a2 83 00 08 00 00 80 00 0a 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 USBC.x.........( 44.2.0 20.1 LEN 00 08 00 00 2048 45.1.0 20.1 DI e9 fd ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 45.2.0 20.1 LEN 0d 00 00 00 13 46.1.0 20.1 DI 55 53 42 53 a8 78 a2 83 00 00 00 00 00 USBS.x....... 46.2.0 上面是我截取的包 20.0 CTL 01 0b 00 00 00 00 00 00 SET INTERFACE 34.1.0 20.0 CTL a1 fe 00 00 00 00 01 00 GET MAX LUN 35.1.0 20.0 LEN 01 00 00 00 1 35.2.0 20.0 DI 03 . 35.3.0 20.3 LEN 1f 00 00 00 31 36.1.0 20.3 DO 55 53 42 43 08 80 e4 83 24 00 00 00 80 00 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 USBC....$....... 36.2.0 20.4 LEN 24 00 00 00 36 37.1.0 20.4 DI 00 80 00 01 1f 00 00 00 4d 79 73 6f 6e 20 20 20 43 53 38 38 31 39 41 32 2d 31 31 33 20 20 30 20 ........Myson 37.2.0 20.4 LEN 0d 00 00 00 13 38.1.0 20.4 DI 55 53 42 53 08 80 e4 83 00 00 00 00 00 USBS......... 38.2.0 20.3 LEN 1f 00 00 00 31 39.1.0 20.3 DO 55 53 42 43 08 80 e4 83 fc 00 00 00 80 00 0a 23 00 00 00 00 00 00 00 fc 00 00 00 00 00 00 00 USBC...........# 39.2.0 20.4 LEN 0d 00 00 00 13 40.1.0 20.4 DI 55 53 42 53 08 80 e4 83 fc 00 00 00 01 USBS......... 40.2.0 20.3 LEN 1f 00 00 00 31 41.1.0 20.3 DO 55 53 42 43 08 80 e4 83 12 00 00 00 80 00 0c 03 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 USBC............ 41.2.0 20.4 LEN 12 00 00 00 18 42.1.0 20.4 DI 70 00 02 00 00 00 00 0a 00 00 00 00 3a 00 00 00 00 00 p...........:... 42.2.0 20.4 LEN 0d 00 00 00 13 43.1.0 20.4 DI 55 53 42 53 08 80 e4 83 00 00 00 00 00 USBS......... 43.2.0 20.3 LEN 1f 00 00 00 31 44.1.0 20.3 DO 55 53 42 43 08 80 e4 83 fc 00 00 00 80 00 0a 23 00 00 00 00 00 00 00 fc 00 00 00 00 00 00 00 USBC...........# 44.2.0 20.4 LEN 0d 00 00 00 13 45.1.0 20.4 DI 55 53 42 53 08 80 e4 83 fc 00 00 00 01 USBS......... 45.2.0 20.3 LEN 1f 00 00 00 31 46.1.0 20.3 DO 55 53 42 43 08 80 e4 83 12 00 00 00 80 00 0c 03 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 USBC............ 46.2.0 20.4 LEN 12 00 00 00 18 47.1.0 20.4 DI 70 00 02 00 00 00 00 0a 00 00 00 00 3a 00 00 00 00 00 p...........:... 47.2.0 20.4 LEN 0d 00 00 00 13 48.1.0 20.4 DI 55 53 42 53 08 80 e4 83 00 00 00 00 00 USBS......... 48.2.0 20.3 LEN 1f 00 00 00 31 49.1.0 20.3 DO 55 53 42 43 08 80 e4 83 fc 00 00 00 80 00 0a 23 00 00 00 00 00 00 00 fc 00 00 00 00 00 00 00 USBC...........# 49.2.0 20.4 LEN 0d 00 00 00 13 50.1.0 20.4 DI 55 53 42 53 08 80 e4 83 fc 00 00 00 01 USBS......... 50.2.0 20.3 LEN 1f 00 00 00 31 51.1.0 20.3 DO 55 53 42 43 08 80 e4 83 12 00 00 00 80 00 0c 03 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 USBC............ 51.2.0 20.4 LEN 12 00 00 00 18 52.1.0 20.4 DI 70 00 02 00 00 00 00 0a 00 00 00 00 3a 00 00 00 00 00 p...........:... 52.2.0 20.4 LEN 0d 00 00 00 13 53.1.0 20.4 DI 55 53 42 53 08 80 e4 83 00 00 00 00 00 USBS......... 53.2.0 20.3 LEN 1f 00 00 00 31 54.1.0 20.3 DO 55 53 42 43 08 80 e4 83 24 00 00 00 80 01 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 USBC....$....... 54.2.0 20.4 LEN 24 00 00 00 36 55.1.0 20.4 DI 00 80 00 01 1f 00 00 00 4d 79 73 6f 6e 20 20 20 43 53 38 38 31 39 41 32 2d 31 31 33 20 20 31 20 ........Myson 55.2.0 20.4 LEN 0d 00 00 00 13 56.1.0 20.4 DI 55 53 42 53 08 80 e4 83 00 00 00 00 00 USBS......... 56.2.0 20.3 LEN 1f 00 00 00 31 57.1.0 20.3 DO 55 53 42 43 08 80 e4 83 fc 00 00 00 80 01 0a 23 00 00 00 00 00 00 00 fc 00 00 00 00 00 00 00 USBC...........# 57.2.0 20.4 LEN 0d 00 00 00 13 58.1.0 20.4 DI 55 53 42 53 08 80 e4 83 fc 00 00 00 01 USBS......... 58.2.0 20.3 LEN 1f 00 00 00 31 59.1.0 20.3 DO 55 53 42 43 08 80 e4 83 12 00 00 00 80 01 0c 03 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 USBC............ 59.2.0 20.4 LEN 12 00 00 00 18 60.1.0 20.4 DI 70 00 02 00 00 00 00 0a 00 00 00 00 3a 00 00 00 00 00 p...........:... 60.2.0 20.4 LEN 0d 00 00 00 13 61.1.0 20.4 DI 55 53 42 53 08 80 e4 83 00 00 00 00 00 USBS......... 61.2.0 20.3 LEN 1f 00 00 00 31 62.1.0 20.3 DO 55 53 42 43 08 80 e4 83 fc 00 00 00 80 01 0a 23 00 00 00 00 00 00 00 fc 00 00 00 00 00 00 00 USBC...........# 62.2.0 20.4 LEN 0d 00 00 00 13 63.1.0 20.4 DI 55 53 42 53 08 80 e4 83 fc 00 00 00 01 USBS......... 63.2.0 20.3 LEN 1f 00 00 00 31 64.1.0 20.3 DO 55 53 42 43 08 80 e4 83 12 00 00 00 80 01 0c 03 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 USBC............ 64.2.0 20.4 LEN 12 00 00 00 18 65.1.0 20.4 DI 70 00 02 00 00 00 00 0a 00 00 00 00 3a 00 00 00 00 00 p...........:... 65.2.0 20.4 LEN 0d 00 00 00 13 66.1.0 20.4 DI 55 53 42 53 08 80 e4 83 00 00 00 00 00 USBS......... 66.2.0 20.3 LEN 1f 00 00 00 31 67.1.0 20.3 DO 55 53 42 43 08 80 e4 83 fc 00 00 00 80 01 0a 23 00 00 00 00 00 00 00 fc 00 00 00 00 00 00 00 USBC...........# 67.2.0 20.4 LEN 0d 00 00 00 13 68.1.0 20.4 DI 55 53 42 53 08 80 e4 83 fc 00 00 00 01 USBS......... 68.2.0 20.3 LEN 1f 00 00 00 31 69.1.0 20.3 DO 55 53 42 43 08 80 e4 83 12 00 00 00 80 01 0c 03 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 USBC............ 69.2.0 20.4 LEN 12 00 00 00 18 70.1.0 20.4 DI 70 00 02 00 00 00 00 0a 00 00 00 00 3a 00 00 00 00 00 p...........:... 70.2.0 20.4 LEN 0d 00 00 00 13 71.1.0 20.4 DI 55 53 42 53 08 80 e4 83 00 00 00 00 00 USBS......... 71.2.0 20.3 LEN 1f 00 00 00 31 72.1.0 20.3 DO 55 53 42 43 08 80 e4 83 24 00 00 00 80 02 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 USBC....$....... 72.2.0 20.4 LEN 24 00 00 00 36 73.1.0 20.4 DI 00 80 00 01 1f 00 00 00 4d 79 73 6f 6e 20 20 20 43 53 38 38 31 39 41 32 2d 31 31 33 20 20 32 20 ........Myson 73.2.0 20.4 LEN 0d 00 00 00 13 74.1.0 20.4 DI 55 53 42 53 08 80 e4 83 00 00 00 00 00 USBS......... 74.2.0 20.3 LEN 1f 00 00 00 31 75.1.0 20.3 DO 55 53 42 43 08 80 e4 83 fc 00 00 00 80 02 0a 23 00 00 00 00 00 00 00 fc 00 00 00 00 00 00 00 USBC...........# 75.2.0 20.4 LEN 0c 00 00 00 12 76.1.0 20.4 DI 00 00 00 08 00 1e 53 ff 00 00 02 00 ......S..... 76.2.0 20.4 LEN 0d 00 00 00 13 77.1.0 20.4 DI 55 53 42 53 08 80 e4 83 f0 00 00 00 00 USBS......... 77.2.0 20.3 LEN 1f 00 00 00 31 78.1.0 20.3 DO 55 53 42 43 08 80 e4 83 24 00 00 00 80 03 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 USBC....$....... 78.2.0 20.4 LEN 24 00 00 00 36 79.1.0 20.4 DI 00 80 00 01 1f 00 00 00 4d 79 73 6f 6e 20 20 20 43 53 38 38 31 39 41 32 2d 31 31 33 20 20 33 20 ........Myson 79.2.0 20.4 LEN 0d 00 00 00 13 80.1.0 20.4 DI 55 53 42 53 08 80 e4 83 00 00 00 00 00 USBS......... 80.2.0 20.3 LEN 1f 00 00 00 31 81.1.0 20.3 DO 55 53 42 43 08 80 e4 83 fc 00 00 00 80 03 0a 23 00 00 00 00 00 00 00 fc 00 00 00 00 00 00 00 USBC...........# 81.2.0 20.4 LEN 0d 00 00 00 13 82.1.0 20.4 DI 55 53 42 53 08 80 e4 83 fc 00 00 00 01 USBS......... 82.2.0 20.3 LEN 1f 00 00 00 31 83.1.0 20.3 DO 55 53 42 43 08 80 e4 83 12 00 00 00 80 03 0c 03 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 USBC............ 83.2.0 20.4 LEN 12 00 00 00 18 84.1.0 20.4 DI 70 00 02 00 00 00 00 0a 00 00 00 00 3a 00 00 00 00 00 p...........:... 84.2.0 20.4 LEN 0d 00 00 00 13 85.1.0 20.4 DI 55 53 42 53 08 80 e4 83 00 00 00 00 00 USBS......... 85.2.0 20.3 LEN 1f 00 00 00 31 86.1.0 20.3 DO 55 53 42 43 08 80 e4 83 fc 00 00 00 80 03 0a 23 00 00 00 00 00 00 00 fc 00 00 00 00 00 00 00 USBC...........# 86.2.0 20.4 LEN 0d 00 00 00 13 87.1.0 20.4 DI 55 53 42 53 08 80 e4 83 fc 00 00 00 01 USBS......... 87.2.0 N和一USB读卡器的包.... |
|
12楼#
发布于:2007-11-14 19:03
微软的驱动只支持一次EXpose一个设备给USB HOst,除非你自己修改驱动
|
|
13楼#
发布于:2007-11-15 13:48
收到Get Max Lun后,我wince这边直接回复的0x00。。。
回复0x01也一样 我没感觉到有啥区别啊 请教werna兄 lun=1 的CBW的operationcode是多少啊? 还有我的usb现在读SD卡速度还能接受,写SD卡速度简直根蜗牛一样,SD卡驱动是木有问题的,应该还是在USB这块,怎么把速度提高啊 我USB的in和out都没用DMA的 可是一个速度是M/S 一个是K/S,这个差距也太大了 |
|
|
14楼#
发布于:2007-11-15 13:52
引用第12楼heyong_401于2007-11-14 19:03发表的 : get max lun是入口点 至于后面怎么做 老兄能否提点一下? |
|
|
15楼#
发布于:2007-11-16 12:15
引用第13楼sniper167于2007-11-15 13:48发表的 : lun 的编号和OPcode没有一定关系,理论上: get MAx LUN -》opcode=0x12的CBW -》opcode = 0x23 的CBW,接下来会对Lun=1的发送同样的这两个CBW。。。 |
|
16楼#
发布于:2007-11-17 09:34
引用第15楼werna于2007-11-16 12:15发表的 : 那如果PC要读或者写 如何来判断read10或者write10是想对哪个SD卡进行操作呢 |
|
|
17楼#
发布于:2007-11-19 09:32
引用第16楼sniper167于2007-11-17 09:34发表的 : 就根据lun ID,将请求发向不同的SD 设备 |
|
18楼#
发布于:2007-11-29 17:36
请问,设备的Lun ID在何处设置?而后如何将请求发向不同的SD设备呢?
|
|
19楼#
发布于:2007-11-30 09:42
引用第18楼tyris于2007-11-29 17:36发表的 : 貌似在USB版看到个帖子说是在string里面。。。 但不确定是否正确,因为看过一段时间了,还没去实践 在问下tyris,你的usb读写SD卡,速率有好多呀 我给写SD加了个DMA,但没见啥提高呀 |
|
|
上一页
下一页