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.

StarterWare AM335X SD card and MSC problem

I'm using evmskAM335x and trying to use SD card as  USB mass storage (MSC) 

I modify the usb_host_msc example and make it to read and write from sd card ,but it always crash while read the sd card .

I find that maybe it was DMA's problem , can anyone help me to fix it ? 

  • user4181497,

    Please download and try out the mmcsd_app_fs_shell test project from the latest ProcessorSDK package. Its location is:

    C:\ti\pdk_am335x_1_0_0\packages\ti\starterware\examples\mmcsd\fs_shell\ccs

    I believe this SD card example is what you are looking for on the AM335xSK. Hope this helps.

    Lali

  • hi Lali,

    thanks for your reply, but the problem is still remain

    I combine two example "hs_mmcsd" and "usb_dev_msc" from AM335X_StarterWare_02_00_01_01  to make SD card as USB Mass storage device

    and it is a non OS system ,so your suggest is not for my question.

    and following is my code 

    int main(void)
    {
    /* Setup the MMU and do necessary MMU configurations. */

    MMUConfigAndEnable();

    /* Enable all levels of CACHE. */
    CacheEnable(CACHE_ALL);

    /* Initialize console for communication with the Host Machine */
    ConsoleUtilsInit();
    ConsoleUtilsSetType(CONSOLE_UART);

    USB0ModuleClkConfig();

    USBInterruptEnable();
    DelayTimerSetup();
    /* Configuring AINTC to receive USB interrupts. */

    UPDNPinControl();

    g_ulIdleTimeout = USBMSC_ACTIVITY_TIMEOUT;
    g_ulFlags = 0;
    g_eMSCState = MSC_DEV_IDLE;

    USBDMSCInit(0, (tUSBDMSCDevice *)&g_sMSCDevice);

    #ifdef DMA_MODE
    Cppi41DmaInit(USB_INSTANCE, epInfo, NUMBER_OF_ENDPOINTS);

    for(;g_bufferIndex < NUM_OF_RX_BDs; g_bufferIndex++)
    {
    dataBuffer = (unsigned char *)cppiDmaAllocBuffer();
    doDmaRxTransfer(USB_INSTANCE, USB_MSC_BUFER_SIZE, dataBuffer,
    g_sMSCDevice.psPrivateData->ucOUTEndpoint);
    }
    #endif
    /* Configure the EDMA clocks. */

    EDMAModuleClkConfig();

    /* Configure EDMA to service the HSMMCSD events. */
    HSMMCSDEdmaInit();

    /* Perform pin-mux for HSMMCSD pins. */
    HSMMCSDPinMuxSetup();

    /* Enable module clock for HSMMCSD. */
    HSMMCSDModuleClkConfig();

    DelayTimerSetup();

    /* Basic controller initializations */
    HSMMCSDControllerSetup();

    /* Initialize the MMCSD controller */
    MMCSDCtrlInit(&ctrlInfo);

    MMCSDIntEnable(&ctrlInfo);
    if((HSMMCSDCardPresent(&ctrlInfo)) == 1)
    {
    if(initFlg)
    {
    HSMMCSDFsMount(0, &sdCard);
    initFlg = 0;
    }
    }
    while(1){

    if(g_ulIdleTimeout != 0)
    {
    g_ulIdleTimeout--;
    }
    g_ulIdleTimeout = USBMSC_ACTIVITY_TIMEOUT;
    }
    }

     and the disk read for sd card is just like following code

    DRESULT disk_read (

    BYTE drv, /* Physical drive number (0) */
    BYTE* buff, /* Pointer to the data buffer to store read data */
    DWORD sector, /* Physical drive nmuber (0) */
    BYTE count) /* Sector count (1..255) */
    {
    if (drv == DRIVE_NUM_MMCSD)
    {
    mmcsdCardInfo *card = fat_devices[drv].dev;
    /* READ BLOCK */
    // ConsoleUtilsPrintf(" disk_read here\n");

    if (MMCSDReadCmdSend(card->ctrl, buff, sector, count) == 1)
    {
    // ConsoleUtilsPrintf(" disk_read ok\n");
    return RES_OK;
    }
    }
    return RES_ERROR;
    }

    and the MSC system is always crash at MMCSDReadCmdSend 

    thank you