Author Topic: MSD firmware under run error handling  (Read 9837 times)

nvd

  • Member
  • ***
  • Posts: 42
MSD firmware under run error handling
« on: June 27, 2012, 07:38:28 am »
Hi All,
 I am trying to write Firmware for mass storage device.
 I have this issue with the under run error.

 When Windows host sends READ(10) command, while copying data (512 bytes) to the TX buffer FIFO, an under run occurs.
 This probably means, Windows host sends IN packet for receiving CSW before the 512 bytes are copied to the TX buffer FIFO.

 I have tried to make the copy faster so that the TX buffer fifo is loaded before the CSW is requested, but i am not able to go beyond certain point.
 The under run is happening intermittently.
 When under run happens, host does not receive CSW and no further commands are sent by host.

 When under run occurs, I do not think the bulk IN endpoint should be stalled.

 One way that I could think of is to divide the 512 bytes packet in smaller chunks and provide the correct data residue value in CSW.
 Is this a right way to respond?
 
 What should be the way to handle this kind of situation in case of WRITE(10) command? (Here buffer over run would occur if data is not read from FIFO fast enough.)

 Can someone please provide suggest, how to go about handling these situations?
 
Regards,
nvd
 

Tsuneo

  • Frequent Contributor
  • ****
  • Posts: 145
Re: MSD firmware under run error handling
« Reply #1 on: June 30, 2012, 02:55:48 am »
Quote
When Windows host sends READ(10) command, while copying data (512 bytes) to the TX buffer FIFO, an under run occurs.
 This probably means, Windows host sends IN packet for receiving CSW before the 512 bytes are copied to the TX buffer FIFO.

Rather, doesn't the READ10 request more than one block (512 bytes)?
Examine TRANSFER LENGTH field of READ10.


Quote
What should be the way to handle this kind of situation in case of WRITE(10) command? (Here buffer over run
would occur if data is not read from FIFO fast enough.)

Overrun on the FIFO doesn't occur, thanking to NAK flow control.
While the FIFO is full, the device USB engine NAKs to more OUT transactions.
And then, the host repeats the last OUT transaction, until the device ACKs to it.

Tsuneo
« Last Edit: June 30, 2012, 03:10:58 am by Tsuneo »

nvd

  • Member
  • ***
  • Posts: 42
Re: MSD firmware under run error handling
« Reply #2 on: July 02, 2012, 12:18:41 am »
Thanks Tsuneo.

Quote
Rather, doesn't the READ10 request more than one block (512 bytes)? Examine TRANSFER LENGTH field of READ10.

More than one block can be requested by READ10.
I was talking about single block since I get underrun error even for one block data transfer.

Regards,
Nitin

Tsuneo

  • Frequent Contributor
  • ****
  • Posts: 145
Re: MSD firmware under run error handling
« Reply #3 on: July 02, 2012, 08:39:07 am »
Hmm..
I'm not sure what you mean by "FIFO under run".
Like above bulk OUT endpoint, bulk IN endpoint also has NAK flow control.
While bulk IN FIFO is empty, the device engine returns NAK to IN transaction.
And then, host repeats last IN transaction, until it gets ACK.
As host is waiting, you should not see any critical timing problem to send CSW.

Quote
I have tried to make the copy faster so that the TX buffer fifo is loaded before the CSW is requested

You may overwrite the DATA transport packet on the FIFO with CSW.
Monitor the USB traffic, to know what kind of packets your device sends.

Tsuneo