Author Topic: Regarding USB Mass Storage Device  (Read 60584 times)

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Regarding USB Mass Storage Device
« Reply #15 on: October 31, 2011, 11:21:08 am »
The bulk endpoint descriptors each have two wMaxPacketSize fields:

00   wMaxPacketSize
02   wMaxPacketSize

Allowed max packet sizes for full speed are 8, 16, 32, and 64. Use 64 if at all possible. High-speed bulk max packet size must be 512.

Jan

akanksha112

  • Member
  • ***
  • Posts: 31
Re: Regarding USB Mass Storage Device
« Reply #16 on: October 31, 2011, 02:53:14 pm »

Hi Jan
I did see that and was wondering too as to how is this possible.But I have no capacity to make any change as my Board just transarently passes the data between the HOST and the mass storage device. So i cannot alter the Wmaxpacket size.Whatever is sent is sent by the mass storage Device which goes via my FPGA through the PHYs to the HOST.

Also the WmaxPower ie the last byte of Config Descriptor
 once I got the value as 32 which is equivalent to 100 mA
and once I got the value FA  which is equivalent to 500 mA.
Now for 500mA , i vaguely remember having read it that after the device is configuredit draws a max of 500 mA current.
If you could please elaborate on this too.

Thanks for being such a patient listner and giving your valuable feedback.

Looking forward to your reply anxiously.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Regarding USB Mass Storage Device
« Reply #17 on: October 31, 2011, 03:02:42 pm »
Rereading this thread, I noticed that you say:

I am working on a USB 2.0 Bridge implementation using an FPGA such that any communication between the HOST and the USB Mass Storage Device happens via the USB Bridge.

What is the function of your Bridge? The USB spec assumes a single cable segment between the host and device (which may be a hub). If you're inserting circuits in the middle of the cable, have you considered the effect on the timing of the phases of the transactions?

Jan

akanksha112

  • Member
  • ***
  • Posts: 31
Re: Regarding USB Mass Storage Device
« Reply #18 on: November 01, 2011, 12:53:23 am »
Hi Jan

Yes I would like to elaborate on those points.

1. The bridge essentially just passes the packets between the HOST and the Device.I mean whatever is sent bythe HOSt is given through the PHY(at HOST side) to the FPGA and the FPGA transparently passes it to the other PHY(at the device side) to the device through the second ULPI interface.The transmission does happen through storage in some memory.this happens in such a way that whatever is recieved by one PHY is transmitted by the other PHY.

 For this we have considered the Timing specification as per the ULPI and USB timings.I mean we have the FPGA with a ULPI interface with the PHYs who in turn are connected to the two USB ports ie the HOST and the Device.

We have considered the response time such that for an IN packet from the HOST the device generates a NAK or an DATA within 24 clock cycles ie 192 bit times for HS device.
However there is no such timing constraint between two independent packets  ie NAK (of the first IN )and then the second IN packet. Please correct me if I am wrong.

Also the SETUP, the 11 byte device request reaching the HOST is ensured to have  24 clock interpacket delay at the device side.

2. I also wanted to know one thing ..If the communication is not able to meet timing specification , then it should not proceed with the enumeration.Right ?
I mean say for the first request Get Device Descriptor if it is not able to meet timing specifications then it should not be proceeding with the Set Address. Please throw light on this.I mean is it possible that the timings are not met and still the HOST continues with the enumeration process?

3. say for any control transfer if the status stage is completed successfully then does that ensure that the transfer was successful and timings were also met?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Regarding USB Mass Storage Device
« Reply #19 on: November 01, 2011, 10:25:16 am »
You are correct; there is no time limit between the transactions in control transfers, but the phases within a transaction must meet timing requirements.

The host and device should comply with the specification's timing requirements when sending data and likely will be a little more liberal than required when receiving data. In other words, if data arrives a little late according to the spec, the host or device may still accept the data. If the receiver of the data returns ACK, the data was accepted.

A control write transfer (where the host sends data in the Data stage or where there is no Data stage) completes successfully when the device has ACKed the data in the Data stage and sends a ZLP in the Status stage and the host responds with ACK.

