2
\$\begingroup\$

There have been previous versions of this question that were closed since "there is no reason to create a one-off actual thumb drive", however, I have a very specific idea for a USB flash drive in mind.

I am getting married next year and I'm thinking of the save-the-dates in the form of a USB dongle. This would actually be a PCB with a USB plug that, when plugged in, flashes a few LEDs on the PCB and contains a multimedia file announcing the wedding date.

I figure I'll use a small microcontroller to control the LEDs. That part is easy and well within my skillset. I probably need a NAND chip and a controller for the flash drive part. Has anyone ever done this before? Any guidance would be appreciated, even just suggesting ICs to use, or a schematic to read over.

\$\endgroup\$
  • \$\begingroup\$ There are a lot of Arduino's that act like USB drives when plugged in, you could start there. \$\endgroup\$ – Ron Beyer Jul 28 '18 at 21:57
  • 1
    \$\begingroup\$ Just buy an EZ430-F2013 from TI. They are cheap (I've bought them from TI, on sale, for as little as $5 each) and you can do everything you want from there. You already have the USB connection, the ability to program it, a tiny add on board you can solder LEDs to, etc. \$\endgroup\$ – jonk Jul 28 '18 at 21:58
  • 2
    \$\begingroup\$ Oh, cool! You can probably add solar panel and WiFi transmitter to it too. And built-in blender for wedding drinks, while you at it. \$\endgroup\$ – Maple Jul 28 '18 at 21:58
  • 1
    \$\begingroup\$ Plugging in random gimmicky USB drives is risky practice which should not be encouraged. You'd do better to make something stand alone. Also a typical MCU may not have the bandwidth to transfer "a multimedia file" unless it is highly compressed or you mean something like audio alone, which again you could do stand alone. If you really wanted to do what you proposed despite it being a bad user practice, the easiest method would probably be to add additional non-communicating LED circuitry in parallel with the guts of a cheap USB drive, and re-package it. \$\endgroup\$ – Chris Stratton Jul 28 '18 at 22:02
  • 1
    \$\begingroup\$ Duplicating a flash drive is not viable. You won't be able to buy the parts, and even if you could you're not in a position to design the board or assemble them. Just take cheap ones apart to re-use, tapping into VBus and Ground. Getting the add-on circuit compact will be a challenge itself, though you might use self-flashing LEDs and fine wire. \$\endgroup\$ – Chris Stratton Jul 28 '18 at 22:20
3
\$\begingroup\$

USB flash drive is a bridge between USB and NAND/eMMC. To make this to work you need to implement Mass Storage Class device, create all necessary endpoints and descriptors, and map them into emmc controller space, provide proper data buffering and format translation. Usually the bridge is done on MCU basis, and the program to do this mapping might contain thousands lines of C++ code. To implement the right descriptor structures you will need probably a year of study of MSC class formats and NAND handling/formatting. Creating a flash drive from scratch is a several man-years project for professionals with proper background. Just forget it.

But if you want just to have some flashing LEDs, there are ICs that do the MS-Class bridge and have the LED activity by default, something like USB2240. Or there is a more complex IC with extra I2C port in addition to SD/eMMC interface, USB2640, where you should be able to hook up an I2C expander and flash several LEDs as you wish.

\$\endgroup\$
  • \$\begingroup\$ Honestly that USB2240 chip seems like just the right thing. If I'm reading that correctly, I can use it to interface with a uSD card, which was another thought I had. That would be more than enough storage for what I have in mind, and I can tap in to the 5V USB power for the light show run by an AtTiny or something. Thanks! \$\endgroup\$ – Ben S. Jul 28 '18 at 23:52
  • \$\begingroup\$ @BenS., yes, the uSD is a straightforward application. They have all eval boards available, sample schematics, and layout examples. But why then don't take a normal cheap flash drive, and attach you AtTiny on the top to its power? It will be much more cost-time effective approach... \$\endgroup\$ – Ale..chenski Jul 29 '18 at 0:12
  • \$\begingroup\$ This is substantially misleading on two fronts. First, practical implementations of actual USB flash drives do not pass the data through an MCU core - MCU's are far too slow for that, it follows dedicated data paths with a CPU only there for management. Next, implementing "low performance" mass storage backed by some tiny memory is not that difficult, it's available as a turn-key demo project for many USB device stacks.. \$\endgroup\$ – Chris Stratton Jul 29 '18 at 3:20
  • \$\begingroup\$ I would however agree on using a dedicated chip intended for this in principle, except that it's unlikely the asker will be able to reasonably build around that - pulling boards out of existing drives is what is realistic. \$\endgroup\$ – Chris Stratton Jul 29 '18 at 3:29
0
\$\begingroup\$

I think it's very doable if you choose the right parts and constrain your media file size to something reasonable. A video will probably be out, but a nice picture announcing the date would work.

There are libraries available that perform the translation of commands to flash memory actions. For Atmel chips, there is LUFA, which has generic drivers for many applications, Mass Storage being one of them. There's an example application on Github. This example assumes you use Atmel's DataFlash chips, but you could write your own translation to generic SPI flash or use a mmc/sd over SPI stack if your need more memory. I personally found LUFA easy to get into for beginners, but of course you could look into chips with native SDIO like stm32f4 if you need the space.

It certainly won't have super great performance, but it'll be cool, because you made all of it.

\$\endgroup\$
  • \$\begingroup\$ Could you offer an estimate for the effort to create such a project, even if the library exists? \$\endgroup\$ – Ale..chenski Jul 29 '18 at 2:57
  • \$\begingroup\$ @AliChen it's basically available as a demo project for some of these codebases, ie, turnkey. However performance would be horrible. \$\endgroup\$ – Chris Stratton Jul 29 '18 at 3:19

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.