Gadgeteer as USB Device/Drive

Hi everyone,

This may be a silly question, but I was wondering if it’s possible to have a Gadgeteer device appear as a USB drive when plugged into a PC. For example, if I attach a SD Card/Card Reader to a main board; then, plug the main board into a PC using a USB cable; can I have the PC mount the Gadgeteer’s SD card as a USB Drive? I was interested in using this technique to share files between the PC and the Gadgeteer.

The full use case is something like:

  1. Plug Gadget into PC
  2. Periodically, PC writes data to Gadget’s SD Card
  3. Gadget notices file creation/written, picks up file and sends contents of file to a well-known web service; deletes file upon completion.

The mirror image is also something I’m interested in.

  1. Plug Gadget into PC
  2. Periodically, Gadget receives a web service call and writes the contents of the call to its SD Card.
  3. PC is able to access content of SD Card

Long story short, I’m trying to enable web service support for some really ancient computing platforms; and Gadgeteer seems like a pretty attractive, low-cost, option.

It’s possible (at least for Premium boards, not sure about OSHW).
But you can not use USB-Drive mode to SD and access SD from gadgeteer app at the same time.
This topic was discussed several times in the forum.

You need to choose a device with USBHost support, thats all.

Sample code in the tutorial section:

https://www.ghielectronics.com/docs/36/usb-host

With USB Client however you can’t access the SD file system while the device is being used as a mass storage device on the PC.

Thanks to everyone for the pointers! It looks like this topic is pretty well covered - at least the mass storage device portion.

One thing I was wondering… Can you partition a SD card into 2 LUNs and only present one LUN to the host? Meanwhile, access the second LUN from within the Gadget?

I was wondering if I could have LUN1 enabled for most of the time; periodically disable it and move the contents to LUN2; then, re-enable it.

I wondered if the same trick would work with a FLASH module acting as LUN2; or a USB drive plugged into the gadget.

No, you can’t partition and expose different LUNs. The entire drive will be visible to the Pc. You can however do this with a usb drive plugged in acting as LUN2.

Or you could go super advanced and implement a Virtual Massstorage device than handles requests to the SD card (all low level programming of course). So that you can still access the SD while providing mass storage access. Data corruption is likely.