This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SK-AM62: using SD card functions inside MCU_PLUS_SDK

Part Number: SK-AM62

Hi experts,

I have a simple file system and I would like to combine it with the SD card functions to read files from an SD card. SD card is using instance 1 so I think I should use MMCSD1. 

first off, what clocks should I enable ? is it TISCI_DEV_MMCSD1_EMMCSDSS_XIN_CLK ? if yes, what should be its frequency? 200Mhz ? I'm saying this from the example in the SDK but it seems that example is for EMCC.

second, how can I change that example to make it read from an SD card instead of EMMC ? I'm referring to /examples/drivers/mmcsd/mmcsd_raw_io

please let me know how I can port this to use an SD card instead of EMMC.

Here is how ti_drivers_open_close looks like 

/*
* MMCSD
*/
/* MMCSD Device Data structures */
MMCSD_EmmcDeviceData gEmmcData0;

/* MMCSD temporary data buffers */
uint8_t gMmcsdDataBuf0[512U] __attribute__((aligned(128U)));;


/* MMCSD Driver handles */
MMCSD_Handle gMmcsdHandle[CONFIG_MMCSD_NUM_INSTANCES];

/* MMCSD Driver Parameters */
MMCSD_Params gMmcsdParams[CONFIG_MMCSD_NUM_INSTANCES] =
{
{
.deviceData = &gEmmcData0,
.dataBuf = &gMmcsdDataBuf0[0],
},
};

void Drivers_mmcsdOpen(void)
{
uint32_t instCnt;
int32_t status = SystemP_SUCCESS;

for(instCnt = 0U; instCnt < CONFIG_MMCSD_NUM_INSTANCES; instCnt++)
{
gMmcsdHandle[instCnt] = NULL; /* Init to NULL so that we can exit gracefully */
}

/* Open all instances */
for(instCnt = 0U; instCnt < CONFIG_MMCSD_NUM_INSTANCES; instCnt++)
{
gMmcsdHandle[instCnt] = MMCSD_open(instCnt, &gMmcsdParams[instCnt]);
if(NULL == gMmcsdHandle[instCnt])
{
DebugP_logError("MMCSD open failed for instance %d !!!\r\n", instCnt);
status = SystemP_FAILURE;
break;
}
}

if(SystemP_FAILURE == status)
{
Drivers_mmcsdClose(); /* Exit gracefully */
}

return;
}

void Drivers_mmcsdClose(void)
{
uint32_t instCnt;

/* Close all instances that are open */
for(instCnt = 0U; instCnt < CONFIG_MMCSD_NUM_INSTANCES; instCnt++)
{
if(gMmcsdHandle[instCnt] != NULL)
{
MMCSD_close(gMmcsdHandle[instCnt]);
gMmcsdHandle[instCnt] = NULL;
}
}

return;
}
Thanks a lot,
Seyed
  • there is also this in ti_drivers_config.c. how would this change if I use SD card on MMCSD1 ?

    /*
    * MMCSD
    */

    /* MMCSD attributes */
    static MMCSD_Attrs gMmcsdAttrs[CONFIG_MMCSD_NUM_INSTANCES] =
    {
    {
    .ctrlBaseAddr = CSL_MMCSD0_CTL_CFG_BASE,
    .ssBaseAddr = CSL_MMCSD0_SS_CFG_BASE,
    .inputClkFreq = 200000000U,
    .intrNum = 161U,
    .intrEnable = FALSE,
    .enableDma = TRUE,
    .phyType = MMCSD_PHY_TYPE_SW_PHY,
    .cardType = MMCSD_CARD_TYPE_EMMC,
    .busWidth = MMCSD_BUS_WIDTH_8BIT,
    .supportedModes = MMCSD_SUPPORT_MMC_DS | MMCSD_SUPPORT_MMC_HS_SDR,
    .tuningType = MMCSD_PHY_TUNING_TYPE_AUTO,
    },
    };
    /* MMCSD objects - initialized by the driver */
    static MMCSD_Object gMmcsdObjects[CONFIG_MMCSD_NUM_INSTANCES];
    /* MMCSD driver configuration */
    MMCSD_Config gMmcsdConfig[CONFIG_MMCSD_NUM_INSTANCES] =
    {
    {
    &gMmcsdAttrs[CONFIG_MMCSD0],
    &gMmcsdObjects[CONFIG_MMCSD0],
    },
    };

    uint32_t gMmcsdConfigNum = CONFIG_MMCSD_NUM_INSTANCES;
  • Hi Seyed,

    The code for clock configuration and all should be generated by Syscfg if you select MMC1

    Also, I suggest looking at the AM64x MCU+ SDK. This SDK has examples that support read/write from/to SD card. One of the example is SBL_SD bootloader which boots an application by reading an image named app.

    Regards,

    Prashant