Author Topic: FAT emulation?  (Read 13752 times)

RickCiervo

  • Member
  • ***
  • Posts: 2
FAT emulation?
« on: July 21, 2011, 05:14:35 pm »
Hi All,

Here is my situation. I have a small embedded system based around an STM32 ARM MCU. We store a bunch of custom-defined databases in serial EEPROM and serial flash, using our own proprietary file system and database manager. This embedded device then has to connect to a PC (or Mac) and present itself like a FAT-formatted drive, but w/o actually implementing a FAT file system in the EEPROM and serial flash. In other words, I am trying to find out the best way to have the STM32 emulate a FAT-file system so that a PC can request or write files to the device as if it were FAT formatted. It seems like it is easy enough to find examples of code for embedded systems that need to access a FAT-formatted memory device (like an SD card), but this isn't my problem.

Any suggestions?

-Rick

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: FAT emulation?
« Reply #1 on: July 22, 2011, 12:41:52 pm »
I'm guessing you need the proprietary file system because existing firmware makes use of the files?

You would need to create a bridge that responds as expected to mass-storage requests and SCSI commands but actually accesses the proprietary file system. I don't know of any examples, but existing FAT firmware could be a starting point.

If you have room for two copies of everything, you could copy the files to an internal FAT system and in firmware sync the two copies so they always have identical contents.

Jan

RickCiervo

  • Member
  • ***
  • Posts: 2
Re: FAT emulation?
« Reply #2 on: July 22, 2011, 02:40:20 pm »
First - thanks for responding! I appreciate any help you may be able to give us.

Correct - we have a proprietary file system because we are using a legacy system. We could convert to FAT structures in our EEPROM and flash, but that would be a large rewrite for major sections of our code. I wanted to avoid that.

The bridge idea is what we came to here also, and we were wondering if there was code out there for this. What do you mean by "existing FAT firmware"? Something like this: http://www.segger.com/cms/emfile.html or an open-source equivalent?

One of our engineers also proposed the dual file system also, but that seems the most complex. We'd probably opt for all-FAT or a "bridge".

-Rick

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: FAT emulation?
« Reply #3 on: July 22, 2011, 10:25:27 pm »
One with source code so you can modify it. For example, Microchip's USB code for PICs includes FAT code, or the Linux source.

Jan

Fse

  • Member
  • ***
  • Posts: 1
Re: FAT emulation?
« Reply #4 on: January 23, 2015, 03:59:07 am »
Fat32 emulation project on stm32f4 using crossplatform tiny emulator https://github.com/fetisov/emfat

grantb5

  • Member
  • ***
  • Posts: 34
Re: FAT emulation?
« Reply #5 on: January 30, 2015, 12:31:45 pm »
Very doable but still a fair bit of work. In our case we use it to transfer some configuration files from a host PC (Win, Linux or Mac) to our embedded device.

I was able to do it in an SILabs 8-bit micro (USB FS with bulk endpoints) with about 12k of flash to work with for the MSD "disk". I looked at a lot of example code for a lot of micros. Almost all of which had some shortcomings.  As in USB, the SCSI command set needs to be supported, but NOT ALL of it. 

Where it gets a little ugly is when you connect to a Mac the OS writes a mess of files. Our solution to that was to wipe the "drive" once our device has accepted the configuration, otherwise we would have blown the flash space we had available.