1

I am currently writing USB(EHCI) driver for pendrives in assembly for my OS. I can successfully get the Device-, String-, Configuration(Interface and Endpoint)-descriptors. However, the SCSI Inquiry and other commnads fail. This is what I do (after getMaxLUN):

  1. SetConfiguration(1)
  2. Inquiry

Another way:

  1. SetConfiguration(1)
  2. TestUnitReady
  3. RequestSense
  4. TestUnitReady

I correctly set the EndPt in the QueueHead (BulkIn or BulkOut) and the device-address. I am implementing the USB-driver by the book "B. D. Lunt - USB: The Universal Serial Bus". If I send Inquiry, this is what I get (return buffer, 36 bytes, hex):

01 00 00 00 01 00 00 00 80 0D 24 00

40 15 16 00 00 20 16 00 00 30 16 00

00 40 16 00 00 50 16 00 00 00 00 00

the 11th byte is 0x24, the length of the returned data (36). This looks garbage or an error message.

If I send TestUnitReady, then RequestSense returns (18 bytes, hex):

01 00 00 00 01 00 00 00 80 0D 12 00

C0 16 16 00 00 20

the 11th byte is 0x12, the length of the returned data (18). The contents of the two returned buffers are similar. The CBW of Inquiry and TestUnitReady look good (I use LUN=0). The SCSI-spec-4 says something about an incorrect logical-unit, if the result is not the expected one, but I have only LUN 0.

I am testing with a Sony 4GB pendrive. Inquiry should work immediately (return a correct data in the buffer) regardless of the CSW after it and I don't understand what the problem can be. I am experimenting with BulkReset and Clear_Feature(for BulkIn and BulkOut) but that doesn't seem to fix the Inquiry. The CSW of the TestUnitReady returns Status=01 but after a BulkReset and ClearFeature it returns Status=0 (success).

What can be the reason for the incorrect data in the buffer(s) ? Any help is appreciated.

EDIT: I tried it with delays too (100ms before sending CBWs, getting CSWs). It didn't help.

EDIT2: calling GetConfiguration() right after SetConfiguration(1), correctly returns 1.

EDIT3: This must be due to an incorrect pointer. I consider it solved.

rob
  • 21
  • 3

0 Answers0