Using a 6.0 R2 flash MDD/PDD Store with usbmsfn
- From: Marc-Andre Hebert <MarcAndreHebert@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 3 Dec 2009 08:01:01 -0800
Hello,
I have a NAND flash driver built using the MDD/PDD model. It is working well
within CE. Now I would like to expose the drive as a mass storage device
using the usb mass storage function client but it doesn't work. I have been
able to use other stores (sd card, ram drive) using the usbmsfn but not the
flash driver.
When I activate the usbmsfn and connect it to the pc, it takes a while but
all I get is a drive but with an error message saying there is no disk if I
click on it.
I've used the debug version of usbmsfn and activated all the debug zones to
get some information and I see that it fails when it tries to read from the
store:
UsbMsFn!ProcessScsiRead10: starting LBA/sector = 0, transfer length = 1
(sectors)
UsbMsFn!ProcessScsiRead10: IOCTL_DISK_READ failed; error = 87
(87: ERROR_INVALID_PARAMETER)
Before that I can see that IOCTL_DISK_GETINFO works:
UsbMsFn!STORE_Init: IOCTL_DISK_GETINFO passed
UsbMsFn!STORE_Init: bytes per sector = 4096
UsbMsFn!STORE_Init: cylinders = 64
UsbMsFn!STORE_Init: flags = 0x8
UsbMsFn!STORE_Init: heads = 1
UsbMsFn!STORE_Init: sectors = 64
UsbMsFn!STORE_Init: total sectors = 4096
This makes sense since my NAND is using 4096 pages with 64 pages per block.
So looking at the source code, I can see usbmsfn does not try to use the
legacy ioctls since IOCTL_DISK_GETINFO works.
Now I have written a simple app that tries to read a sector from the store
directly like this (duplicating what usbmsfn does):
(Open store, call IOCTL_DISK_GETINFO to get g_diDiskInfo...)
pbData = (PBYTE) LocalAlloc( LPTR, g_diDiskInfo.di_bytes_per_sect );
SG_REQ sgSgReq;
SG_BUF sgSgBuf;
// prepare scatter/gather buffer
sgSgBuf.sb_buf = pbData;
sgSgBuf.sb_len = g_diDiskInfo.di_bytes_per_sect;
// prepare scatter/gather request
sgSgReq.sr_start = dwLogicalBlockAddress;
sgSgReq.sr_num_sec = dwTransferLength;
sgSgReq.sr_status = 0;
sgSgReq.sr_callback = NULL;
sgSgReq.sr_num_sg = 1;
sgSgReq.sr_sglist[0] = sgSgBuf;
fResult = DeviceIoControl( hStore,
IOCTL_DISK_READ,
&sgSgReq,
sizeof(sgSgReq),
NULL,
0,
&dwBytesReturned,
NULL);
(error handling...)
This gives me the ERROR_INVALID_PARAMETER with my flash store but it works
correctly using the SD or RAM drive store. I don't think it would be possible
for the flash store to not support IOCTL_DISK_READ (if it would be the case I
would expect something like ERROR_NOT_SUPPORTED) otherwise how would the
storage manager obtain any data from the store?
Any ideas?
Thanks
Marc
.
- Follow-Ups:
- RE: Using a 6.0 R2 flash MDD/PDD Store with usbmsfn
- From: Marc-Andre Hebert
- Re: Using a 6.0 R2 flash MDD/PDD Store with usbmsfn
- From: Rik Attrill
- Re: Using a 6.0 R2 flash MDD/PDD Store with usbmsfn
- From: Valter Minute [eMVP]
- RE: Using a 6.0 R2 flash MDD/PDD Store with usbmsfn
- Prev by Date: Re: Access Violation in stream interface drive
- Next by Date: Re: Using a 6.0 R2 flash MDD/PDD Store with usbmsfn
- Previous by thread: How to See to which file MEM_MAPPED
- Next by thread: Re: Using a 6.0 R2 flash MDD/PDD Store with usbmsfn
- Index(es):
Relevant Pages
|