At the mount of SD card, MacOSX puts PREVENT ALLOW MEDIUM REMOVAL(PREVENT:01b - prohibit removal), to know the auto-eject capability of the card reader.
a) Auto eject
If the device succeeds on this command, OS assumes auto-eject capability of the reader.
On drag-to-trash eject, MacOSX writes the write cache to the SD card. And then, it puts this command sequence, to eject the SD card by command.
- PREVENT ALLOW MEDIUM REMOVAL(PREVENT:00b - allow removal)
- START STOP UNIT
After START STOP UNIT, the device should fail TEST UNIT READY and other commands, because of no media.
b) Manual eject
Manual eject reader should fail PREVENT ALLOW MEDIUM REMOVAL(PREVENT:01b) at the mount of SD card.
The Sense Data for this fail is,
- Sense Key: ILLEGAL REQUEST (0x05)
- ASC/ASCQ : INVALID FIELD IN CDB (0x24/0x00)
On eject, MacOSX writes the write cache to the SD card.
And then, it polls manual eject using TEST UNIT READY
The problem on Microchip example is caused by the response that it succeeds PREVENT ALLOW MEDIUM REMOVAL(PREVENT:01b) at mount of SD card, though the SD Card PICTail Plus board doesn't have auto-eject capability. It should fail this SCSI command.
Here is a fix for this problem.
C:\Microchip Solutions v2010-10-19\Microchip\USB\MSD Device Driver\usb_function_msd.c
void MSDProcessCommandMediaPresent(void)
{
BYTE i;
switch(MSDCommandState)
{
...
...
// <--- comment MSD_PREVENT_ALLOW_MEDIUM_REMOVAL handler,
// so that this command fails with S_ILLEGAL_REQUEST Sense data
/*
case MSD_PREVENT_ALLOW_MEDIUM_REMOVAL:
if(LUNMediaDetect())
{
msd_csw.bCSWStatus=0x00;
msd_csw.dCSWDataResidue=0x00;
}
else
{
gblSenseData[LUN_INDEX].SenseKey=S_NOT_READY;
gblSenseData[LUN_INDEX].ASC=ASC_MEDIUM_NOT_PRESENT;
gblSenseData[LUN_INDEX].ASCQ=ASCQ_MEDIUM_NOT_PRESENT;
msd_csw.bCSWStatus=0x01;
}
MSDCommandState = MSD_COMMAND_WAIT;
break;
*/
Tsuneo
post edited by chinzei - 2010/12/26 06:37:18