Author Topic: Handshake in Mass Storage Mode  (Read 17193 times)

egovind

  • Member
  • ***
  • Posts: 14
Handshake in Mass Storage Mode
« on: December 06, 2013, 11:34:30 am »
Another question :) We have an embedded device that acts as a MSD Host that connects to one of our client's devices that can act as an MSD device. Because of some technical reasons, we need to do some custom handshaking between the two devices. Is it possible to establish some communication channel along with the MSD channel? I don't have much data to send, just a couple of commands of 20 bytes or so back and forth.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Handshake in Mass Storage Mode
« Reply #1 on: December 06, 2013, 12:02:57 pm »
If you can program both the host and device firmware, you could add a HID interface for this. 

http://www.lvr.com/hidpage.htm

Other than that, maybe reading and writing to a file in the MSD?

Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
Re: Handshake in Mass Storage Mode
« Reply #2 on: December 06, 2013, 02:10:31 pm »
How about some vendor specific SETUP commands?

Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
Re: Handshake in Mass Storage Mode
« Reply #3 on: December 06, 2013, 02:15:29 pm »
I'll also add, I've added out of band communications with a Mass Storage device by using both vendor specific SETUP commands and also vendor specific SCSI commands.

In either one you have to add custom code you both your host and device. The SETUP command is easier to add.

egovind

  • Member
  • ***
  • Posts: 14
Re: Handshake in Mass Storage Mode
« Reply #4 on: December 07, 2013, 01:27:34 am »
Thanks for the responses! I checked with the developer at the client side, and he does not want to add HID (host or device), so the only option is to work within MSD. He is open to customize the MSD stack as long as it's not too complicated. So I will have a look at the SETUP commands option.

Writing files to communicate should be OK, but I'm worried if there will be issues regarding arbitration of the memory. Wouldn't there be problems at the device end if he allows the memory to be read/written by the host(me) and also simultaneously tries to read/write files into his memory? Maybe we can think of a protocol to avoid conflicts though..

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Handshake in Mass Storage Mode
« Reply #5 on: December 07, 2013, 11:17:52 am »
Yes, one way is to use UNIT ATTENTION and REQUEST SENSE to signal that the media is unavailable.

Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
Re: Handshake in Mass Storage Mode
« Reply #6 on: December 07, 2013, 10:58:03 pm »
I've shared files between host and device before now. There needs to be some arbitration so that one end of the other has exclusive use of the media at a time.

You can do this with the Spin up/down state of the media or the load/eject status, either uses the Start/Stop unit command to change the state. When stopped or ejected, the media is available to the device. A Start/Stop unit with LoEj or Start set is the signal that the host wants the media. A Start/Stop unit with the LoEj or Start not set is the signal that the device can have the media back.

Also the host should flush any caches before "ejecting" or stopping the media.