Author Topic: reset mass storage device during bulk trasnfer  (Read 11920 times)

naorg

  • Member
  • ***
  • Posts: 1
reset mass storage device during bulk trasnfer
« on: September 22, 2014, 08:44:17 am »
Hi,

I have a mass storage device connected to hub. I need to reset the device and re-enumerate it while the device processes bulk transfer.
I can't stop the bulk transfer (since i'm not the one who initiates it).
The problem is that the mass storage device does not answer to control requests after the reset.
This happens with any mass storage device.
What can I do using control transfers sent to hub or the device in order to solve this ?

thanks for taking time to answer my question.
naorg.

Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
Re: reset mass storage device during bulk trasnfer
« Reply #1 on: September 23, 2014, 02:36:05 pm »
Are you the host or the device, and which direction is the transfer? Most transfers can be stopped, and if you can't stop it, you can just receive the data and discard it.

The sender of the data can always send a zero length packet to terminate the transfer. The device can terminate a transfer the host is sending it by returning a STALL handshake. If the host wants to terminate a bulk transfer it initiated, that's bad, hosts are supposed to know what they're doing and not change their mind like that.

If that's your problem the best thing to do would be to fix your logic so you don't get into that situation. Failing that, you could just accept the data and discard it.

A bulk only device should respond to a Mass storage reset and go back to the accepting CBW state. If your mass storage device doesn't accept that (and I wouldn't be surprised if it did), a port reset is your next step.  Your best option is to not get into this circumstance in the first place though.

Bret

  • Frequent Contributor
  • ****
  • Posts: 68
Re: reset mass storage device during bulk trasnfer
« Reply #2 on: September 24, 2014, 12:35:09 pm »
I need to reset the device and re-enumerate it

To reset a device so that it can re-enumerate, you send a control request to the hub the device is attached to, not the device itself.  This should have approximately the same overall effect as physically unplugging and reinserting the device from the hub port.  And, it won't respond to any requests until it has been successfully re-enumerated.

The problem you're going to have with your scenario (resetting/unplugging a device in the middle of a data transfer) is that your file system (on either the host or device or both) is most likely going to get corrupted.  You really need to figure out a way to coordinate what you're doing with whatever is transferring the data -- you can't have the two processes completely isolated without some form of cooperation between them.