Using a 6.0 R2 flash MDD/PDD Store with usbmsfn

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
.



Relevant Pages

  • RE: Using a 6.0 R2 flash MDD/PDD Store with usbmsfn
    ... For some reason IOCTL_DISK_READ fails on the store, ... on a partition from the store. ... So I modified usbmsfn in the following way when requested (using a registry ... UsbMsFn!STORE_Init: sectors = 64 ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Trouble burning DVD
    ... The signed32 limits all individual files on an ISO9660 fs to 2G. ... UDF stores file sizes in a 64-bit int, ... If you only store the number of N-byte ... sectors a file takes, any attempt to readan N+1-byte file will return ...
    (comp.os.linux.misc)
  • Re: Hiding data in drve bad sectors?
    ... generate a new hash, and see if the value has changed. ... it can not tell whether the data in those sectors ... if and only if the user can successfully store some data ... Guantanamo prisoners are no longer forced to undergo ...
    (comp.periphs.scsi)
  • Re: Hiding data in drve bad sectors?
    ... When a bad guy's hard drive is seized for legal purposes, ... generate a new hash, and see if the value has changed. ... it can not tell whether the data in those sectors ... if and only if the user can successfully store some data ...
    (comp.periphs.scsi)
  • Re: Hiding data in drve bad sectors?
    ... generate a new hash, and see if the value has changed. ... it can not tell whether the data in those sectors ... if and only if the user can successfully store some data ... If he *can*, then, the cryptographc hash should include ...
    (comp.periphs.scsi)