Tuesday, 29 June 2010

Windows Embedded CE: USB memory stick fix part 2

Hi foks,

Following up on my previous post about USB memory stick fixes; here is another fix for direct access of USB memory sticks. Again, the files mentioned reside under _PUBLICROOT\COMMON\OAK\DRIVERS\USB\CLASS\STORAGE\DISK\SCSI2. Be sure to clone the respective files to your Platform before altering them!

4 issues with direct access USB memory sticks

In the function GetMediumInfo in disk.c there are some USB memory sticks that do not recover well from the call to either of the ScsiModeSense6/ScsiModeSense10 commands which are used to retrieve the device type as well as the state of the write protect bit. Neither of these commands are necessary according to the SCSI-2 specification, anyway.


Since the working USB memory sticks seem to return 0x80 as the pDevice->MediumType we will also set the medium type to 0x80 for direct access USB memory sticks. In addition we need to disable the write protect bit.

Replace the if statement following the
// determine medium type
comment with:

// USB Memory Stick fix:

if (SCSI_DEVICE_UNKNOWN != pDevice->DeviceType &&
SCSI_MEDIUM_UNKNOWN == pDevice->MediumType )
if(SCSI_DEVICE_DIRECT_ACCESS == pDevice->DeviceType)
(TEXT("Device type: Direct Access => force medium type\n") ));
// set device type to 0x80
pDevice->MediumType = 0x80;
// disable write protect
pDevice->Flags.WriteProtect = 0;
dwErr = ScsiModeSense6(pDevice, Lun);

if (ERROR_SUCCESS != dwErr)
UCHAR senseData[18];

tData.TransferLength = 0;
tData.RequestLength = sizeof(senseData);
tData.DataBlock = senseData;

dwErr = ScsiRequestSense(pDevice, &tData, Lun);

dwErr = ScsiModeSense10(pDevice, Lun);

if (ERROR_SUCCESS != dwErr)

Have fun!

No comments: