/SDCard

Portable SDCard controller

Primary LanguageVHDLMIT LicenseMIT

SDCard

This repository contains a portable OpenSource SDCard controller for FPGAs written in VHDL. I'm writing my own implementation because I've looked at several other implementations, and they all seemed lacking in various regards (features, stability, portability, simplicity, etc.).

The SDCard controller in this repository is a complete rewrite from scratch, and is provided with a MIT license.

This implementation only supports the 4-bit SD mode, i.e. it doesn't support the 1-bit SD mode, nor does it support the SPI mode. There are plenty of open-source implementations that support SPI mode. It is aimed at being fast (high-speed), small, and portable.

Resources

The doc folder contains useful resources, including

The sim folder contains the files needed for testing in simulation

Testing

The SD Card I'm testing on is a 32 GB SDHC card from SanDisk with a speed class of 10 MB/s.

This card responds to CMD8 and therefore supports V2.X of the SD protocol. Additionally, it responds with CCS set (= SDHC).

The CID 035344534333324780B90C4E7F0138 is decoded as follows:

field value interpretation
MID 03 SanDisk
OID 5344 SD
PNM 5343333247 SC32G
PRV 80 8.0
PSN B90C4E7F Serial Number
MDT 138 August 2019

The CSD 400E00325B590000EDC87F800A4040 is decoded as follows:

field value interpretation
CSD_STRUCTURE 01 SDHC
(TAAC) 0E 1.0 ms
(NSAC) 00 0 clocks
(TRAN_SPEED) 32 25 Mb/s
CCC 5B5 0, 2, 4, 5, 7, 8, 10
(READ_BL_LEN) 9 512 bytes
(READ_BL_PARTIAL) 0 No
(WRITE_BLK_MISALIGN) 0 No
(READ_BLK_MISALIGN) 0 No
DSR_IMP 0 DSR not implemented
C_SIZE EDC8 31 GB
(ERASE_BLK_EN) 1 Yes
(SECTOR_SIZE) 7F 64 kB
(WP_GRP_SIZE) 00 1 sector
(WP_GRP_ENABLE) 0 No
(R2W_FACTOR) 2 factor 4
(WRITE_BL_LEN) 9 512 bytes
(WRITE_BL_PARTIAL) 0 No
(FILE_FORMAT_GRP) 0 File format group
COPY 1 copy flag
PERM_WRITE_PROTECT 0 No
TMP_WRITE_PROTECT 0 No
(FILE_FORMAT) 0 Hard disk with partition table