I ran periph_sdmmc of LPCOpen v2.10 on an Embedded Artists OEM Base Board with an LPC4088 OEM Board. It worked fine with a version 2 SD card after I reversed the polarity of MCIPWR.
When I replaced the SD card with a version 1 SD card, all the disk operations returned a "Failed with rc=1".
I traced the problem to sendAppOpCond() in sdmmc_17xx_40xx.c that returned a "SDC_RET_FAILED". The comment of the code said that the host repeatedly issues ACMD41 for at least 1 second (8192 tries). But the code bailed after the first sendAppCmd() call that failed.
I commented out the else block of the "if (Ret == SDC_RET_OK)". During the second iteration of the while loop, the calls to sendAppCmd() and executeCmd() both returned SDC_RET_OK. And the rest of the tests ran without failure.
I am wondering whether I did the right thing to fix the problem.
STATIC int32_t sendAppOpCond(LPC_SDC_T *pSDC, uint16_t rca, bool hcs, uint32_t *pOcr, bool *pCCS) { int32_t Ret = SDC_RET_FAILED; SDC_RESP_T Response; uint32_t Argument; uint32_t RetryCnt = 0x2000; /* The host repeatedly issues ACMD41 for at least 1 second or until the busy bit are set to 1 */ Argument = ACMD41_OCR(*pOcr); if (hcs) { Argument |= ACMD41_HCS; } while (RetryCnt > 0) { Ret = sendAppCmd(pSDC, rca); if (Ret == SDC_RET_OK) { Ret = executeCmd(pSDC, SD_ACMD41_SD_SEND_OP_COND, Argument, &Response); if (Ret == SDC_RET_OK) { if (Response.Data[0] & CMDRESP_R3_INIT_COMPLETE) { if (*pOcr == 0) { *pOcr = CMDRESP_R3_OCR_VAL(Response.Data[0]); return SDC_RET_OK; } if ((CMDRESP_R3_OCR_VAL(Response.Data[0]) & *pOcr) != *pOcr) { return SDC_RET_BAD_PARAMETERS; } *pCCS = (Response.Data[0] & CMDRESP_R3_HC_CCS) ? true : false; return SDC_RET_OK; } } } // else { // return Ret; // } RetryCnt--; } return SDC_RET_FAILED; }