Hello, If I mount a USB device on a windows machine, can the device in any reliable way create files so that they appear on the windows explorer? I know the device is mounted on Windows so that Windows should be the one to determine the contents. But is it possible or is this a clear violation of the rules? what happens if the device creates a file, resets itself (assuming it can do that by control over the data lines) to force reenumeration? will Windows see the new file?
Check Keil Samples. It's already there. Look for USB Mass Storage. To "notify" Windows that a modified file is available, try a Soft Dis/Connect Sequence
thanks. I already found it - using an LPC2478. I hope I get it to work...
Ulrich, I had a quick look in the data sheet of the LPC2478. Am I correct in assuming that a hardware change is necessary in order to allow "softconnect" to work (namely, an external resistor) ?
Windows caches directory and FAT on its side. When the device alters these blocks on the media without intervention of Windows, mismatch occurs. Windows will take this mismatch as disk error. When the device touches to media, unmount the media first.
Emulate SD card reader response for media exchange.
Just after enumeration, Windows put several SCSI commands to know about the media. In this sequence, respond to the command as follows.
INQUIRY - return RMB = 1 (removable)
PREVENT ALLOW MEDIA REMOVAL - when PREVENT = 00, success this command. when PREVENT = 01, fail it
With this response, Windows doesn't make write cache. It prevents disorder caused by unmount.
To unmount the media, Windows put TEST UNIT READY every 1 sec. Fail this command while unmounted. To REQUEST SENSE just after this TEST UNIT READY, return this sense data
Status = CHECK CONDITION Sense Key = NOT READY (0x02) Additional Sense Code = MEDIUM NOT PRESENT (ASC: 0x3A, ASCQ: 0x00)
While unmounted, fail any other SCSI commands, and return above
After the operation of device side finishes, re-mount the media - respond to SCSI commands as usual.
Tsuneo
thanks. I am going to try this.
Tsuneo,
which byte in the reply for REQUEST SENSE needs to be set in order to have Status = CHECK CONDITION ? Which numerical code is it?
And could you please tell me what the format of the reply to PREVENT ALLOW MEDIA REMOVAL should be?
Ulrich, I think we have a problem with the hardware here, but anyway: are you saying the using the USB_Connect function should force a re-enumeration? I cannot tell as our hardware is probably at fault...
"which byte in the reply for REQUEST SENSE needs to be set in order to have Status = CHECK CONDITION ?"
Please ignore it - it make sense just for SCSI device server. For MSC-BOT, It means TEST UNIT READY command returns fail in its CSW.
"And could you please tell me what the format of the reply to PREVENT ALLOW MEDIA REMOVAL should be?"
PREVENT_ALLOW_MEDIUM_REMOVAL spc3r23.pdf(p184)
Recently, T10.org restricted the access to the draft SCSI specs. You can still download them from these T11 links, but it will be also closed sooner or later. www.t11.org/.../spc3r23.pdf www.t11.org/.../sbc2r16.pdf www.t11.org/.../mmc3r10.pdf
Tsuneo, thanks a lot for your help. I'll take it from here.
I am sorry to bother you again but I am having some trouble here...when I try to do this
case SCSI_MEDIA_REMOVAL: if ( (BulkBuf[4] & 3) == 0) { CSW.bStatus = CSW_CMD_PASSED; MSC_SetCSW(); } else if ( (BulkBuf[4] & 3) == 1) { goto fail; }
I cannot write to the device anymore. I guess I'm doing something wrong in passing the command, because failing it is the default behavior and it works. The RMB bit is set to 1. What am I doing wrong here?
Tsuneo, I have one small question left. If I have a device with an HID interface and a MSC interface, how can I prevent the MSC part to be mapped to a windows drive unless an HID report of some kind comes in?