A control read transfer (where the device sends data in the Data stage) completes successfully when the host has ACKed the data in the Data stage and sends a ZLP in the Status stage and the device responds with ACK.

The host can initiate other traffic to the device anytime after enumeration completes.

The double and suspicious values for wMaxPacketSize seem to indicate a problem in your link. Viewing the descriptors when the device is attached directly to a host would offer a clue.

Jan

akanksha112

  • Member
  • ***
  • Posts: 31
Re: Regarding USB Mass Storage Device
« Reply #20 on: November 01, 2011, 02:16:33 pm »
Hey Jan

Thanks so much for reverting.
I would look again into the endpoint descriptor again with another mass storage device and see if I find any change.I am waiting for Beagle Protocol Analyser to arrive.Till then I am reading up on things.

Its really very sweet of you to respond in such detail.You have no idea how happy I am.Thanks again!!!

Would keep you posted of any updates.

Akanksha

akanksha112

  • Member
  • ***
  • Posts: 31
Re: Regarding USB Mass Storage Device
« Reply #21 on: November 01, 2011, 03:15:05 pm »

Please let me know if there could be anything in the meanwhile I could tweak into .

Anything to do with the class specific requests.

akanksha112

  • Member
  • ***
  • Posts: 31
Re: Regarding USB Mass Storage Device
« Reply #22 on: November 02, 2011, 06:30:04 am »

Hi Jan

I probed again in the endpoint decriptors and found out that the value is not wrong.
As per the specifications
wMaxPacket size is a 2 byte value which is being sent from LSB byte to the MSB byte so a value of 00 followed by 02 actually means

wMaxPacket   00  LSB
wMaxPacket  02   mSB

ie 0200  now out of this the break up as per USB 2.0 spec is
Bits 15-13 are erserved and set to '0' Bits 12,11 = "00" means 1 transactionm per microframe
and bits 10-0 indicate the no of bytes transferred for bulk data and it comes out to 512 which is in accordance with the HS spec.
So this possibility of wrong wMaxpacket is ruled out.

I also wanted to know when would the device go into suspend state.Is it when the HOST stops sending SOF.

Under normal circumstances the SOF should be repeated every 125 us for HS.Right?

I am really stuck and do not know how to proceed.
       

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Regarding USB Mass Storage Device
« Reply #23 on: November 02, 2011, 11:19:52 am »
OK, that makes sense. Yes, the lack of SOF for 3 millisecs. means the host has suspended the device.

The protocol analyzer will be a big help. You will be able to compare what happens when the device connects directly to a host with what happens when your circuit is in between. Be sure to use very short cables when testing because you are already adding your circuit to the cable segment.

Jan

akanksha112

  • Member
  • ***
  • Posts: 31
Re: Regarding USB Mass Storage Device
« Reply #24 on: November 08, 2011, 12:51:31 pm »
Hi Jan

I finally got  a Beagle Protocol 480 Analyser and could make the following observations.
The sequence has a Get String Descriptor (marked in yellow background)  with the following data
28 03 4D 00 61 00 73 00 73 00 20 00 53 00 74 00 6F 00 72 00 61 00 67 00…

I am missing out on the last bytes of the descriptor(proabably they didnt get exported well), but they were exactly the same as that when obtained by direct connnection ie minus my circuit.(would anyways mail them to u in my next response as I dont have the analyser with me now)


 but it has correct CRC its a 40 byte string descriptor




However the In token followed by DATA is not acknowledged by the HOST.But when i had connected the host and the mass storage device directly, the data from the device was acknowledged withou any problem,


Also the host keeps sending vendor specific requests in between say after set address and say device descriptor.These requests too go unacknowledged.

I am attaching the excel sheet of the captured data with the problem areas highlighted in yellow.



Please if could tweak into something and help me out.

Also if you could tell me wht is exactly a Tiny J and why does tht occur.and when after 1 st dev descriptor the HOST issues a request what exactly happens??
I mean sequence of events.I just wanted to know if I am doing the right thing.I meant this in terms of electrical specifiactions of Vbus and pullup and terminations to accordingly make PHY settings.

