SD Cards and FAT file systems for STM32 cortex m3

Chans FatFS

A Secure Digital (SD) card is a tiny memory card used to make storage portable among various devices, such as car navigation systems, cellular phones, eBooks, PDAs, smartphones, digital cameras, music players, camcorders, and personal computers. An SD card features a high data transfer rate and low battery consumption, both primary considerations for portable devices. It uses flash memory to provide nonvolatile storage, which means that a power source is not required to retain stored data.

An SD card is about the size of a postage stamp and weighs approximately two grams. It is similar in size to a MultiMediaCard, but smaller than older memory card types such as the SmartMedia card and the CompactFlash card. Both MMC and SD cards provide encryption capabilities for protected content to ensure secure distribution of copyrighted material, such as digital music, video, and eBooks. SD cards are available with storage capacities as high as 4 gigabytes.

SD cards are more rugged than traditional storage media. They have an operating shock rating (basically, the height you can drop them from and still have them work) of 2,000 Gs, compared to a 100-200 G rating for the mechanical drive of the typical portable computing device. This translates to a drop to the floor from 10 feet, as compared to a single foot for the mechanical disk drive. Both MMC and SD cards use metal connector contacts, instead of the traditional pins-and-plugs, so they aren’t as prone to damage during handling.

Chans Petite FatFS (2k-4k)

EFSL Embedded Filesystems Library

The EFSL project aims to create a library for filesystems, to be used on various embedded systems. Currently we support the Microsoft FAT filesystem family. It is our intention to create pure ANSI C code that compiles on anything that bears the name ‘C compiler’. We don’t make assumptions about endianness or how the memory alignement is arranged on your architecture.

Adding code for your specific hardware is straightforward, just add code that fetches or writes a 512 byte sector, and the library will do the rest. Existing code can off course be used, own code is only required when you have hardware for which no target exists. For example, we support secure digital cards in SPI mode.

SD/MMC interface code specific to STM32

Domen Puncer’s code for SPI access to SD/MMC cards on the STM32 which uses the std firmware library and is released under the BSD Licence

Martin Thomas’s code for SPI access to SD/MMC cards on the STM32 uses chan’s FatFS


DOSFS is a FAT-compatible filesystem intended for fairly low-end embedded applications. It is not the leanest possible implementation (the leanest FAT implementations operate in << 512 bytes of RAM, with heavy restrictions). This code strikes a good balance between size and functionality, with an emphasis on RAM footprint.

STM32100B-EVAL demonstration Firmware

The demonstration firmware for the STM32100B demo board contains an SPI implementation for accessing SD / MMC cards using the Standard Peripheral Library and also uses the DOSFS file system.

Related posts:

About author

This article was written by admin

Admin has over twenty years experience in the electronics industry, largely dedicated to embedded software. A frequent presenter at conferences and seminars and author of numerous technical articles. Working presently as Development Manager in India. A firm Believer in Knowledge grows when it shared.


No Comments

Leave your comment

Your email address will not be published. Required fields are marked *