5
\$\begingroup\$

I am wondering if it possible to create a USB device (in following the device) composed from

  • a custom circuit (eg arduino) and
  • a flash storage

in such a manner that the device is recognized as a standard usb flash storage (and as such is operable with standart OS drivers), while said storage holds the utilities to operate with the custom circuit (dispalying the data colled by the circuit); and if so, how?

My first thought was to smack a cheap usb-hub and usb-pen before my circuit but that solution, is not pleasing to me.

My goal is to eliminate the need to carry an extra flash-drive just for the operating software, and use default os drivers, make it plug-and-just-work:

  1. i plug the device in
  2. the os (windows) mounts a new flash-drive without needing a special driver
  3. is start (manually or via autorun) my custom.exe from that flash-drive
  4. i recive data measured by the circuit
\$\endgroup\$
  • \$\begingroup\$ The answer is "yes, it is possible" :-) but we need a little more informations to give a meaningful answer. (I have some NETMF board that works that way with its internal microSD card) \$\endgroup\$ – Axeman Aug 30 '12 at 13:04
  • \$\begingroup\$ well as this is my first serious engineering project apart from beginner-level stuff like pseudo-random-generator and analog-digital-convertors i am open for every advice. \$\endgroup\$ – Valerij Aug 30 '12 at 13:08
  • 1
    \$\begingroup\$ I think you'll find that any microprocessor that has a USB device interface built in has example code that does exactly what you are asking for. \$\endgroup\$ – Dave Tweed Aug 30 '12 at 13:29
  • \$\begingroup\$ @DaveTweed could you link some examples? \$\endgroup\$ – Valerij Aug 30 '12 at 13:41
  • \$\begingroup\$ @Vprimachenko: Atmega32U4 has USB 2.0 device (this IC is used in Arduino Leonardo... since you mentioned Arduino) \$\endgroup\$ – boardbite Aug 30 '12 at 14:45
3
\$\begingroup\$

Your first step is to find a USB microcontroller that has all the peripherals you need to accomplish your task.

The second step is to correctly set up your USB descriptors. The descriptors will tell the PC that your device is a composite device. I have not seen very much support for multiple configurations. So you will need one configuration descriptor.

Typically, composite devices are described by using multiple interface descriptors. So your one config descriptor will say it has 2 interface descriptors. The first interface descriptor will be for your Mass Storage Device. The second interface descriptor will be your custom interface.

EDIT: here's a couple links that might help you out with the descriptors. The USB Generic Parent Driver is what Windows uses to enumerate composite devices. Lots of good stuff here. http://msdn.microsoft.com/en-us/library/windows/hardware/ff539234%28v=vs.85%29.aspx

Here's a link to an Atmel app note which shows an example of a composite device. http://www.atmel.com/images/doc7805.pdf

Microchip has a free USB stack for their microcontrollers. It also contains examples for composite devices. Unfortunately, the link to the Microchip examples is the type that will likely change over the course of time, so your best bet is to google "Microchip Application Libraries"


With that said, you probably don't need a custom interface. If you're just passing around bytes, you can use standard HID drivers to transport your data to and from the device, no custom drivers necessary. However, host-side software will be required to use the OS-specified interface for reading/writing HID reports (in the case of Windows, this is usually ReadFile and WriteFile from the Windows API)

\$\endgroup\$
  • \$\begingroup\$ He can't use a HID device if OP wants to run 'custom.exe' from the device. OP'll need to use Mass Storage. \$\endgroup\$ – dext0rb Aug 30 '12 at 16:02
  • \$\begingroup\$ He can still do a composite HID/MSD, no need for a custom driver. \$\endgroup\$ – ajs410 Aug 30 '12 at 16:03
  • \$\begingroup\$ i was tending to use Teensy2 and i found this elasticsheep.com/2010/04/… so i aussume my custom.exe just need to issue commands not contained in CBW or CSW sets? \$\endgroup\$ – Valerij Aug 30 '12 at 16:21
  • 1
    \$\begingroup\$ Your custom.exe would have nothing to do with Mass Storage Device. It should use HID interface instead. See Jan Axelson's HID FAQ for some tips. lvr.com/hidfaq.htm \$\endgroup\$ – ajs410 Aug 30 '12 at 16:33
  • \$\begingroup\$ Jan Axelson's site is fantastic. I also highly recommend owning a copy of her book, "USB Complete" for anybody entering this domain. It's a fantastic quickstarter. \$\endgroup\$ – Scott Seidman Aug 30 '12 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.