Mark Whitis's Website Home Page Linux Book: Linux Programming Unleashed My Resume Genealogical Data Contact Info Security About

[HOME(Mark Whitis)] [Contact] [Resume] [Browser Friendly] [No Spam] [FEL] [DBD]

Embedded SD Card/MMC Card

Raw images of card contents

A separate page contains raw images of SD/MMC cards as shipped from the factory. These images can be used for testing embedded software against the various filesystem permutations which might be encountered from the factory.

Openness of standards

MMC/SD card format is more open than some formats (XD, Memory Stick) but less open than Compact flash and USB flash drives. Of the serial interface formats, MMC/SD is the easiest to embed. The SD card format is encumbered by patents, licensing, and specifications that are not published openly. However, all SD memory and SDIO cards are required to support the older SPI/MMC mode which supports the slightly slower 4 wire serial interface (clock, serial in, serial out, chip select) that is compatible with SPI ports on many microcontrollers. Many digital cameras, MP3 players, and other portable devices probably use MMC mode exclusively. Documentation for this mode can be purchased from the MMCA for $500; however, partial documentation for SDIO is free and there is free documentation availible for memory cards as part of some manufacturers datasheets. MMC mode does not provide access (and the free documentation does not document) the rarely used (and generally undesireable from a consumer perspective) proprietary encryption features of SD cards. There are three transfer modes supported by SD: SPI mode (separate serial in and serial out), 1 bit SD mode (separate command and data channels and a proprietary transfer format), and 4 bit SD mode (uses extra pins plus some reassigned pins) to support 4 bit wide parallel transfers. Low speed cards support 0-400K bit per second data rate and SPI and 1 bit SD transfer modes. High speed cards support 0-100 megabit per second data rate in 4 bit mode and 0-25 megabit per second in SPI and 1 bit SD modes. Royalties for SD/SDIO licenses are imposed for memory cards, and host adapters ($1000 per year plus membership at $1500/year) but SDIO cards can be made without royalties and MMC host adapters do not require a royalty. MMC cards had a 7 pin interface, SD and SDIO expanded this to 9 pins.

Compared to compact flash where the entire standard can be downloaded free of charge but you apparently have to join the Compact Flash Association at $2500/yr to use the trademarks on your product, the SD standard is less open. Compared to other small form factor standards such as xD-Picture Card and Memory Stick, the SD standard is more open and the MMC subset is much more open. USB Flash memory drives and I/O devices may also be used in similar applications; the standards can be downloaded for free but there is a $1500 one time fee (plus certification costs) for use of the certified USB logos and you must pay either the logo fee or become a member ($2500/yr) in order to get a vendor ID (not needed for host adapters). Relatively few microcontrollers have USB slave support built in and none (as of 2004) had usb master support built in. Many microcontrollers have SPI support built in. Few microcontrollers have SD card host interfaces built in and those that do typically also have compact flash and memory stick interfaces and are usually suited for usb to memory card adapters and little else. No microcontrollers with MMC/SD/SDIO slave interfaces built in were located.

See [Legitimacy of Standards] for background info.

SDIO

SD/MMC slots can support I/O devices as well. Devices that support SDIO includingGPS receivers, WiFi or Bluetooth adapters, modems, barcode readers, FM radio tuners, RFID readers, or digital cameras. Other devices that do not appear to be realized yet are RS-232 serial adapters, TV tuners, fingerprint scanners, irda adapters, SDIO to USB host/slave adapters (would allow an SDIO equiped handheld device to use USB peripherals and/or interface to PCs), magnetic stripe readers, combination bluetooth/WiFi/GPS receivers, ethernet adapters, cellular modems (PCS/CDPD/GSM/etc), APRS/TNC adapters, etc.

Comparison of different types of MMC/SD cards

Type MMC RS-MMC MMC plus SecureMMC SD SDIO miniSD microSD
SD Socket yes mechanical adapter yes yes yes yes electromechanical adapter electromechanical adapter
pins 7 7 13 7 9 9 9? 9?
form factor thin thin/short thin thin thick thick narrow/short/thin narrow/short/extrathin
width 24mm 24mm 24mm 24mm 24mm 24mm 20mm 11mm
length 32mm 18mm 32mm 32mm 32mm 32mm+ 21.5mm 15mm
thickness 1.4mm 1.4mm 1.4mm 1.4mm 2.1mm 2.1mm 1.4mm 1mm
SPI mode optional optional optional required required required required? required?
1 bit mode yes yes yes yes yes yes yes yes
4 bit mode no no yes  ? optional optional optional optional
8 bit mode no no yes  ? no no no no
xfer clock 0-20 Mhz 0-20Mhz 0-54Mhz 0-20Mhz? 0-25Mhz 0-25Mhz 0-25Mhz? 0-25Mhz?
Max XFER 20Mbps 20Mbps 416Mbps 20Mbps? 100Mbps 100Mbps 100Mbps 100Mbps
Max SPI XFR 20Mbps 20Mbps 54Mbps 20Mbps 25Mbps 25Mbps 25Mbps 25Mbps
DRM no no no yes yes n/a yes yes
user encrypt no no no yes no no no no
Simplified Spec yes yes no not yet? yes yes no no
Memb cost $2500/yr (not required) $1500/yr (appears required)
Spec cost $500  ?  ? member member member member
Host license no no no no $1000/yr+memb
Mem card royalties yes yes yes yes yes yes yes yes
i/o card royalties n/a n/a n/a n/a n/a $1000/yr+memb n/a n/a
open source compatible yes yes yes? yes? SPI only SPI only SPI only SPI only

Table data compiled mostly from simplified versions of MMC and SDIO specifications and other data on SD card and MMC association web sites. Data for other card variations is interpolated.

Capacity limit in all SD/MMC formats appears to be 128GB in LBA mode (28 bit sector address).

Most, possibly all, current MMC flash memory cards support SPI mode even if not officially required as failure to do so would severely affect compatibility. All cards currently made by Sandisk, Ritek/Ridata, and Kingmax digital appear to support SPI. Also, MMC cards may be electrically identical to SD cards but in a thinner package and with a fuse blown to disable SD functionality (so no SD royalties need to be paid).

MMC defined the SPI and 1 bit MMC/SD protocols. The underlying SPI protocol has existed for years as a standard feature on many microcontrollers. From a societial perspective, the justification for a new incompatible SD/MMC protocol is questionable; the development of a new incompatible and unnecessary protocol may help trade associations collect licensing and membership fees but it raises the cost of hardware and software in many ways. The new protocol used open collector signalling to allow multiple cards on the same bus but this actually causes problems at higher clock rate. While SPI used 3 shared lines plus a separate chip select to each card, the new protocol allows up to 30 cards to be connected to the same 3 wires (with no chip select) at the expense of a much more complicated card initialization and the requirement that each card have a unique serial number for plug and pray operation; this feature is rarely used and its use is actively discouraged in new standards (which recomend a completely separate channel to each card) because of speed and power consumption issues. The quasi-proprietary 1 bit protocol was extended to support 4 bit wide (SD and MMC) and 8 bit (MMC only) transfers for more speed while much of the rest of the computer industry is moving to higher speed narrower channels; standard SPI could simply have been clocked at higher data rates (such as 133Mhz) for higher performance than offered by 4 bit SD - embedded CPUs that did not already have higher clock rates availible would not have been fast enough to handle the higher data rates anyway. The SD card association dropped support for some of the old 1 bit MMC protocol commands and added support for additional commands related to copy protection.

See Also

The SD card isn't the only flash memory card standard ratified by the Secure Digital Card Association. Other SD Card Association formats include:

These smaller cards are useable in full size MMC/SD/SDIO slots with an adapter (which must route the electrical connections as well as making physical contact). It should be noted, however, that it is already difficult to create I/O devices in the SD form factor and this will be even more impractical in the smaller sizes.

SD cards are derived from the original MultiMediaCards which have separately evolved a new smaller form factor. The reduced size MMC or MMCmobile cards are roughly half the length of a standard MMC/SD card and come with a clip on passive plastic extender for use in full length slots. Full size cards can also be used in reduced size slots but they will protrude from the device. Contrast this with miniSD and microSD that require more expensive adapters with electrical connections to put a miniSD/microSD card in a full size SD slot and an adapter to use a full size card in a miniature slot would be mechanically impractical. It should also be noted that MMC is separately evolving security features that will not require royalties for host implementation. MMC has also evolved faster versions (MMCplus) that support transfer widths of 1, 4, or 8 bits (13 pins), at up to 416 megabits per second. Note that SD cards are slightly thicker than MMC cards so SD card sockets can accomodate MMC cards but MMC sockets can't accomodate SD cards.

Competing Formats

USB

USB supports USB flash drives and a wide variety of I/O devices. The down side is that USB flash drives are physically larger and few microcontrollers have built in USB support and those that do are lacking in other features.

Compact Flash

Compact flash cards are more open and support more types of I/O devices but are larger, require connectors with large pin counts, and use up precious I/O pins on your microcontroller.

XD Picture Cards

XD-Picture cards are a newer rival to SD/MMC cards. While there is a need for a standard that is more open (published specs), cheaper (in terms of licensing fees), and more flexible than MMC/SD, XD-Picture Cards are worse in all of these respects.

Caveat emptor: Even when considered from a Neutral Point of View the xD-Picture Card is so thoroughly lacking in redeeming features compared to the competition as to make an impartial view seem one sided.

Consumers would be wise to compare xD to SD cards as well as the mini-SD and micro-SD formats (or even compact flash) before purchasing and xD based product. From the consumer's perspective, xD cards lose in all aspects of the comparison. SD cards were availible first; therefore, xD cards would need to bring some significant advantages to the table. xD is one third smaller than SD cards but larger than mini-SD and micro-SD formats. mini-SD and micro-SD formats are usable in full size MMC/SD/SDIO card slots with an adapter; xD is not. SD slots support I/O devices such as WiFi, Bluetooth, GPS, cameras, etc. but xD slots do not. xD memory cards are more expensive for the same capacity compared to MMC/SD cards. SD format supports twice the data rate (10 megabytes per second) of xD (5 megabytes per second). More technical documentation seems to be availible for MMC/SD and SDIO cards making it possible to implement I/O cards or host adapters that don't require encryption or high speed (>25Mbps) without licensing; documentation for xD cards is not availible without a license and license fees are not disclosed on the web site. SD memory cards work in digital cameras, PDAs, MP3 players, GPS receivers, and many other handheld devices; xD cards work only in a few brands of digital cameras ("The xD card is the only card exclusively for digital cameras" - xD Picture card office) and in some models of memory card readers for PCs. Indeed, they try to spin this as a benefit to the consumer - since your card isn't supported by music players, there won't be any music files taking up space that your camera doesn't know how to delete (not that there is anything preventing you from storing non-image files on the cards from your PC to move them from one PC to another). xD cards work in two brands of cameras; SD cards are supported by 665 different manufactuers (not counting MMC mode devices) including too many brands of digital cameras to count. And if that isn't enough vendor lock-in for you, Olympus cameras are designed to disable the panaramic feature when used with any other brand of xD-Picture card.

From the perspective of the average manufacturer of cameras and other devices, the only advantage is that you don't need to license the encryption technology used to copy-protect audio on SD cards, though you do not in fact have to license SD technology to use SD memory cards in MMC mode and it isn't clear whether the xD license is any cheaper to anyone other than the creators of the standard.

The xD picture card office cites 6 "advantages" to xD picture cards. None of them hold water when compared to SD cards and only one (size) is an advantage compared to CF cards.

The primary disadvantage to CF cards are their larger size and higher cost to manufacture. The high pin count on the connector raises the cost of both cards and host devices. Even so, compact flash memory cards still seem to be cheaper than xD. CF is availible in much larger sizes (either as flash memory or microdrives). Compact flash to SD card adapters are possible (with software support), allowing some CF devices to also take SD cards. CF slots support not only memory but an even wider array of peripheral devices than SD cards.

The xD-Picture Card is similar to the sony memory stick - it only works with a few brands of handheld devices (the memory stick works in more types of devices but usually only those made by sony) and both are more expensive than the more standard SD cards of equivalent capacity. Memory sticks are availible in capacities four times larger than xD.

From the perspective of open source movement, anti-DRM movement, and designers of small volume devices, xD comes up lacking as well. While xD lacks DRM, which would be an advantage to those opposed to DRM, it isn't availible for devices where DRM is an issue so the point is moot. And while you don't have to pay to license the non-existent security features, you still have to pay to access the specification which is even less availible than SD cards. Licensing cost may even be higher (if it was lower, they would surely tout that as an advantage on their web site). And they require product certification which is likely to add substantially to the cost. And while open source software developers can obtain enough information on SD format to use memory cards without DRM and SDIO peripherals at up to 25Mbps transfer speed, information on even that basic level functionality of xD format is not availible.

For Fuji and Olympus, the creators of xD, their format has a simple apparent advantage. Instead of paying the SD Card Association royalties, they get to charge other companies royalties. On the other hand, their camera sales may suffer badly. It is worth noting, that Sony, the manufacturer of the similarly proprietary memory stick format, discontinued its entire CLIE PDA line, presumably due to lackluster sales; the Achilles heel of that line of, otherwise interesting, PDAs was its support for only the memory stick format. And the market share of memory stick based MP3 players is abysmal; whereas an SD card based player was ranked the 63rd highest selling piece of electronics on Amazon, the top ranked memory stick player was way down at #56,857.

From the consumer's point of view, the xD-Picture card lacks a Raison d'ĂȘtre .

Memory Stick

Memory sticks are too proprietary.

Smart Media

Obsolete.

Speed

In a desktop USB 2.0 reader, a 128MB SD card was read in 3.5 minutes, which is about 610KB/s or about 5Mb/s or 1190 sectors per second. A 128MB RS-MMC card was read in 7.5 Minutes. Write speeds were similar. A desktop reader may use multi-sector writes and 4 bit transfer modes, however, so that performance is higher than might be expected on an embedded system. A commercial embedded library for the AVR gets much lower speeds of 1-5kB/s write and 4-10kB/s for reads. That implementation used a low clock speed for the CPU (14.7Mhz) and updated the directory and fat sectors after each write. Read speed might have been compromised by not setting asside a memory buffer to cache the current FAT sector requiring a FAT sector to be read for each new cluster.

Why copyprotection features are moot

Embedded MMC/SD card reader board

Here is a MMC/SD card reader board I am currently designing as an add on for a 5V microcontroller board. The connector mates with my MC9S12DP256 microcontroller board But with a custom cable it can be used with any 5V micro or a PC parallel port. Feel free to duplicate for personal use or prototyping (drop me a note to let me know you are using it); for commercial use, contact me for licensing.

[schematic diagram] [Printed Circuit Board Layout]

Card detect, write protect, and power off signals are optional but ground power off if not used. This device provides a fixed 3.3V voltage to the card, it will not support low voltage only cards. The 74TVC16222 is a 22 channel bidirectional FET voltage translation clamp and is used to translate the 5V signals to 3.3V. It also is being used as a simple emiter follower voltage regulator for providing power to the card; there is no current limiting so don't go sticking metal objects in the card slot. It can probably provide up to about 1W to the card but check thermal dissipation on the chip before using a high power SDIO card such as WiFi. Two fet channels are unused and can be wire modded if you want to experiment with 4 bit transfer mode.

In spite of having one fine pitch component, this board was designed to be fairly easy to make by homebrew methods including etching and hand soldering.

This board uses surface mount components, including one 0.625mm (25 mil) TSSOP package. However, it should not be too hard to assemble even if you have no experience with surface mount. Although the 48 pin TSSOP may seem intimidating, bear in mind that only 12 of the pins can't be shorted to an an adjacent pin. Practice on the end where adjacent pins are shorted together already. To do the assembly, you will need fine pitch solder (the smallest sold at Radio Shack is ok), a fine tip soldering iron, and a magnifying lamp. Position the IC and tack solder the corner pins, then solder the rest. C2 is polarized. On surface mount caps, the positive end is marked, often with a stripe and/or a bevel. For those used to through hole electrolytics caps, this can be confusing because those have a stripe marking the negative side. The stripe or bevel goes towards the top of the board (in the orientation shown above).

This board can be made as a homebrew single sided board using the toner transfer.method. My first attempt was successful. I used Staples Photo Basic Gloss paper (SKU 471861 , $9.95/30 sheets or 471865 $29.97/100 sheets ) which is noted to work particularly well and is significantly cheaper than toner transfer sheets, set my laser printer to high toner density. Use the panelized file since the hole sizes have been adjusted for manual drilling and has been mirrored for toner transfer. I scrubbed the board with alcohol and a heavy duty scotch brite pad before transfering the toner. The board was preheated to 250degrees in a grease free toaster oven (optional step) and then the transfer was ironed on with heavy pressure and max heat setting for 2 minutes. The paper was soaked in warm water for 20 minutes, I pealed off what would peal, and the paper residue scrubbed off with a toothbrush under running water. The board was dried and an adhesive label with a fold in it was attached to the back side as a handle. It was then carefully floated face down in a plastic storage container filled with ferric chloride etchant and etched for 15 minutes. Note that every time you remove and replace the board, you must dry the top and edges to maintain proper surface tension (and prevent uneven etching on the top for double sided boards). Then the board was rinsed, dried, and the toner was removed with nail polish remover (in this case the non-acetone variety though I usually use the acetone variety). There is a significant amount of pitting but all of the TSSOP pads are ok. It should be noted that even on the dark toner density setting, my Samsung laserprinter has visable ghosts of white areas 3 inches above (one drum circumference?) in the dark areas of the image. Pictures are availible after toner transfer and after etching. For faster etching and easier inspection during etching, you can used a Low cost etch tank . To dispose of ferric chloride etchant, first fully deplete the etchant using something such as steel wool, then add Washing Soda and allow liquid to evaporate and discard in trash. Tips on staples paper and ferric chloride disposal are from EasyPCB. Holes were drilled using a dremel tool.

Errata

A 1K pulldown resistor is recommended on the 3.3V supply to discharge supply when turned off. The 3.3 volt supply does not work as well as expected. Voltage ranges from 3.5V at 0ma to 2.99V at 30ma. Sustitution of a low dropout regulator (TC1265 3.3V Fixed 800ma with shutdown or TC1071 adjustable 100ma with shutdown) is recommended connect vref pin on level translator to regulator output instead of voltage divider. Even worse, while the power supply line is dragged down, the data lines are not resulting in the data lines being at higher voltages than the supply. As a workaround for this, I added a 100K pull down on the Data Out line and 10k on chip select, data in, and clock; The pulldown resisters were tack soldered onto TP4 through TP7. The MMC data out pin presents special problems. The drive strength and voltage levels on this pin are substandard. I am currently using a modified board with a FDV301N fet with a 75K pullup to 3.3V on the gate and a 1K pullup to 5V (on the 5V side of the level translator IC) installed in the cut trace between the level translator and the MMC card.

The socket used is a push in to relase type. However, it still uses friction or a spring detent to hold the card so I was able to eject a card by banging the corner of the PCB on the table (multiple Gs) 15 times so it may not be suitable for high vibration environments.

Drive levels on the data out line of the MMC card are lower than expected.

Card Size Limitations

Cards are currently availible up to 2GB. Lexar notes that compact flash cards larger than 2GB require FAT32, the same is likely to be true for MMC/SD.

Links

This file is maintained by Mark Whitis (whitis@freelabs.com).

Senior Engineer for hire
Software Development - Electronic Design - Embedded Systems - Device Drivers - System/Network Administration and Security - Motor Control, RobotCNC - Linux/Un*x - 25+ years experience
The author of these pages is looking for a new gig.
[RESUME]

Engineers and electronic hobbyists: The new Open Symbol Project is creating open schematic symbols and PCB footprints for a variety of different CAD packages.

Mark Whitis's Website Home Page Linux Book: Linux Programming Unleashed My Resume Genealogical Data Contact Info Security About

All email messages received must pass the turing test or they will be considered SPAM. If it could have been written by a machine, it was.

Under no circumstances are you to email me with questions regarding windoze, any other microsoft operating system or application, or any software which runs under any form of windoze.

*