Posts

Showing posts from March, 2018

Effect of file-system on sd card's performance

Image
I had a task to compare different protocols( and their different implementations) like SD, SPI, SDIO(in FreeBSD's MMCCAM implementation) by accessing SD Card. Now, for unbiased comparison, i must eliminate file system type in sd card from the equation. In this blog post, i'll discuss/share my findings about how file-system on a card(SD and MMC) affect its performance. So, let's start with a very quick introduction to some basic concepts: Introduction MMC- M ulti m edia C ard is a memory card unveiled in 1997 by SanDisk and Siemens based on NAND flash memory. eMMC is a regular MMC in a BGA package. SD Card: S ecure D igital Card was introduced in 1999 based on MMC but adding extra features such as security. INSIDE MMC [caption id="" align="alignright" width="321"] https://www.ibm.com/developerworks/linux/library/l-flash-filesystems/figure1.gif[/caption] MMC is made up of broadly 3 parts: MMC interface - Responsible for handling communi

Implementing a MMC/SD/SDIO stack using CAM framework(Part 2)

Image
Hi, In the next part lets look at other files which makes up the SDIO stack within mmccam framework. Please have  a look at previous part for more info: http://81.4.107.225/wordpress/index.php/2018/03/19/implementing-a-mmc-sd-sdio-stack-using-cam-framework/ mmc_sdio.c +void sdio_fill_mmcio_rw_direct(union ccb *ccb, uint8_t f, uint8_t wr, uint32_t adr, uint8_t *data) { + struct ccb_mmcio *mmcio; + + CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, + ("sdio_fill_mmcio(f=%d, wr=%d, adr=%02x, data=%02x)\n", f, wr, adr, (data == NULL ? 0 : *data))); + mmcio = &ccb->mmcio; + + mmcio->cmd.opcode = SD_IO_RW_DIRECT; + mmcio->cmd.arg = SD_IO_RW_FUNC(f) | SD_IO_RW_ADR(adr); + if (wr) + mmcio->cmd.arg |= SD_IO_RW_WR | SD_IO_RW_RAW | SD_IO_RW_DAT(*data); + mmcio->cmd.flags = MMC_RSP_R5 | MMC_CMD_AC; + mmcio->cmd.data->len = 0; +} sdio_fill_mmcio_rw_direct is basically a wrapper for CMD_52 that's needed

Detailed SDIO protocol Implementation

Image
Reference: Wikipedia, https://www.sdcard.org/developers/overview/sdio/sdio_spec/Simplified_SDIO_Card_Spec.pdf  SDIO cards are intended to provide high speed data Input/Output on our regular sd card slot. SDIO cards are compatible with any sd card slot and will not cause any physical damage to the host if it's not compatible with SDIO. When SDIO is plugged in a SDIO compatible host, in its early stage it is in low power mode and consumes very little current. Host identifies the SDIO card ,it's power requirement, it's I/O capabilities etc. If host finds that power requirement is manageable and there is driver for the I/O functionality card is offering it allows the SDIO card to power up completely and start it's I/O functions.  SDIO card allows up to 7 different I/O functions along with 1 memory function. It's available in market in 2 form factors: miniSDIO and full size SDIO. For example http://www.spectec.com.tw/sdw-822..html is a miniSDIO wifi card by spectec. Typ

Implementing a MMC/SD/SDIO stack using CAM framework(Part 1)

Image
In this blog post we will have a detailed look at all the files added/changed while implementing the MMC/SD/SDIO stack via CAM framework. We will basically discuss the commit  https://github.com/freebsd/freebsd/commit/a87c7a85be3e3727b6b08b19741b4282f942400d which aims at adding MMC/SD/SDIO stack to FreeBSD's already existing CAM framework. So, lets start one by one with each file: mmc.h #ifndef CAM_MMC_H #define CAM_MMC_H #include <dev/mmc/mmcreg.h> /* * This structure describes an MMC/SD card */ struct mmc_params { u_int8_t model[40]; /* Card model */ /* Card OCR */ uint32_t card_ocr; /* OCR of the IO portion of the card */ uint32_t io_ocr; /* Card CID -- raw and parsed */ uint32_t card_cid[4]; struct mmc_cid cid; /* Card CSD -- raw */ uint32_t card_csd[4]; /* Card RCA */ uint16_t card_rca; /* What kind of card is it */ uint32_t card_features; #define CARD_FEA