Ports
May 22, 2013, 11:27:03 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed!
 
   Home   Help Search Login Register  
Welcome to the PORTS Forum. Please post your questions, answers, and comments relating to USB and other hardware interfaces in the appropriate forums below. - Jan
Pages: [1]
  Print  
Author Topic: MSD firmware under run error handling  (Read 801 times)
nvd
Member
***
Posts: 42


« on: June 27, 2012, 06: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
 
Logged
Tsuneo
Frequent Contributor
****
Posts: 76


« Reply #1 on: June 30, 2012, 01: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, 02:10:58 am by Tsuneo » Logged
nvd
Member
***
Posts: 42


« Reply #2 on: July 01, 2012, 11:18:41 pm »

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
Logged
Tsuneo
Frequent Contributor
****
Posts: 76


« Reply #3 on: July 02, 2012, 07: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
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!