wrote:
> I'm getting stuck trying to figure out how to recover from a
> USB mass storage "error". This is for "bulk only" protocol.
> The root problem is that the RTOS we use is returning errors
> when they don't really exist and terminating transfers in
> the middle. I think I can fix that problem, but in the
> meantime I was trying to add some error checking and
> recovery to their mass storage driver. I'd also like to be
> able to recover from real errors if they ever happen.
>
> What happens is that the CBW command bytes are sent
> successfully, then the data phase is interrupted mid-stream.
> When the host ignores the error and tries to read the CSW
> status it hangs forever.
>
> My first approach was to detect the error and return from
> the transfer routine without reading the CSW. But the very
> next I/O operation will fail. I then tried doing doing a
> "bulk-only mass storage reset" operation, but that I/O also
> hangs. I then tried first clearing stalled endpoints out of
> desparation, and then doing the reset, but that didn't help.
>
> So now I'm baffled. What I think is happening is that the
> mass storage devices are still waiting to read bytes from
> the data phase, and can not leave that state even if they
> see bytes on the control endpoint.
>
> Is there anything I can do to clear this stuck state?
>
> --
> Darin Johnson
Here is the procedure for clearing faults on a bulk storage transfer
that we are using in our project. Hope this helps.
The following are the steps I take during a bulk transport:
1. Send the CSW. If the pipe stalls, clear the stall and go to the
transport stage.
If the clear stall fails, or the original result was some other
error, perform
a Bulk Reset and exit the transport routine.
2. Send/receive data. If the pipe stalls, clear it and go to the read
CSW stage.
If the clear stall fails, or the original result was some other
error, perform
a Bulk Reset and exit the transport routine. Do not try to read
the CSW.
3. Read the CSW. If the pipe stalls, clear it and try to reread the
CSW.
If the clear stall fails, some other error occurs, or the CSW
is
invalid,
perform a Bulk Reset.
On all of the steps above, if the Bulk Reset fails, the HC or device is
not working properly. If other devices ARE working properly (or if it
can be verified that the HC is functioning properly), assume the device
is corrupt and ignore it. Otherwise try a hardware reset.