MrLolthe1st wrote:
i'm developing MassStorage driver. So, on QEMU my two(Read10 and ReadCapacity10) functions work fine.
On real hardware after sending readCapcity10 command, my driver tries to read 8 bytes. But data never comes to driver, when i'm detach my USB stick from PC, host controller successfully performs all driver requests and returns to driver some random data.
Many things could be going on here.
1) Many USB drives may and usually expect the Identify command before you get the capacity or read from the drive.
2) Some USB drives may and usually expect a Test Unit Ready command before you get the capacity or read from the drive.
3) Few USB drives may and usually expect a Sense Request command before you read from the drive, though allowing you to get the Capacity before hand.
As stated before in previous posts, unfortunately, many manufacturers test their drives on one or two of the major operating systems and if it works on those, they consider the test complete and successful. However, those OSes, namely one in particular, does a certain sequence of requests in a specific order. The manufacturer of the drive expects this specific order. It saves on the testing phase of the manufacturing process.
I have found that most drives work if I:
1) Identify the drive
2) Get Capacity
3) always assume that the first Get Capacity request will fail.
4) Test Unit Ready before each request thereafter
As for the controller sending bogus data after you disconnect the drive:
1) this could be the EHCI controller giving up control of the port to the companion controller (UHCI) and your UHCI driver/code is taking over
2) the EHCI firing an interrupt due to the disconnect (port status change) and your code assuming it is a completion interrupt
3) many different things could be going on.
Granted, I have not worked on my USB book non-stop, but I started it in 1994. It is now 24 years later and I am still finding issues and quirks with devices and what not, having to arrange my requests in a certain sequence to accommodate a broader range of devices.
It takes time and work. Don't give up.
Ben
-
http://www.fysnet.net/the_universal_serial_bus.htm