Looking forward to ur reply



Akanksha

[attachment deleted by admin]

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Regarding USB Mass Storage Device
« Reply #25 on: November 08, 2011, 01:49:39 pm »
I haven't examined the data you uploaded, but as a general suggestion, now that you have an analyzer, compare the timing with and without your bridge attached.

If communications work OK without the bridge and the bridge doesn't change the data, timing is the natural place to look.

Jan

akanksha112

  • Member
  • ***
  • Posts: 31
Re: Regarding USB Mass Storage Device
« Reply #26 on: November 08, 2011, 01:55:47 pm »
Hi Jan

I know you must be really busy and timing is the thing I am already looking into, but if could please spare sometime to look into it.It would really help me.

Also if you could reply to my other queries ,whenever you get a little time, I had mentioned in my last post.

Also the strange part is if timing is the case then it should be the same for all the descriptors.However even Set Configuration is successfully happening.

That is what is further puzzling me .!!!!!


Akanksha

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Regarding USB Mass Storage Device
« Reply #27 on: November 09, 2011, 12:44:48 pm »
>Also the host keeps sending vendor specific requests in between say after set address and say device descriptor.These requests too go unacknowledged.

Are you sure they're vendor-specific requests and that they're directed to the mass-storage device?

>Also if you could tell me wht is exactly a Tiny J

Defined here:

http://www.totalphase.com/support/kb/10047/

>when after 1 st dev descriptor the HOST issues a request what exactly happens??
I mean sequence of events.I just wanted to know if I am doing the right thing.I meant this in terms of electrical specifiactions of Vbus and pullup and terminations to accordingly make PHY settings.

I have a description of enumeration here:

http://www.janaxelson.com/usbcenum.htm

If you want more detail, take a look at the USB spec.

Jan
« Last Edit: June 29, 2015, 10:28:42 am by Jan Axelson »

akanksha112

  • Member
  • ***
  • Posts: 31
Re: Regarding USB Mass Storage Device
« Reply #28 on: November 15, 2011, 04:58:15 am »
Hi Jan

I have been observing things closely but am yet to find out that trigger pointwhich could lead me to a  major clue.

I had some queries for which I wanted some pointers from you.

PART A - DIRECT Connection between the hOST and the device without my circuit.


1. Responding to Get Max LUN . Is the response device specific. By this I mean , a mass storage device successfully goes through all the stages of SETUP ,IN and OUT transcations.While the other one sends a STALL in response to the IN transaction(followed by Clear ENDPOINT feature). and the entire control transfer is repeated again. There is no data flow happening from the device to the HOST.


2. In other SCSI commands, say INQUIRY ,is it necessary that the device returns a NYET in the Command Transport Stage.I had two masss storage devices, one which returned and NYET and the other which returned an ACK.(this is without my circuit, direct connection between the host and the device through Beagle)



PART B   Connection between the HOST and the device through my circuit.




1. Could you please elaborate on the EXT packet ID . I did go through it in your book, but the book did not cover it in detail. Also what exactly is an LPM packet?
I am getting an EXT packet sometimes after Set Address(when I am connecting my circuit).But there is no LPM packet following it.


2. Regarding the vendor specific request, how do I know whether it is directed to the device or not.
I get the following

SETUP  --  2D / 01/ E8

DATA0    C3/40/B0/28/00/11/00/00/00/09/1B

After which there is no response from the device.
 PFA a snapshot of the same which might help you in looking at my query.


Looking forward to your reply.

Akanksha




[attachment deleted by admin]

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Regarding USB Mass Storage Device
« Reply #29 on: November 15, 2011, 01:17:05 pm »
1. See 3.2 in the Mass Storage Class Bulk-Only Transport spec from usb.org.

2. NYET means not ready. If the endpoint is ready, it returns ACK.

1. EXT is used in power management. See the Link Power Management addendum to the USB 2.0 specification. I would check to verify that that is what the host is actually sending.

2. See 8.4.1 in the USB 2.0 spec.

Jan