FAT Emulation

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FAT Emulation

1,413 Views
mjbcswitzerland
Specialist V

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 http://www.utasker.com/docs/uTasker/uTaskerEmulatedFAT.pdf

 

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:

 

93475_93475.pngpastedImage_0.png

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:

 

93488_93488.pngpastedImage_1.png

 

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.

 

Regards

 

Mark

 

 

Kinetis: http://www.utasker.com/kinetis.html

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: uTaskerV1.4.10_FRDM-K64F_FAT_emulation.bin.zip

Labels (2)
Tags (2)
0 Kudos
2 Replies

795 Views
mjbcswitzerland
Specialist V

Hi All

As follow-up, I have attached a version with SD card enabled as well as the emulated FAT. This means that the FRDM-K64F appears as two drives to the PC host, the first being the SD card with full FAT (utFAT2.0) support and the second the emulated drive visualising the linear data.

Since a full FAT is now integrated (for the SD card use) the command line on the virual COM port connection includes a DOS-like interface which allows interaction between both the SD card and the emulated FAT:

- In the disk drive menu the SD card appears as drive and the emulated one as drive E:

- use "disk e" to switch to the emulated drive

- with "dir" the content can also be viewed

E:\>dir
Directory E:\

---- 03.08.2015  08:23             3722 Raw Data File 1.bin
---- 03.08.2015  13:09            74982 Raw Data File 2.bin
---- 03.08.2015  08:23            15816 Formatted Data File 1.csv
---- 03.08.2015  13:09           318672 Formatted Data File 2.csv
---- 26.10.2015  12:00           262144 software.bin
---- 26.10.2015  12:00              354 uTasker.html
6 files with 675690 bytes
0 directories, 327680 bytes free

Regards

Mark

0 Kudos

795 Views
mjbcswitzerland
Specialist V

Hi All

Next follow-up.

I have attached a version for a KL25 (FRDM-KL25Z) which doesn't have enough internal Flash to run the exact same reference. Instead it just allows viewing its complete internal Flash and also a (new) snap-shot of its complete internal RAM.

The RAM snap-shot is in fact quite interesting to look at because it is possible to recognise various buffers and also see the stack and heap usage. I could imagine using this quite regularly to check out the RAM usage during operation!

The file manager display it something like this:

pastedImage_0.png

Regards

Mark

0 Kudos