R – USB drive LED flash

embeddedhardwareledusb

I was recently reading about the Arduino's Hello World application, and I thought to myself, "I wonder if I can do that with hardware that I have right now."

Since I don't have an Arduino, I grabbed a usb flash drive that I had laying around and started googling around for information about it. I didn't find much helpful information in this area, so I'm now asking here: is it possible for me to access a USB drive's hardware (e.g. the LED) and interact with it via some programming environment (I was thinking C# should probably have some way to do this)?

Also, related to this subject – does anyone know what kind of commands USB drives use? For example, SCSI storage devices have a standardized command set; ATA devices have a similar protocol. How are things like simple read/write commands issued to a USB storage device?

Best Answer

While the USB protocol is fairly generic, the peripheral devices are really function specific and require some kind of device driver on the host to function properly.

While a USB Flash Drive has a micro-controller on it, most USB storage devices follow a common protocol. That is why you don't have to install a different device driver for every drive you plug into windows.

I'm pretty sure that the mass storage protocol does not have a "Turn LED on" message :) And while the company that implemented the USB drive might actually have a special command to do that (maybe for debugging), I would doubt it would be published.

While I'm no guru on Windows, I believe that in order for you to access the USB stack directly, you would have to write your own device driver and plug load it in the kernel. Can you imagine if a regular application could send the "format everything" command to an arbitrary USB device.

Related Topic