Hello,
I like use an ARM LPC4357 with the eMMC Memory on SDIO interface. For testing the eMMC I used the program example from the MC4300\RL\FlashFS\SD_File folder and modified the SDIO_LPC43xx.c file. The example work fine up to 2GB memory, but I use memory between 8 and 32GB.
I can read the SEC_COUNT register over the extended CSD Register. The value is 0x00EA0000 (by 8GB Memory). I calculated a value for rval[2] byte of 0x3A7F. For managing the correct data size I modified the CSD field by sending CMD9 and changed the value at the CSD Structure register to CSD Version No. 1.1 (0x01) and moved my calculated block number size into rp[2].
My code example:
/*--------------------------- Command ----------------------------------------*/ BOOL Command (U8 cmd, U32 arg, U32 resp_type, U32 *rp) { /* Send a Command to Flash card and get a Response. */ U32 cmdval, ints, temp; /* Clear interrupt status */ LPC_SDMMC->RINTSTS = SDIO_RINTSTS_MSK; if(cmd == 0x01) arg = 0x40FF8080; cmdval = (cmd & 0x3F) | SDIO_CMD_RESP_CRC | SDIO_CMD_WAIT_PRV | SDIO_CMD_START; switch (resp_type) { case RESP_SHORT: cmdval |= SDIO_CMD_RESP_EXP; break; case RESP_LONG: cmdval |= SDIO_CMD_RESP_EXP | SDIO_CMD_RESP_LEN; break; } if (cmd == READ_BLOCK || cmd == READ_MULT_BLOCK || cmd == WRITE_BLOCK || cmd == WRITE_MULT_BLOCK ) { /* Set data expected and read/write bits */ cmdval |= SDIO_CMD_DATA_EXP | SDIO_CMD_WAIT_PRV; if (cmd == WRITE_BLOCK || cmd == WRITE_MULT_BLOCK) { cmdval |= SDIO_CMD_READ_WRITE; } } if ((cmd == SEND_OP_COND) || (cmd == SEND_APP_OP_COND) || (cmd == STOP_TRANS)) { /* Disable response CRC check */ cmdval &= ~SDIO_CMD_RESP_CRC; } /* Send the command */ LPC_SDMMC->CMDARG = arg; LPC_SDMMC->CMD = cmdval; if (resp_type == RESP_NONE) { /* Wait until command finished */ while (!(LPC_SDMMC->RINTSTS & SDIO_RINTSTS_CDONE)); return (__TRUE); } for (;;) { ints = LPC_SDMMC->RINTSTS; if (ints & (SDIO_RINTSTS_RE | SDIO_RINTSTS_RCRC | SDIO_RINTSTS_RTO)) { /* Response error, CRC error, response timeout */ return (__FALSE); } if (ints & SDIO_RINTSTS_HLE) { /* Hardware locked write */ LPC_SDMMC->CMD = cmdval; } if (ints & SDIO_RINTSTS_CDONE) { /* Command done */ if (cmdval & SDIO_CMD_DATA_EXP) { if (ints & (1 << 3)) { break; } } else break; } } /* Read MCI response registers */ rp[0] = LPC_SDMMC->RESP0; if (resp_type == RESP_LONG) { rp[0] = LPC_SDMMC->RESP3; rp[1] = LPC_SDMMC->RESP2; rp[2] = LPC_SDMMC->RESP1; rp[3] = LPC_SDMMC->RESP0; if(cmd == 0x09){ rp[0] &= 0x3FFFFFFF; rp[0] |= 0x40000000; //CSD Structure "CSD Version No. 1.1" rp[2] &= 0x0000FFFF; rp[2] |= 0x3A7F0000; //Size for 8GB eMMC } } return (__TRUE); }
When I started the example the memory was correctly initialized and when I was asked if to format the memory I confirmed with yes. The memory was formatted and I received “Memory Card Formatted”. But he repeats the formatting question over and over again. When I over jump the formatting routine in the init function and send the formatting command “FORMAT TEST /FAT32” manually, I get a correct init and by sending the dir command I see the correct memory size. I can save and read a text file on the memory. But when I reset the LPC4357 EVAL-Board and send the dir command the memory size was zero. By re-sending the format command the memory size is correct and I see the old saved text files.
I think the addressing of the eMMC is wrong, but can i change this? use someone a emmc greater as 2GB and have a example code for me?
Thanks for help!
OK I tested by fake the sending address from byte addressing to sector addressing (Sectoraddr = Byteaddr / 512) the memory works fine, but I can’t use memory greater than 4GB.
The main Problem is that internal FlashFS function knows no sector addressing for MMC. Can I edit my program, so that the FlashFS function handles the eMMC memory with sector addressing instead byte addressing?