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:


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

pCFAT_Port_SPI.zip
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:
SPI-master 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.


pC_FAT MMC_SD_Port_1.jpg
Card

MMC
16MB

Infineon

MMC
32MB

Infineon

MMC
64MB

Transcend

MMC
128MB

SanDisk

MMC
1GB

Hama

MMCmicro
512MB

X4store

RS-MMC
32MB

SanDisk

MMCmobile
64MB

Transcend

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


pC_FAT MMC_SD_Port_2.jpg
Card

MMCmobile
512MB

Transcend

MMCmobile
1GB

extreme

MMCmobile
2GB
green
memory

MMCmobile
2GB

Kingston

MMCplus
512MB

Transcend

MMC
1GB

extreme

MMCplus
2GB

Transcend

MMCplus
4GB

Pretec

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


pC_FAT MMC_SD_Port_3.jpg
Card

M-Bridge
1GB

Hama

SD
16MB

Panasonic

microSD
128MB

Prima

SD
128MB

SanDisk

SD
512MB

Formel1

SD
1GB
133x
SanDisk

miniSD
1GB

SanDisk

microSD
1GB

Hama

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


pC_FAT MMC_SD_Port_4.jpg
Card

SD
1GB

Fuji

SD
1GB

premium

SD
1GB
80x
Transcend

SD
2GB
plus USB
ATTiA

microSD
2GB

SanDisk

microSD
2GB

Transcend

SD
2GB

Kingston

SD
2GB

Panasonic

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


pC_FAT MMC_SD_Port_5.jpg
Card

SD
2GB

premium

SD
2GB

Transcend

SD
2GB
Ultra-II
SanDisk

SD
4GB

memoQ

SD      /      SDHC
4GB

Transcend

SDHC
4GB

Transcend

SDHC
4GB

SanDisk

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


pC_FAT MMC_SD_Port_6.jpg
Card

SDHC
4GB

Fuji

SDHC
4GB
green
memory

SDHC
4GB

Kingston

SDHC
4GB

Panasonic

SDHC
4GB
Ultra-II
SanDisk

SDHC
4GB

Toshiba

microSDHC
4GB

SanDisk

microSDHC
4GB

Hama

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


pC_FAT MMC_SD_Port_7.jpg
Card

microSDHC
8GB

SanDisk

microSDHC
8GB

Transcend

SDHC
8GB

Reekin

SDHC
8GB
green
memory

SDHC
16GB

Panasonic

SDHC
16GB

Transcend

SDHC
16GB

takeMS

SDHC
16GB

PNY

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


pC_FAT MMC_SD_Port_8.jpg
Card

microSDHC
16GB

SanDisk

SDHC
32GB
green
memory

microSDHC
32GB

ADATA

microSDHC
32GB

Samsung

SDXC
64GB

Transcend

microSDXC
64GB
SanDisk /
Team

SDXC
128GB
Komputer
Bay

microSDXC
128GB

SanDisk

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


* * 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.






BoardMMCMMCplus
(HS-MMC)
SDxxHS-SDxx
ATMega1287,3728MHz (MCLK/2)
STR-H7118MHz (MCLK/6)
LPC1114 und LCP134319,2MHz48MHz24MHz48MHz
LCP176912,5MHz50MHz25MHz50MHz
LPC-H214812MHz24MHz
STM32-H10318MHz (PCLKx/2)
AT91SAM7xxx15,9744MHz47,9232MHz23,9616MHz47,9232MHz
AT91SAM3SxA Stick16(24)MHz48MHz24MHz48MHz




Not supported cards:

pC_FAT MMC_4GB-Transcend.jpg

The Transcend 4GB MMCplus can not be set into SPI Idle-state (GO_IDLE_STATE)
(card 394426 01 03)




A lock into a card? Why not ...


inside Panasonic SD 16MB


inside memoQ SD 4GB


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:



X

SD card versions


X

ATMega128_DevMaster


X

STR-H711


X

LPCXpresso LPC1114


X

LPCXpresso LPC1343


X

LPCXpresso LPC1769


X

LPC-H2148


X

STM32-H103


X

MCBSTM32


X

SAM7Sxx_DevMaster


X

SAM7XCxx_DevMaster


X

SAM7SExx_DevMaster


X

SAM3SxA_Stick Board


X

inside Panasonic SD 16MB


X

inside memoQ SD 4GB