Electronic – Solutions for implementing a USB Mass Storage Device

usb device

I'm trying to figure out a convenient way with which a PC can configure an embedded system. The PC will have a custom app. written that can 'talk' to the embedded uC and configure the various settings and upload some data to it (~ 500 KB). The advantage of this approach is it's simplicity.

My initial thought was to go with a UART to USB bridge and take it from there. However, I'm now considering implementing a usb mass storage device instead. The advantage is that the end-user can simply drag and drop a file which contains the data and the configuration settings. The board will have a flash memory IC of appropriate size mounted on it. The uC will be a low-end STM32 (I have not decided on a specific chip yet).

Since the file will have to be in a specific format for the embedded system, I believe I'll still have to write a custom app. for the PC to write that file from the settings provided by the end-user. This isn't overly difficult.

But what I'm confused about is, how do I mount the flash memory as a FAT disk on the PC? Are there any integrated solutions – perhaps a flash memory which talks to USB directly?

NOTE: I know about LUFA for the AVR. However, I'm not yet sure if I'll be able to use an AVR as I also have to drive a 800×400 RGB display. As a test, I did drive the display using an AVR running at 8 MHz. The update rate was slower than I'd like.

Best Answer

Lookup forebrain code examples, they use NXP LPC1343 chip that has USB mass storage drivers in ROM (so you can program the chip via drag and drop). Forebrain have example where they use internal ROM driver to present an EEPROM chip or simply just piece of RAM as mass storage device. They are closed source, but this gives the idea of how it could be implemented.

In general, you have to implement specific USB mass storage driver hooks.

There is no need to make config file in any special format as you could implement FAT system on your chip so it accesses flash memory as FAT filesystem. You can lookup any SD card reading/writing example for popular microcontrollers - some use low level, some implement FAT. Particulary - this one for LPC1343 implements FAT over SD card: https://github.com/Miceuz/LPC1343CodeBase/tree/master/drivers/fatfs

BTW, have you considered an option to put configuration into a file on SD card? You would have loads of ready made code and examples for broad range of MCUs for that. Config process would involve extracting SD card from device and putting it into computer though.

Related Topic