port to MMC/SD
Unfortunately, I can't make the modules pC/FAT and pC/FFS freely accessible. However, I can give here a simplified version of the MMC/SD-Card Ports on the SPI-connection for miscellaneous controller.
By using this ports you can use another FileSystem on this interface and with it accessing the MMC- and SD-Cards. Or, like my tests, a MMC/SD-to-USB adapter can be realized in software. This works like an USB-Device as MassStorage (removable media) on the PC and you have access to the MMC- and SD-cards like an professional adapter in hardware (only slower, since SPI-mode and software realization).
Here a overview over the SD-Card versions:
Restrictions of the simplified MMC/SD-ports:
- no interrupt- or DMA-mode
- no detailed media infos
- no read / write in call-back mode
- no direct RTOS-support
download simplified pC/FAT Ports to MMC/SD (as ZIP)
(with MMCplus/HD-MMC/M-Bridge/SDHC/SDXC support)
(with optional McEx/ASSD-support)
On a porting to further controllers, additional to the SPI-speed adaptation only some parameters of the hardware must be known and to setup. This are the used PIO-pins for WP (WriteProtect), CD (CardDetect) plus the correct settings for MOSI, MISO, SCLK and /SS. Additional the matching SPI-mode 3 must be enabled.
to used SPI-mode of the controller (master)
Following diagram shows the SPI-mode, that is required for the communication with MMC- and SD-cards in the SPI-mode:
To the topic "speed"
In the following table, all important parameters of here present MMC/MMCplus/M-Bridge/SD/SDHC-cards are listed as confrontation. This illustrates quite well that the performance statements of the manufacturers speed for MMC/SD-mode is only indirect/relative with the context in SPI-mode.
The paramters Nac and Nbs are from special interest.
- Nac = maximum cycles between Read_CMD and data
- Nbs = maximum cycles between Write_CMD+data and End-of-Busy
These parameters partly fluctuate very strongly between the different cards/manufacturers. They give an information about how fast read and write of the internal storage can be really. BUT! also these values represent the respective absolute maximum-worth. That is but also on the other hand, a card with high Nbs nevertheless can possibly be faster ready with a Write-CMD, as a card with lower Nbs. However yields these statements a tendency over the cycles at most possible/expected/permissible from the respective manufacturer.
Card | MMC | MMC | MMC | MMC | MMC | MMCmicro | RS-MMC | MMCmobile |
MID-OID | 01-0000 | 01-0000 | 06-0000 | 02-0000 | 48-FFFF | 6F-0000 | 02-0000 | 2C-0000 |
maxclk | 20MHz | 20MHz | 20MHz | 20MHz | 20MHz | 20MHz | 20MHz | 20(26)MHz |
usedclk* | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz |
Nac | 10.012 | 10.012 | 10.012 | 10.012 | 800.000 | 50.000 | 100.000 | 50.000 |
Nbs | 40.048 | 40.048 | 40.048 | 40.048 | 102.400.000 | 1.600.000 | 400.000 | 1.600.000 |
maxsectors | 31.424 | 62.720 | 125.440 | 250.880 | 2.007.040 | 1.003.520 | 62720 | 125.440 |
sectorsize | 512 | 512 | 512 | 512 | 512 | 512 | 512 | 512 |
Card | MMCmobile | MMCmobile | MMCmobile | MMCmobile | MMCplus | MMC | MMCplus | MMCplus |
MID-OID | 15-0000 | 00-0000 | 6F-0000 | 70-0000 | 1E-FFFF | 4B-4342 | 1E-FFFF | 19-5944 |
maxclk | 20(26)MHz | 20MHz | 20(52)MHz | 20(52)MHz | 20(52)MHz | 20(?)MHz | 20(52)MHz | 20(52)MHz |
usedclk* | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz |
Nac | 15.012 | 30.000 | 10.000 | 200.012 | 50.000 | 35.000 | 200.000 | 200.012 |
Nbs | 1.921.536 | 480.000 | 1.280.000 | 25.601.536 | 1.600.000 | 1.120.000 | 6.400.000 | 25.601.536 |
maxsectors | 1.003.520 | 1.935.360 | 1.945.600 | 1.983.488 | 990.208 | 2.022.912 | 1.981.952 | 1.988.096 |
sectorsize | 512 | 512 | 1024 | 1024 | 512 | 512 | 1024 | 2048 |
Card | M-Bridge | SD | microSD | SD | SD | SD | miniSD | microSD |
MID-OID | 04-4450 | 01-4150 | 13-474B | 03-4453 | 02-4D54 | 03-4453 | 03-4453 | 1B-4D53 |
maxclk | 25(50)MHz | 25MHz | 25(50)MHz | 25MHz | 25MHz | 25MHz | 25MHz | 25(50)MHz |
usedclk* | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz |
Nac | 10.000 | 5.012 | 50.000 | 15.000 | 2.000 | 15.000 | 15.000 | 802.200 |
Nbs | 320.000 | 160.384 | 1.600.000 | 240.000 | 64.000 | 240.000 | 240.000 | 12.835.200 |
maxsectors | 1.990.656 | 29.120 | 249.344 | 246.016 | 1.000.448 | 1.984.000 | 1.984.000 | 1.995.776 |
sectorsize | 512 | 512 | 512 | 512 | 512 | 512 | 512 | 512 |
Card | SD | SD | SD | SD | microSD | microSD | SD | SD |
MID-OID | 1B-4D53 | 1B-4D53 | 1C-5653 | 29-4441 | 03-4453 | 1E-4241 | 02-4D54 | 01-4150 |
maxclk | 25(50)MHz | 25(50)MHz | 25MHz | 25(50)MHz | 25MHz | 25(50)MHz | 25(50)MHz | 25(?)MHz |
usedclk* | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz |
Nac | 802.200 | 802.200 | 50.000 | 10.000 | 15.000 | 200.000 | 400.000 | 5.012 |
Nbs | 12.835.200 | 12.835.200 | 1.600.000 | 320.000 | 240.000 | 6.400.000 | 1.600.000 | 80.192 |
maxsectors | 1.995.776 | 1.995.776 | 1.999.872 | 1.964.032 | 1.985.024 | 1.948.672 | 1.927.168 | 1.967.616 |
sectorsize | 512 | 512 | 512 | 1024 | 1024 | 1024 | 1024 | 1024 |
Card | SD | SD | SD | SD | SD / SDHC | SDHC | SDHC | |
MID-OID | 02-4D54 | 1B-4D53 | 03-4453 | 19-5944 | 1C-5653 | 1B-4D53 | 03-4453 | |
maxclk | 25(50)MHz | 25(50)MHz | 25MHz | 25(50)MHz | 25(?)MHz | 25(50)MHz | 25MHz | |
usedclk* | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | |
Nac | 20.000 | 200.000 | 15.000 | 20.012 | 30.000 | 100.000 | 100.000 | 100.000 |
Nbs | 640.000 | 6.400.000 | 240.000 | 2.561.536 | 120.000 | 250.000 | 250.000 | 250.000 |
maxsectors | 1.921.024 | 1.981.440 | 1.931.264 | 1.956.352 | 1.967.616 | 7.870.464 | 7.811.072 | 7.959.552 |
sectorsize | 1024 | 1024 | 1024 | 2048 | 2048 | 512 | 512 | 512 |
Card | SDHC | SDHC | SDHC | SDHC | SDHC | SDHC | microSDHC | microSDHC |
MID-OID | 1B-4D53 | 03-6883 | 02-4D54 | 01-4150 | 03-4453 | 02-4D54 | 03-4453 | 27-4850 |
maxclk | 25(50)MHz | 25(50)MHz | 25(50)MHz | 25MHz | 25MHz | 25(50)MHz | 25MHz | 25(50)MHz |
usedclk* | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz |
Nac | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 |
Nbs | 250.000 | 250.000 | 250.000 | 250.000 | 250.000 | 250.000 | 250.000 | 250.000 |
maxsectors | 7.811.072 | 7.913.472 | 7.729.152 | 7.741.440 | 7.744.512 | 7.741.440 | 7.959.552 | 7.843.840 |
sectorsize | 512 | 512 | 512 | 512 | 512 | 512 | 512 | 512 |
Card | microSDHC | microSDHC | SDHC | SDHC | SDHC | SDHC | SDHC | SDHC |
MID-OID | 03-4453 | 1E-4241 | 1D-4441 | 27-4850 | 01-4150 | 1E-4241 | 19-5944 | 02-4D54 |
maxclk | 25MHz | 25(50)MHz | 25(?)MHz | 25(50)MHz | 25(50)MHz | 25(50)MHz | 25(50)MHz | 25(50)MHz |
usedclk* | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz |
Nac | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 |
Nbs | 250.000 | 250.000 | 250.000 | 250.000 | 250.000 | 250.000 | 250.000 | 250.000 |
maxsectors | 15.954.944 | 15.661.056 | 15.332.352 | 15.720.448 | 31.645.696 | 31.387.648 | 31.776.768 | 31.116.288 |
sectorsize | 512 | 512 | 512 | 512 | 512 | 512 | 512 | 512 |
Card | microSDHC | SDHC | microSDHC | microSDHC | SDXC | microSDXC | SDXC | microSDXC |
MID-OID | 03-4453 | 02-4D54 | 03-4453 | 1B-4D53 | 1E-4241 | 03-4453 | 74-454A | 03-4453 |
maxclk | 25MHz | 25(50)MHz | 25MHz | 25(50)MHz | 25(50)MHz | 25MHz | 25(50)MHz | 25MHz |
usedclk* | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz | 8MHz |
Nac | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 | 100.000 |
Nbs | 250.000 | 250.000 | 250.000 | 250.000 | 500.000 | 500.000 | 500.000 | 500.000 |
maxsectors | 31.116.288 | 63.700.992 | 62.333.952 | 61.315.072 | 124.925.952 | 124.735.488 | 251.394.048 | 249.736.192 |
sectorsize | 512 | 512 | 512 | 512 | 512 | 512 | 512 | 512 |
Card | microSDXC | microSDXC | nm-card | |||||
MID-OID | 03-4453 | 03-4453 | FF-0000 | |||||
maxclk | 25MHz | 25MHz | 50MHz | |||||
usedclk* | 8MHz | 8MHz | 8MHz | |||||
Nac | 100.000 | 100.000 | 100.000 | |||||
Nbs | 500.000 | 500.000 | 500.000 | |||||
maxsectors | 384.503.808 | 769.277.952 | 246.988.800 | |||||
sectorsize | 512 | 512 | 512 |
* * To get comparable values for Nac and Nbs, the parameters are readed using the STR-H711 board,
since the highest possible CLK for SPI (on MMC and SD cards) is there 8MHz.
Board | MMC | MMCplus (HS-MMC) | SDxx | HS-SDxx |
ATMega128 | 7,3728MHz (MCLK/2) | |||
STR-H711 | 8MHz (MCLK/6) | |||
LPC1114 und LCP1343 | 19,2MHz | 48MHz | 24MHz | 48MHz |
LCP1769 | 12,5MHz | 50MHz | 25MHz | 50MHz |
LPC-H2148 | 12MHz | 24MHz | ||
STM32-H103 | 18MHz (PCLKx/2) | |||
AT91SAM7xxx | 15,9744MHz | 47,9232MHz | 23,9616MHz | 47,9232MHz |
AT91SAM3SxA Stick | 16(24)MHz | 48MHz | 24MHz | 48MHz |
SAMD21.. | 16(24)MHz | 48MHz | 24MHz | 48MHz |
Not supported cards:
The Transcend 4GB MMCplus can not be set into SPI Idle-state (GO_IDLE_STATE) |
A lock into a card? Why not ...
What's so special there?
The write-protect switch has no notifying connection to the inner life. That means, is the adapter / host ignoring the switch, you can (if not write-protect has been set by software) still write.
Why different values of maxsectors at cards with the same storage-size ?
In all MMC- and SD-cards a Wear-Leveling is used, to load the physical pages (max. erase-/writecycles of pages) evenly. To realize this, the user gets access to logical pages and these are recalculated to physical pages (like a table). This administration/table needs also one part of the flash-memory of course (and it's not allowed to use alltimes the same physical pages for this).
To Wear-Leveling there are many patents world-wide and since the takeover of M-Systems through SanDisk is this very centrally (-> licenses). But some few good ideas / alternative solutions are patent-free...
And here still some helpful links to the topic MMC/SD , SDHC and Wear-Leveling:
- 64MB MMC und PIC-Mikrocontroller
- Ulrich Radig (AVR/ARM-Projects)
- How to Use an MMC
- SanDisk - SD physical spec
- SanDisk - SD spec v1.9
- SanDisk - SD spec v2.2
- SanDisk - Application notes
- MMC - System Spec v3.31 (short version)
- MMC - System Spec v4.1 (short version)
- SanDisk - MultiMediaCard Product Manual
- Samsung - Comparison btw. MMC & SD (incl. MMC4.2 & SD2.0)
- About SDHC Memory Card
- Simplified Version of PHYSICAL LAYER SPEC V2.0
- ELM - How to support SDC Ver2 and high capacity cards
- Cardspeed - SD 2.00: SDHC with CSD 2.0
- Samsung - High Density MMC Application Note
- Intel - WearLeveling FTL
- M-Systems - Wear Leveling of TrueFSS
- SanDisk - WhitePaper Wear Leveling
- M-Systems - WhitePaper Increasin Life Expectancy of Flash