AnsweredAssumed Answered

SDK Bug in MMC code with DDR device

Question asked by Padraig Fogarty on May 8, 2019
Latest reply on May 14, 2019 by soledad

I'm using a LPC54608 with an external IS21ES04G eMMC memory device (which supports DDR) and I believe there is a bug in the SDK code (see fragment below) which causes the incorrect eMMC bus interface to be selected.


When setting up an eMMC/MMC device the default card->busWidth value is kMMC_DataBusWidth1bit, therefore the switch statement below will always attempt to firstly select a DDR interface and because the eMMC device flags indicate that it does support DDR this configuration is selected. The subsequent MMC_TestDataBuswidth() and MMC_SetDataBusWidth() functions succeed and the interface is consequently set for DDR.


However, to the best of my knowledge the LPC546xx does not support DDR on the SD/MMC and SDIO interface, therefore data access to the external device will not function beyond this point.


The same problem arises for both 8-bit and 4-bit interfaces.


One work-around for this problem is to set the card->busWidth before calling the MMC_SetMaxDataBusWidth() function thereby forcing the switch/case statement to bypass the offending code and set the bus correctly to non-DDR mode.


BUT I would expect that the code should not allow an unsupported option to be selected in the first place.





static status_t MMC_SetMaxDataBusWidth(mmc_card_t *card, mmc_high_speed_timing_t targetTiming)

    status_t error = kStatus_Fail;
    switch (card->busWidth)
        case kMMC_DataBusWidth1bit:
        case kMMC_DataBusWidth8bitDDR:
            /* Test and set the data bus width for card. */
            if ((SDMMCHOST_NOT_SUPPORT != kSDMMCHOST_Support8BitBusWidth) &&
                (card->flags & (kMMC_SupportHighSpeedDDR52MHZ180V300VFlag | kMMC_SupportHighSpeedDDR52MHZ120VFlag)) &&
                ((targetTiming == kMMC_HighSpeedTiming) || (targetTiming == kMMC_HighSpeed400Timing)))
                if ((kStatus_Success == MMC_TestDataBusWidth(card, kMMC_DataBusWidth8bitDDR)) &&
                    (kStatus_Success == MMC_SetDataBusWidth(card, kMMC_DataBusWidth8bitDDR)))
                    error = kStatus_Success;
                    card->busWidth = kMMC_DataBusWidth8bitDDR;
                /* HS400 mode only support 8bit data bus */
                else if (card->busTiming == kMMC_HighSpeed400Timing)
                    return kStatus_SDMMC_SetDataBusWidthFailed;