Mark Butcher

FAT Emulation

Discussion created by Mark Butcher on Oct 29, 2015
Latest reply on Nov 6, 2015 by Mark Butcher

Hi All


There are many applications where the Kinetis is used to collect data and save it to memory. Sometimes it will be saving to an SD card but often to a robust linear memory such as internal Flash or a Flash device connected via SPI.


FAT emulation is a very interesting and pratical method of using an available USB interface to allow this memory to appear as an external drive to the host (USB-MSD). It doesn't require the data to be stored in a FAT (linear storage is often much faster and more pratical for the Flash involved and also the storage algorithms when FAT is avoided) and it can be stored as raw sampled data but stil be viewed/retrieved in formatted form.


I have just completed a document explaining this in more detail and also a reference allowing a Kinetis part with USB to be used to access raw sampled data as formatted .csv file for direct import to a calculator program (like Excel).
The document is at


Attached is a binary file that can be loaded to a FRDM-K64F (since it is a popular board owned by many people).

When connected to the PC host it will display some files that are in fact 'just' data in the internal Flash (that have been primed) as shown here:


The data from the internal Flash is visible as either raw sample data (eg. "RawData File 1.bin") which can be copied from the emulated FAT virtual disk, or as comma separated value format (the data is not stored like this but instead the emulated FAT converts it on demand) such as "Formatted Data File 1.cvs" so that it can directly be opened in Excel (for example) where it typically looks something like:



This is a great technique for adding such professional data retrieval/formatting with little overhead (aso to existing applications that are based on linear storage and not FAT).

For example: this application with emulated FAT requires less that 3k more code that a USB-CDC class. The USB-MSD part (including USB device driver, FAT emulation and application) requires just 11.5k in total and so saves FAT overhead and easily fits into smallest data sampling devices with USB.


uTasker users can now add/use this technique in their projects by just enabling a single new define (FAT_EMULATION) to their existing project.

If anyone is interested in a binary for their own evaluation board (just needs to be one with USB) just tell me and I'll add it here, since the project runs on any Kinetis board (with USB device) without any porting requirements so I can build and test it in just 5 minutes or so.








For the complete "out-of-the-box" Kinetis experience and faster time to market

What's up next? Dual-mode USB-MSD Device/Host boot loader with device-to-device OTG cloning....

Out-of-the-box support for 46 Kinetis boards and 10 IDEs (460 combinations from a single code source with no porting required)

Original Attachment has been moved to: