Anda di halaman 1dari 5

Integrating MMC/SDIO Support in Design http://dev.emcelettronica.

com/print/51771

Your Electronics Open Source


(http://dev.emcelettronica.com)
Home > Blog > allankliu's blog > Content

Integrating MMC/SDIO Support in Design


By allankliu
Created 09/05/2008 - 04:58

BLOG Microcontrollers

This blog describes my idea about integrating


MMC/SDIO in embedded systems, including
software in host controller and card controller
running in SPI mode. Although I do not have
full source code to demonstrate, theoretically
it is realizable.

Flash Cards Everywhere

All kinds of flash cards are parts of our digital


lives. They are used everywhere in mobiles,
cameras, mp3s and DVD players. These
cards are offering more storage memory
space in much lower price. Technically these
cards are quite mature to be integrated into many devices. However the engineers can not
find suitable open source stack solutions because of legal issues from the corresponding
flash card associations.

So far we can find following flash cards in the market:

1. Smart Media: It was a pure NAND card developed by Samsung/Toshiba, today it has
phased out since it is too large for today's devices.
2. Compact Flash: It is an industry standard flash card, very old, but still widely used in
many applications. The CF cards can be considered as hard disks via IDE/PCMCIA
interfaces.
3. Multimedia Card: A flash card developed by Infineon/Siemens/Sandisk, it can be
licensed from MMCA under NDA. It has a mini version called RS-MMC.
4. Memory Stick: A flash card family developed by SONY, designers can only get
specification from SONY under NDA. Sandisk is the major second source for memory
stick.
5. XD card: Actually it is an alternative package for NAND flash memory chip. We can
simply consider it as miniature SM card, which was developed by Fuji film and Olympus.
But it is seldom used in the embedded systems.
6. SD card: A flash card by Matsushita/Toshiba/Sandisk, it can be licensed from SDCA
under NDA. It has two mini version called mini-SD and micro-SD.
7. Trans-flash card: It is developed by Motorola/Sandisk for mobile phone. It was renamed
as micro-SD card.

1 din 5 10.05.2008 10:49


Integrating MMC/SDIO Support in Design http://dev.emcelettronica.com/print/51771

No Open Source SD Protocol Available

We can easily found that Sandisk plays an important role in the flash card industry. The SD
card family is the market leader, since most of the cards offer SD adapters. So it is important
to support SD card in an embedded system. The SD card simplified specification is freely
available from the SDCA official site, but the detail specification is only available under NDA
and strict agreements. In order to support SD card in the devices, most of the suppliers have
to use proprietary SD card protocols in the designs. For example, Sharp used a proprietary
protocol in its Linux Zaurus PDA. There is a good article regarding this topic. Please check
reference for your information.

Actually Sandisk released the P-TAG, which is a flash card dedicated for health record of US
army. I have checked the specification. It is almost a SD card specification. The PDF file is
removed from Sandisk site now. Maybe Sandisk realized this file revealed too much
confidential information to the world.

Host SD Protocol in Latest Linux

Now Linux starts to integrate SD support in the latest kernel. Please check cited mail from the
Linux kernel maintainer. That means SD protocol is a standard feature of Linux kernel. It is
very exciting news for the embedded system developers. Compare to other interfaces,
including USB and Bluetooth, SD or SDIO card is relatively easy to deploy in the systems
from the technical point of view. The costs of BOM and development effort for SDIO cards
are also much lower. The reason is simple, SD and SDIO support SPI mode operation. And
SPI mode is available in many low-end microcontrollers, even emulated by firmware inside
the microcontrollers. And there is no requirement of running a complex stack in the SDIO
card as well. The microcontroller inside the SDIO card can easily map its IO or registers to
host controller, and let host controller to manipulate them. It is easy, but we still need extra
programming for switching SD card to SPI mode.

Host SD Protocol in embedded RTOS

Micrium’s uC/OS-II open source RTOS kernel has a complementary embedded file system
called uC/FS. It is a file system for embedded applications which can be used on any media,
for which you can provide basic hardware access functions. µC/FS is a high performance
library that has been optimized for minimum memory consumption in RAM and ROM, high
speed and versatility. It is written in ANSI C and can be used on any CPU. An optional device
driver for MultiMedia & SD cards using SPI mode or card mode that can be easily integrated.
It is a good starting point to integrated SDIO support into your embedded system. I got a
fragment of the whole uC/FS source code from an evaluation board supplier, which only
offers SmartMedia card driver. If I have sufficient time, maybe I can port a SPI mode driver
and access the SD card. But I do not know the latest license term of Micrium. The developer
must contact the supplier first.

SPI mode in SDIO card

SD/SDIO offers three operation


modes, SPI mode, SD 1-bit mode
and SD 4-bit mode. SPI mode and
SD 1-bit mode are mandatory modes,
SD 4-bit mode is mandatory for
high-speed card. SPI mode is not the
default mode of SD card. The default
one is SD 1-bit mode. On page 17-18
of SDIO simplified specification, the
card initialization flow in SPI mode is

2 din 5 10.05.2008 10:49


Integrating MMC/SDIO Support in Design http://dev.emcelettronica.com/print/51771

offered. We can implement SDIO


card running in SPI mode.

In order to design a card controller


with a microcontroller, we need
emulate the initialization procedure
by emulation SD-1 bit mode in I/O
electrical characteristics, communication and CRC calculation, and internal registers of card
parameters, which describe card timing, voltage, and more. During this initialization period,
the SD card must use SD 1-bit mode. It is OK for this small period because the speed is quite
slow. There is an issue for CRC calculation which is required in SD mode communication. I
found a way to solve it. Because CRC7/CRC16 calculation is byte oriented algorithm and only
required for upstream communication, (yes, it is required in both directions, but are you going
to calculate downstream while basically they are all correct?) we can use a look-up table to
emulate it. Some programmer might doubt my implementation. They might wonder how I can
calculate the CRC result with two input variables. The reason is very easy, because the
leading bytes are the descriptors for parameters of the cards, which are all fixed bytes. Of
course if a powerful microcontroller is used in the project, CRC calculation is out of question.
Then SD 1-bit mode can be used in the following communication. The I/O electrical
characteristics can be achieved by toggling the I/O and port configuration registers in the
microcontrollers.

After the initialization procedure, the following communication in SPI mode, such as register
access, normal communication is quite easy. And CRC calculation is not required in SPI
mode by default, unless the system enable it explicitly.

I do have an unfinished reference code designed for Cypress PSoC. Maybe I should spend
some effort to finish it and sell it some day.

More Issues

SPI mode is convenient, but SD mode offers much higher communication speed. In case you
want a high speed communication on SD socket, the designer must sign the NDA with SDCA
for full specification and implement a dedicate SD card controller.

Reference

The simplified SDIO card specification from the SD card


association official site.

[1]

[2]

Sharp Linux PDA promotes use of proprietary SD card, but more


open MMC works just fine.

3 din 5 10.05.2008 10:49


Integrating MMC/SDIO Support in Design http://dev.emcelettronica.com/print/51771

Where are the open-source SD/SDIO stacks?

[3]

uC/FS from Micrium. It is a complementary module for


uC/OS-II. The uC/FS support FAT12/16/32 in SmartMedia,
SD/MMC card, Compact Flash and IDE hard disk driver.

[4]

[5]

What's in mmc.git for 2.6.24? This article is about SDIO support


in Linux kernel 2.6.24.

[6]

World's First Medical Trials of SanDisk's Wearable P-Tag


Electronic Information Card.

4 din 5 10.05.2008 10:49


Integrating MMC/SDIO Support in Design http://dev.emcelettronica.com/print/51771

Trademarks

Source URL: http://dev.emcelettronica.com/integrating-mmcsdio-support-design

Links:
[1] http://www.sdcard.org/about/sdio/sdio_spec/
[2] http://www.linux.com/articles/20060
[3] http://www.linuxdevices.com/articles/AT6640645071.html
[4] http://www.micrium.com/products/fs/filesystem.html
[5] http://kerneltrap.org/mailarchive/linux-kernel/2007/9/24/273136
[6] http://findarticles.com/p/articles/mi_m0EIN/is_2001_April_19/ai_73388143

5 din 5 10.05.2008 10:49

Anda mungkin juga menyukai