Author Topic: Windoze MSD interface behaviour -pretend SD card removed/inserted  (Read 18284 times)

oldnick

  • Member
  • ***
  • Posts: 3
Apologies if this has already been covered, but I did a quick search and couldn't find it.

I have a working MSD device, but have a use case that is giving me difficulty.
 
When I plug the device into the PC, I want to keep the PC host off my back until I have saved the current settings of the instrument to the SD card before disabling the embedded FAT control and handing control of the SD card over to the SCSI block protocol.
 
Page 162 of USB Mass Storage complete suggests a method – that is to “pretend” the SD card is not inserted until we are ready to let the PC host have access to it.
 
But once we send a valid response to the device format capacity request, the PC never sends inquiries, it jumps straight to reading block 0.

Any suggestions appreciated.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Windoze MSD interface behaviour -pretend SD card removed/inserted
« Reply #1 on: June 26, 2013, 12:51:50 pm »
Is the Windows behavior causing a problem (if so, what?), or is it just not what you expect?

Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
Re: Windoze MSD interface behaviour -pretend SD card removed/inserted
« Reply #2 on: June 26, 2013, 03:25:39 pm »
Do you get test unit ready commands? What's your response to that?

I'd expect to get a TUR command which you fail. Your sense would be not ready, no media. If the hosts go direct to reads or any other media access command, you can also fail those, then your sense would again be not ready, no media.

You can also give a sense of not ready, media becoming ready, if you expect to be done in the near future. Did you ever get an Inquiry? That's where you tell the host you're a removable device (via the RMB bit). Even if you haven't told the host you have removable media, you can still fail commands with a sense of media becoming ready.

My devices have used the removable media approach to all this and they work with Windows.

oldnick

  • Member
  • ***
  • Posts: 3
Re: Windoze MSD interface behaviour -pretend SD card removed/inserted
« Reply #3 on: June 27, 2013, 08:05:59 am »
Do you get test unit ready commands? What's your response to that?

I'd expect to get a TUR command which you fail. Your sense would be not ready, no media. If the hosts go direct to reads or any other media access command, you can also fail those, then your sense would again be not ready, no media.

You can also give a sense of not ready, media becoming ready, if you expect to be done in the near future. Did you ever get an Inquiry? That's where you tell the host you're a removable device (via the RMB bit). Even if you haven't told the host you have removable media, you can still fail commands with a sense of media becoming ready.

My devices have used the removable media approach to all this and they work with Windows.
Barry,
thanks for the help here.  Removable media bit is set, and Inquiry commands are handled correctly.
We learnt this morning that you have to fail the device format capacity request to force the Host to send TUR's.
I know, its all there in the book, (Thanks Jan) but we missed that detail yesterday!

Now the host->device interaction begins to look sensible.

But, when we are finally ready to let the host see the drive, it doesn't want to look.

Attached transactions distilled from our USB sniffer


[attachment deleted by admin]

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Windoze MSD interface behaviour -pretend SD card removed/inserted
« Reply #4 on: June 27, 2013, 04:54:10 pm »
Windows isn't liking the response to READ CAPACITY. Can you get the command working at all? Monitor the response to the command on other devices for clues.

Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
Re: Windoze MSD interface behaviour -pretend SD card removed/inserted
« Reply #5 on: June 29, 2013, 09:35:54 pm »
It sounds like Read Format Capacities is a media access command. Which is sensible as if you don't have media, there's no capacity to read.

oldnick

  • Member
  • ***
  • Posts: 3
Re: Windoze MSD interface behaviour -pretend SD card removed/inserted
« Reply #6 on: July 01, 2013, 07:37:25 am »
Windows isn't liking the response to READ CAPACITY. Can you get the command working at all? Monitor the response to the command on other devices for clues.
You nailed it!  Thanks :)

The response to READ CAPACITY was missing the logical block address and the block size. It is working correctly now.

All we have to do now is to figure out how to give control of the SD card back to the embedded code when we unplug the cable.  Heigh-ho, and on we go!

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Windoze MSD interface behaviour -pretend SD card removed/inserted
« Reply #7 on: July 01, 2013, 09:32:15 am »
Good news!