-   Programming (
-   -   Help with USB storage program and USB 3.0 (

Equinn 01-25-2011 01:08 PM

Help with USB storage program and USB 3.0
OK, I admit I'm a newbie at this - especially the linux part. I have inherited a USB storage program that tests USB hard disk drives. Up to now, I have been successful at making updates to the code when needed because accessing the USB device has never been a problem.

First, I am running Slackware 12.1.0 with Linux Kernel

The program basically monitors the USB devices via /proc/bus/usb/devices and when there's a new device, checks to see if the vendor ID is one it should test. If so, the first thing it does is go out and do a read capacity via the usb_bulk_write (eventually), which I assume is in the usb library located in /usr/include (please verify). I know that usb.h is in the includes in the usb_storage.c that is part of the program code.

Anyway, this has always worked on USB 2.0 devices, but now that I have a USB 3.0 device, it errors out at the usb_bulk_write command (return code is 31). I was under the impression that USB 3.0 was backward compatible. Also, if I just plug in the drive without running my program, the system sees it just fine. I am just plugging the USB 3.0 device into a USB 2.0 bus.

I am kind of at a loss as to what would be causing this. Seems to me if it worked on USB 2.0, it would work on 3.0. Any ideas would be appreciated.


Equinn 01-26-2011 04:46 PM

Guys and Gals,

I have done some more digging around and have more information. This program is using libusb v0.1.12. Also, I made a mistake in my statement above. It's not failing at usb_bulk_write (the return code from that is 31, which is the correct number of bytes transferred). It's actually failing on the subsequent usb_bulk_read. It's supposed to return 8 bytes and its returning 0.

After some searching on the net, I found some information on libusb. I found there is a bit of test software that's distributed with libusb that identifies information about the devices attached to the bus. I ran this little test on both types of drives and found that there are some differences.


USB 2.0 Drive
bmAttributes = c0h
MaxPower = 1
bInterval = 0

USB 3.0 Drive
bmAttributes = 80h
MaxPower = 200
bInterval = 20
All of the other information was the same between the two drives. I'm wondering if any of these things are used by usb_bulk_read. I'm off to do more digging, but hopefully this will spark some thoughts on this and help me get there a little faster.


All times are GMT -5. The time now is 01:31 PM.