Adding Mass Storage Support to Leonardo

Currently the Leonardo has a, what I think is called, a composite USB definition.

It is a serial port (I think it is called a CDC)
It is a Mouse (HID)
It is a Keyboard (HID)

I think that is all but there may be more.

I would also like to add a mass storage ability.

I am thinking about creating a device to log data. I would write this data to an SD card. I would like to be able to read this data from the SD card as though it was a "thumb drive".

I know that I could take the SD card out of my device and load it into my computer and read the data like that. If I do that then the device could not be logging data. I could buffer the data but as we know, Arduinos have VERY little ram.

If I change change log files from time to time then I should be able to move (copy and delete) older log file from the device without interrupting the logging process.

This may be too much to ask of an Arduino and a Raspberry Pi or Beagle would be a better platform. The Arduino is just Simple, Small, and Cheap Affordable. So I would like to use a Leonardo.

If I change change log files from time to time then I should be able to move (copy and delete) older log file from the device without interrupting the logging process.

This will not be possible. When a PC or Mac host accesses a USB drive, it assumes the drive is a simple block device and the host has total control. This means you can not modify the SD while the host accesses the SD.

Several people have done mass storage experiment with a ATMEGA32U4. See this old link. This just provides a very complicated and very slow SD to USB adapter.

Use LUFA lib

or V-USB (USB flash on atmega8)