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.

Create File System (RTFS) for two SD cards

Other Parts Discussed in Thread: OMAPL138

Hi,

I try to create the file system of two SD cards for C6748 using RTFS (1.10.02.32). The sample code works on the EVM board. Then I modified the code on our own board. But I can only get one SD card works, not both. Here is the code I am using.

#define MMC_INTERNAL_INST_ID                     0U

#define MMC_EXTERNAL_INST_ID                     1U

 

void MMCSD_Init()

{

Int32 result;

/* DSP/BIOS File System initialization */

result = mmcsdStorageInit();

 

if (result == IOM_COMPLETED) {

        printf("Block Driver initialization succeeded.\n");

        }

       else {

        //Most likely not enough memory

        printf("Block Driver initialization failed, error = %d.\n", result);

        return;

       }

PSP_MmcsdConfig mmcsdConfig;

    mmcsdConfig.opMode = PSP_MMCSD_OPMODE_DMAINTERRUPT;

    mmcsdConfig.hEdma = hEdma[0];

    mmcsdConfig.eventQ = PSP_MMCSD_EDMA3_EVENTQ_0;

        mmcsdConfig.hwiNumber = 12u;

    mmcsdConfig.pscPwrmEnable = FALSE;/* default no power management reqd */

      mmcsdConfig.pllDomain = PSP_MMCSD_PLL_DOMAIN_0;

    result = PSP_mmcsdDrvInit(MMCSD_CLK_FREQ, MMC_INTERNAL_INST_ID, &mmcsdConfig);

 

if (IOM_COMPLETED != result)

{

   //Init MMCSD fail

printf("Internal SD initialization failed, error = %d.\n", result);

//return;

}

else

printf("Internal SD initialization succeeded.\n");

 

m_bIntSDCardPresent = isCardPresent(MMC_INTERNAL_INST_ID);

if(m_bIntSDCardPresent)

{

// Get drive letter associated with MMC/SD

result = getdriveid(BFS_DEVICE_TYPE_MMC, 0, 0, m_InternalDriveId);

 

if (result != -1)

{

printf("Get Internal SD drive ID DONE. %s\n", m_InternalDriveId);

}

else

{

printf("Error getting drive ID for Internal SD.\n");

m_bIntSDCardPresent = false;

}

}

mmcsdConfig.opMode = PSP_MMCSD_OPMODE_DMAINTERRUPT;

mmcsdConfig.hEdma = hEdma[0];

    mmcsdConfig.eventQ = PSP_MMCSD_EDMA3_EVENTQ_0;

  mmcsdConfig.hwiNumber = 12u;

 mmcsdConfig.pscPwrmEnable = FALSE;/* default no power management reqd */

    mmcsdConfig.pllDomain = PSP_MMCSD_PLL_DOMAIN_0;

    result = PSP_mmcsdDrvInit(MMCSD_CLK_FREQ, MMC_EXTERNAL_INST_ID, &mmcsdConfig);

 

if (IOM_COMPLETED != result)

{

    //Init MMCSD fail

printf("External SD initialization failed, error = %d.\n", result);

}

else

printf("External SD initialization succeeded.\n");

 

m_bExtSDCardPresent = isCardPresent(MMC_EXTERNAL_INST_ID);

if(m_bExtSDCardPresent)

{

//Get drive letter associated with MMC/SD

result = getdriveid(BFS_DEVICE_TYPE_MMC, 0, 0, m_ExternalDriveId);

 

if (result != -1)

{

printf("Get External SD drive ID DONE. %s\n", m_ExternalDriveId);

}

else

{

printf("Error getting drive ID for External SD.\n");

m_bIntSDCardPresent = false;

}

}

}

 

It always failes on 

result = getdriveid(BFS_DEVICE_TYPE_MMC, 0, 0, m_InternalDriveId);

the result = -1.

 

It will find the external SD using 

result = getdriveid(BFS_DEVICE_TYPE_MMC, 0, 0, m_ExternalDriveId);

and assigns "A" to external SD.

 

If I use result = getdriveid(BFS_DEVICE_TYPE_MMC, 1, 0, m_ExternalDriveId); 

Then it will fail too. 

Could someone help me about how to create file system for two SD cards?

 

Thanks,

 

Yi

 

  • Forgot one function.

    int mmcsdStorageInit()

    {

        Int32 result = IOM_COMPLETED;

        EDMA3_DRV_Result edmaResult;

     

        /* Initialize the EDMA */

        if (NULL == hEdma[0])

        {

        edmaResult = edma3init();

        if (EDMA3_DRV_SOK != edmaResult)

        {

            /* EDMA Initialization Failed */

            result = edmaResult;

            return result;

        }

        }

     

        result = PSP_blkmediaDrvInit(hEdma[0], 0x00, 0x02u, 4096u);

        if (IOM_COMPLETED == result)

        {

        //success

            //result = initMmcsd(hEdma[0], uInstanceId);

            //if (IOM_COMPLETED != result)

            //{

                /* Init MMCSD fail */

            //}

        }

        else

        {

            /* Block media Init fail */

        }

     

        return result;

    }

  • Yi,

       Can you provide any more information about the failures on your board? For example, is there any HW difference between the two MMC/SD ports? Can you get either of the 2 MMC/SD ports to work in a mutually exclusive mannor, or can you only get one to work?

     

    Have you confirmed that the Pinmux is appropriate set up? Are both MMC/SD ports active using the PSC?

     

  • Hi Drew,

    Thank you for your help.

    There are no different between the two SD port. The Pinmux and are right and the ports are active.

    Right now I can access MMC/SD0 using Block Media+MMC/SD driver. I ported the sample code for block media from PSP. I can write some data and read back.

    I can also access MMC/SD1 using RTFS. I can create file, write and read.

    But I can not get a id from getdriveid() for the MMC/SD0.

    I found in the RTFS package, there is a setting inside "\rtfs_1_10_02_32\rtfs_1_10_02_32\packages\ti\rtfs\config\fsadaptmem.h". 

    #define MMC_CFG_NUM_DEVICES                             1

    Should I try to chage it to 2 and rebuild the "mmcsd_configuration" project? But when I rebuild it, I got an error

    "Severity and Description Path Resource Location Creation Time Id

    can't locate the package 'ti.rtfs.xdcconfig' along the path: 'C:/packages;C:/CCS_V4/bios_6_32_02_39/packages;C:/CCS_V4/ipc_1_23_02_27/packages;C:/examples;C:/CCS_V4/xdctools_3_22_01_21/packages;..;'. Ensure that the package path is set correctly. mmcsd_configuration mmcsdSample.cfg line 14 1323274173264 59".

    And it points to line 14 of "mmcsdSample.cfg" filr 

    xdc.useModule('ti.rtfs.xdcconfig.Rtfs');.

    But I can not fin this file inside the RTFS package.

     

    Thanks,

     

    Yi

  • Sorry, I found the  "mmcsd_configuration" project is for BIOS6. I am using BIOS5. What I need to do with BIOS5?

    Thanks,

    Yi

  • More detail about our configuration.

    We use both the MMC/SD0 and MMC/SD1. One (MMC/SD0) for internal and cannot be removed. The other one for external and can be remove from our gage. The board configuration is based on EVM board. Just add MMC/SD1. Same configuration.

     

    I also wrote the software based on the sample code from RTFS_1_23_05_40. I am build our project on CCS5 with BIOS 5.41.11.38 and PSP 1.30.01.

     

    AS the code shown below, after init the MMC/SD and Block Media, I call the RTFS function

    result = getdriveid(BFS_DEVICE_TYPE_MMC, 0, 0, m_InternalDriveId);          

    but I always can “-1” as return. The RTFS package does not include source code. So I cannot debug into it.

     

    I when I can the same function for the extern SD, if I use

     

    result = getdriveid(BFS_DEVICE_TYPE_MMC, 1, 0, m_ExternalDriveId);          

     

    it failed. If I use

     

    result = getdriveid(BFS_DEVICE_TYPE_MMC, 0,  0, m_ExternalDriveId); 

     

    it success. I can then create file, write and read. But it Write to the MMC/SD0 (the internal one) instead of MMC/SD1.

     

    I think somehow the RTFS system think I only have one SD card present and it is MMC/SD0.

     

    I found there is a setting inside “C:\TI\rtfs_1_10_02_32\packages\ti\rtfs\config\fsadaptmem.h”.

     

    #define MMC_CFG_NUM_DEVICES                             1

     

    I changed it to 2 and rebuild the configu project. But my code still got the same problem. Do I need to change more settings to use two SD card?

     

    I put my code again.

     

    if (NULL == hEdma[0])

    {

    edmaResult = edma3init();

      if (EDMA3_DRV_SOK != edmaResult)

      {

      printf("EDMA Initialization Failed .\n");

      return;

     

       }

    }

     

    result = PSP_blkmediaDrvInit(hEdma[0], 0x00, 0x09u, 4096u);

     

     

    if (result == IOM_COMPLETED) {

            printf("Block Driver initialization succeeded.\n");

     

        }

        else {

           //Most likely not enough memory

            printf("Block Driver initialization failed, error = %d.\n", result);

            return;

        }

     

    PSP_MmcsdConfig mmcsdConfig;

     

       mmcsdConfig.opMode = PSP_MMCSD_OPMODE_DMAINTERRUPT;

        mmcsdConfig.hEdma = hEdma[0];

    mmcsdConfig.eventQ = PSP_MMCSD_EDMA3_EVENTQ_0;

    mmcsdConfig.hwiNumber = 7u;

    mmcsdConfig.pllDomain = PSP_MMCSD_PLL_DOMAIN_0;

    mmcsdConfig.pscPwrmEnable = FALSE;/* default no power management reqd */

     

    result = PSP_mmcsdDrvInit(MMCSD_CLK_FREQ, 0, &mmcsdConfig);

     

    if (IOM_COMPLETED != result)

    {

       /* Driver init failed */

    }

    if (IOM_COMPLETED != result)

    {

       //Init MMCSD fail

    printf("Internal SD initialization failed, error = %d.\n", result);

    //return;

    }

    else

    printf("Internal SD initialization succeeded.\n");

     

    m_bIntSDCardPresent = isCardPresent(0);

    if(m_bIntSDCardPresent)

    {

    // Get drive letter associated with MMC/SD

    result = getdriveid(BFS_DEVICE_TYPE_MMC, 0, 0, m_InternalDriveId);

     

    if (result != -1)

    {

    printf("Get Internal SD drive ID DONE. %s\n", m_InternalDriveId);

     

    }

    else

    {

    printf("Error getting drive ID for Internal SD.\n");

    m_bIntSDCardPresent = false;

     

    }

     

     

     

    }

     

    mmcsdConfig.opMode = PSP_MMCSD_OPMODE_DMAINTERRUPT;

     

    mmcsdConfig.hEdma = hEdma[0];

    mmcsdConfig.eventQ = PSP_MMCSD_EDMA3_EVENTQ_1;

    mmcsdConfig.hwiNumber = 10u;

    mmcsdConfig.pllDomain = PSP_MMCSD_PLL_DOMAIN_1;

    mmcsdConfig.pscPwrmEnable = FALSE;/* default no power management reqd */

     

    result = PSP_mmcsdDrvInit(MMCSD_CLK_FREQ, 1, &mmcsdConfig);

    if (IOM_COMPLETED != result)

    {

       /* Driver init failed */

    }

     

     

    if (IOM_COMPLETED != result)

    {

        //Init MMCSD fail

    printf("External SD initialization failed, error = %d.\n", result);

     

    //return;

    }

    else

    printf("External SD initialization succeeded.\n");

     

    m_bExtSDCardPresent = isCardPresent(1);

     

    if(m_bExtSDCardPresent)

    {

    // Get drive letter associated with MMC/SD

    result = getdriveid(BFS_DEVICE_TYPE_MMC, 0, 0, m_ExternalDriveId);

     

    if (result != -1)

    {

     

    printf("Get External SD drive ID DONE. %s\n", m_ExternalDriveId);

     

    }

    else

    {

    printf("Error getting drive ID for External SD.\n");

    m_bIntSDCardPresent = false;

     

    }

     

  • Hi,

     

    I debug the "blkmedia.c" from PSP/blkmedia. I found this function.

     

    Int32 PSP_blkmediaDrvIoctl(Ptr *pDevName, PSP_BlkDrvIoctlInfo_t *pIoctl)

    {

        Int32           media;

        PSP_BlkDrvId_t  *device;

        Int32           err;

        Bool            flag = TRUE;

     

        do

        {

            /* Initialize the local variables as required                         */

            err = IOM_EBADARGS;

            flag = FALSE;

     

    /* Begin parameter checking                                                   */

    #ifndef PSP_DISABLE_INPUT_PARAMETER_CHECK

            if ((NULL == pIoctl) || (NULL == pDevName))

            {

                break;

            }

    #endif

    /* End parameter checking                                                     */

     

            switch (pIoctl->Cmd)

            {

                case PSP_BLK_DRV_SETRAWDEV:

                    device = (PSP_BlkDrvId_t*)pIoctl->pData;

                    /* Enforce the rule that we cannot have more than one media driver

                registered for RAW access, But will not fail if same device is send again*/

                if ((NULL == device) || ((gBlkmediaRawDev.BLKAPP_DEV != PSP_BLK_DRV_MAX) && (gBlkmediaRawDev.BLKAPP_DEV != (*device))))

                    {

                        err = IOM_EBADARGS;

                    }

                    else

                    {

                        switch (*device)

                        {

                            case PSP_BLK_DRV_MMC0:

                                gBlkmediaRawDev.BLKAPP_DEV = PSP_BLK_DRV_MMC0;

                                err = IOM_COMPLETED;

                                break;

    #if defined(CHIP_C6748) || defined(CHIP_OMAPL138)

                            case PSP_BLK_DRV_MMC1:

                                gBlkmediaRawDev.BLKAPP_DEV = PSP_BLK_DRV_MMC1;

                                err = IOM_COMPLETED;

                                break;

    #endif

                            case PSP_BLK_DRV_NAND:

                                gBlkmediaRawDev.BLKAPP_DEV = PSP_BLK_DRV_NAND;

                                err = IOM_COMPLETED;

                                break;

                            case PSP_BLK_DRV_USB0:

                                gBlkmediaRawDev.BLKAPP_DEV = PSP_BLK_DRV_USB0;

                                err = IOM_COMPLETED;

                                break;

                            case PSP_BLK_DRV_USB1:

                                gBlkmediaRawDev.BLKAPP_DEV = PSP_BLK_DRV_USB1;

                                err = IOM_COMPLETED;

                                break;

    #if defined(CHIP_C6748) || defined(CHIP_OMAPL138)

                            case PSP_BLK_DRV_ATA0:

                                gBlkmediaRawDev.BLKAPP_DEV = PSP_BLK_DRV_ATA0;

                                err = IOM_COMPLETED;

                                break;

                            case PSP_BLK_DRV_ATA1:

                                gBlkmediaRawDev.BLKAPP_DEV = PSP_BLK_DRV_ATA1;

                                err = IOM_COMPLETED;

                                break;

    #endif

                            default:

                                err = IOM_EBADARGS;

                        }

                    }

                    break;

     

                case PSP_BLK_DRV_GETRAWDEV:

                    *((PSP_BlkDrvId_t*)pIoctl->pData) = gBlkmediaRawDev.BLKAPP_DEV;

                    err = IOM_COMPLETED;

                    break;

     

                case PSP_BLK_DRV_SET_INIT_COMP_CALLBACK:

                    media = *((PSP_BlkDrvId_t*)pDevName);

                    gBlkmediaInfo[media].InitCallback = \

                        (BLK_DRV_InitCallback_t)(Uint32)pIoctl->pData;

                    err = IOM_COMPLETED;

                    break;

     

                default:

                    err = IOM_EBADARGS;

            }

        }while (flag);

     

        return err;

    }

     

    It looks like the block media can only have ONE driver! Is that true for RTFS system? Only ONE drive?

     

    Thanks,

     

    Yi

  • Hi,

     

    Any suggestion?

     

     I still got problem to use two SD cards with the RTFS.

     

    For the RTFS, it always fails at “getdriveid(BFS_DEVICE_TYPE_MMC, uInstanceId, 0, m_DriveId)” for MMC/SD1. MMC/SD0 is ok. Does RTFS supports two SD?

     

     I also tried only use Block Media to write some raw  data to the SD cards.

     

     But fails on “PSP_blkmediaAppRegister()” for the first one(MMC/SD0). Inside this function, it fails on “BLK_DEV_MAXQUEUE == gBlkmediaInfo[device].AvailReq”. The “gBlkmediaInfo[device].AvailReq” is “4” not BLK_DEV_MAXQUEUE(5). Do not know why is not 5?

     

     Then fails on the second one (MMC/SD1) at PSP_blkmediaDrvIoctl using “PSP_BLK_DRV_SETRAWDEV” as command. Inside it fails at

     

    if ((NULL == device) || ((gBlkmediaRawDev.BLKAPP_DEV != PSP_BLK_DRV_MAX) && (gBlkmediaRawDev.BLKAPP_DEV != (*device))))

    {

         err = IOM_EBADARGS;

    }

     

    Because the gBlkmediaRawDev.BLKAPP_DFV is already assigned to MMC0. Even I call “PSP_blkmediaDrvDeInit”, still does not work.

     

    Please help.

     

    Thanks,

     

    Yi

  • Hi Yi,

    Yi Hou said:

     I also tried only use Block Media to write some raw  data to the SD cards.

     

     But fails on “PSP_blkmediaAppRegister()” for the first one(MMC/SD0). Inside this function, it fails on “BLK_DEV_MAXQUEUE == gBlkmediaInfo[device].AvailReq”. The “gBlkmediaInfo[device].AvailReq” is “4” not BLK_DEV_MAXQUEUE(5). Do not know why is not 5?

    The mmcsd sample (raw mode) application which comes with the BIOS PSP 1.30.01, works for MMCSD instance 0. Please try this, then it should work in raw mode. 

     In raw mode, you need to follow al the sequence mentioned in the 1.30.01 sample application for MMCSD to work (refer the userguide "C6748_BIOSPSP_Userguide.pdf" section 12.5). It also shows how to unregister the device.

    Once MMCSD 0 works then modify the same sample application to work for MMCSD 1 by modifying the instance ID appropriately (like changin the PINMUXING etc, refer file pspdrivers_01_30_01\packages\ti\pspiom\platforms\evm6748\src\mmcsd_evmInit.c and mmcsd_startup.c). Also refer the userguide "C6748_BIOSPSP_Userguide.pdf" section 12.5

    Let me know the result.

    Thanks and Regards,

    Sandeep K

  • Hi Sandeep,

    Thank you for your help.

    I did try the mmcsd sample code on EVM board (mmcsd0 only) without problem. But when I run the code on our board it failed on “PSP_blkmediaAppRegister()”.  Inside this function, it fails on “BLK_DEV_MAXQUEUE == gBlkmediaInfo[device].AvailReq”. The “gBlkmediaInfo[device].AvailReq” is “4”not BLK_DEV_MAXQUEUE(5).

    If I use the same code to test mmcsd1, (after change to mmcsd1), then inside  “PSP_blkmediaAppRegister()”, "gBlkmediaInfo[1].DevHandle"  is NULL! Still fails!

    Here is the code I am using. uInstanceId = 0/1, Id = PSP_BLK_DRV_MMC0/PSP_BLK_DRV_MMC1.

    Can you find any problem? Is it because we enable both mmcsd0 and mmcsd1 in Pinmux?

    Thanks,

     

    Yi

     

     

    if (NULL == hEdma[0])

    {

    edmaResult = edma3init();

      if (EDMA3_DRV_SOK != edmaResult)

      {

      printf("EDMA Initialization Failed .\n");

      return;

     

       }

    }

     

    result = PSP_blkmediaDrvInit(hEdma[0], 0x00, 0x06u, 4096u);

     

     

    if (result == IOM_COMPLETED) {

            printf("Block Driver initialization succeeded.\n");

     

        }

        else {

           //Most likely not enough memory

            printf("Block Driver initialization failed, error = %d.\n", result);

            return;

        }

     

    PSP_MmcsdConfig mmcsdConfig;

     

        mmcsdConfig.opMode = PSP_MMCSD_OPMODE_DMAINTERRUPT;

        mmcsdConfig.hEdma = hEdma[0];

     

     

     

    mmcsdConfig.eventQ = PSP_MMCSD_EDMA3_EVENTQ_0;

    mmcsdConfig.hwiNumber = 7u;

    mmcsdConfig.pllDomain = PSP_MMCSD_PLL_DOMAIN_0;

     

    mmcsdConfig.pscPwrmEnable = FALSE;

     

    result = PSP_mmcsdDrvInit(MMCSD_CLK_FREQ, uInstanceId, &mmcsdConfig);

     

    if (IOM_COMPLETED != result)

    {

       //Init MMCSD fail

    printf("SD initialization failed, error = %d.\n", result);

    //return;

    }

    else

    printf("SD initialization succeeded.\n");

     

    driverDev = Id;

        drvIoctlInfo.Cmd = PSP_BLK_DRV_GETRAWDEV;

        drvIoctlInfo.pData = (Ptr*)&driverDev;

        result = PSP_blkmediaDrvIoctl((Ptr*)&device, &drvIoctlInfo);

        printf(" MMCSD_SAMPLE: Currently %d device is set as a"

                            " Raw Device\n", driverDev);

     

        driverDev = Id;

        /*To set MMCSD as a RAW device at runtime, call PSP_blkmediaDrvIoctl()

        function with PSP_BLK_DRV_SETRAWDEV as a command */

        drvIoctlInfo.Cmd = PSP_BLK_DRV_SETRAWDEV;

        drvIoctlInfo.pData = (Ptr*)&driverDev;

        result = PSP_blkmediaDrvIoctl((Ptr*)&device, &drvIoctlInfo);

        if (result == IOM_COMPLETED)

        {

            printf(" MMCSD_SAMPLE: Ioctl for setting mmcsd device"

                                " as RAW device is successfull\n");

            driverDev = Id;

            drvIoctlInfo.Cmd = PSP_BLK_DRV_GETRAWDEV;

            drvIoctlInfo.pData = (Ptr*)&driverDev;

            result = PSP_blkmediaDrvIoctl((Ptr*)&device, &drvIoctlInfo);

            printf(" MMCSD_SAMPLE: Currently %d device is set as"

                                " a Raw Device\n", driverDev);

            /*The Media Driver clients like Mass Storage drivers shall use this

            function to register for a Block media device.*/

            result = PSP_blkmediaAppRegister(&blkMmcsdTestCallBack,

                         &pDevOps,

                         &handle);

            if (IOM_COMPLETED == result)

            {

               printf(" MMCSD_SAMPLE: Media for remote client"

                                    " is regsitered\n");

            }

            else

            {

                printf(" MMCSD_SAMPLE: Media for remote client"

                                    " can not regsitered\n");

                return false;

            }

            if ((NULL == handle) || (NULL == pDevOps))

            {

                printf(" MMCSD_SAMPLE: Invalid handle\n");

                return false;

            }

     

            semAttr.name = (String)"Mmcsd_Blk_Sema";

            mmcsdCbSem = SEM_create(0U, &semAttr);

            if (NULL == mmcsdCbSem)

            {

                printf(" MMCSD_SAMPLE: Sem mmcsdCbSem  Create failed\n");

            }

     

            TSK_sleep(500U);

            checkBlockMediaIoctl(pDevOps, handle);

            checkMmcsdIoctl(PSP_BLK_DRV_MMC0);

            cnt = sectorCount * 512U;

     

            loopCnt = 10U;

     

            while (loop < loopCnt)

            {

                for (i = 0; i < cnt; i++)

                {

                    srcmmcsdBuf[i] = i + addr + (loop*1000);

                    dstmmcsdBuf[i] = 0;

                }

     

                result = pDevOps->Blk_Write(handle, (Ptr)&mmcsdRespInfo,

                                            srcmmcsdBuf, addr, sectorCount);

                if (result == IOM_PENDING)

                {

                    SEM_pend(mmcsdCbSem, SYS_FOREVER);

                    printf(" MMCSD_SAMPLE: BLK write passed & loop"

                                        " count is %d \n",loop);

                }

                else if (result != IOM_COMPLETED)

                {

                    printf(" MMCSD_SAMPLE: Error returned from"

                                        " function Blk_Write while writing\n");

     

                    isCardPresent(MMC_INTERNAL_INST_ID);

                    addr = 0;

                }

                else

                {

                    SEM_pend(mmcsdCbSem, SYS_FOREVER);

                    printf(" MMCSD_SAMPLE: BLK write passed & loop"

                                        " count is %d\n", loop);

                }

     

                result = pDevOps->Blk_Read(handle, (Ptr)&mmcsdRespInfo,

                                           dstmmcsdBuf, addr, sectorCount);

                if (result == IOM_PENDING)

                {

                    SEM_pend(mmcsdCbSem, SYS_FOREVER);

                    printf( " MMCSD_SAMPLE: BLK read passed & loop"

                                        " count is %d\n ",loop);

                }

                else if (result != IOM_COMPLETED)

                {

                    printf(" MMCSD_SAMPLE:Error returned from"

                                        " function Blk_Read while reading\n");

     

                    isCardPresent(MMC_INTERNAL_INST_ID);

                    addr = 0;

                }

                else

                {

                    SEM_pend(mmcsdCbSem, SYS_FOREVER);

                    printf( " MMCSD_SAMPLE: BLK read passed & loop"

                                        " count is %d\n",loop);

                }

     

                for (i = 0; i < (sectorCount * 512U); i++)

                {

                    if (srcmmcsdBuf[i] != dstmmcsdBuf[i])

                    {

                        printf(" MMCSD_SAMPLE: BLK Data write-read"

                                            " matching failed at i = %d\n",i);

                        bRet = false;

                        break;

                    }

                }

                addr = addr + sectorCount;

                loop++;

            }

     

            /*The Media Driver clients like Mass Storage drivers shall use this

            function to un-register from a Block media device*/

            result = PSP_blkmediaAppUnRegister(handle);

            if (IOM_COMPLETED == result)

            {

                printf(" MMCSD_SAMPLE: Media for remote client is"

                                    " unregsitered\n");

            }

            else

            {

                printf(" MMCSD_SAMPLE: Media for remote client is"

                                    " not unregsitered\n");

            }

     

     

  • Hi Yi,

    Yi Hou said:

    I did try the mmcsd sample code on EVM board (mmcsd0 only) without problem. But when I run the code on our board it failed on “PSP_blkmediaAppRegister()”.  Inside this function, it fails on “BLK_DEV_MAXQUEUE == gBlkmediaInfo[device].AvailReq”. The “gBlkmediaInfo[device].AvailReq” is “4”not BLK_DEV_MAXQUEUE(5).

    If I use the same code to test mmcsd1, (after change to mmcsd1), then inside  “PSP_blkmediaAppRegister()”, "gBlkmediaInfo[1].DevHandle"  is NULL! Still fails!

     

    in blkmedia.c file, initially in the function PSP_blkmediaDrvInit(), the "AvailReq" is made equal to "BLK_DEV_MAXQUEUE". But by the time you reach the PSP_blkmediaAppRegister(), it got modified to 4. This we need to investigate.

    The "AvailReq" is incremented/decremented only in blkmediaAllocReq()/blkmediaRelReq(). Can you just put breakpoint inthes two function to see how the "AvailReq" is getting modified.

    Thnaks and Regards,

    Sandeep K

     

     

    Thanks and Regards,

    Sandeep K

  • Hi Sandeep,

    Thank you for your help.

    I found the problem for the RAW data test using blkmedia only. I should link "ti.pspiom.blkmedia.raw.a674", not "ti.pspiom.blkmedia.filesystem.a674". Now the SD0 working using the blkmedia testing code. 

    But the SD1 still has problem. When it try to write to the SD card, inside "blkmedia.c" function "blkmediaWriteAsync", it waits the SEM "asyncSema" and never return!

    /* Wait for transfer to be completed */
     if (SEM_pend(pDevice->asyncSema, SYS_FOREVER) != TRUE)
     {
    BLKMED_ERR_DEBUG(("\r\nBLK_MED: WAsyncSema take fail"));
    break;
    }
    I use the same code for SD0 and SD1.
    Also we NEED to use the RTFS system for both SD cards! Is there anyone knows the RTFS supports two SD cards?
    
    
    Thanks,
    Yi
  • I also used the test code from LogicPD BSL lib (use registers). I can read from both SD cards, but cannot write to both. It waits the DATDNE forever then time out!

    CHKBIT(mmcsd->MMCST0, DATDNE)

    Any ideal?

    Thanks again.

  • Hi Yi,

    I can help you with RTFS.

    I've just been looking over the thread and I would like to make sure that I understand some things correctly.  It looks like you said that when using the original EVM, you were able to successfully run the modified MMC/SD example to use 2 SD cards?  But when you moved to custom hardware, getdriveid() returned -1 at this point? Is that correct?

    Also, what priority is your task function (the one that calls getdriveid()) running at?  The PSP Block Media task, which performs some initialization with RTFS, runs at a priority of 2.  I have seen issues in the past with getdriveid() returning -1 due to the calling task running at a priority greater than 2 (http://e2e.ti.com/support/embedded/bios/f/355/t/130313.aspx#470701).

    Lastly, is it possible that you have any interrupt conflicts?  For example, I have also seen getdriveid() fail when multiple peripherals (e.g. EDMA, used by RTFS, and the EMAC driver) were configured to use the same interrupt number (http://e2e.ti.com/support/embedded/bios/f/355/t/112802.aspx#417020).

    Thanks,

    Steve

  • Hi Steve,

    Thanks you for your help!

    First I only tested SD0 on the EVM board because the EVM board only have one SD card.

    Second, the SD card task has priority 6. Should be ok, right?

    I also checked the interrupts again, there should not have conflicts. I even swap the interrupt between SD0 and SD1 but still only SD0 works! I try only use SD1 without init SD0, but still failed at getdriveid(). Is it the right way to call this function for SD1?

    getdriveid(BFS_DEVICE_TYPE_MMC, 1, 0, m_DriveId);

    I read the Block Media document and it said it only support one device at one time, is it right?

    I used some test code from LogicPD BSL on our board and I can read/write to both SD cards! So there should be no problem on hardware side.

    Thanks,

    Yi

  • Sorry, one thing wrong with my reply.

    The priority should less then 2, right? I will try that and tell you the result.

    But why SD0 is Ok?

    Thanks,

  • Hi Yi,

    Can you try running your program again for the case of 2 SD cards?

    For each one that's inserted, the PSP Block Media driver should call the RTFS function pc_rtfs_media_insert().

    Can you put a break point at pc_rtfs_media_insert and then run your program and see how many times it is called?

    Here's some further information (from rtfsblkmedia.h) regarding how the RTFS hooks up with the PSP Block Media drivers.  There is some information regarding the 2 MMC/SD card case:

    -----------------------------------------

            int pc_rtfs_media_insert(struct rtfs_media_insert_args *pargs) - Must be called by the media driver when a fixed device is detected at start
            up or when a removable device is inserted.

                      Media driver must provide a properly initialized rtfs_media_insert_args structure.

                            Returns 1 if the device mount succeeded.
                            Returns 0 if rtfs_media_insert_args contains invalid values or if too many devices are mounted for the current configuration to
                            support, if a calll to rtfs_port_alloc_mutex() fails, or, if RTFS_CFG_MEM == RTFS_CFG_DYNAMIC and a calll to rtfs_port_malloc() faails.

                            The following fields must be initialized in the rtfs_media_insert_args structure, prior to passing it to pc_rtfs_media_insert().

                      .....

                    int   device_type;               This field must be initialized with a device type. The device type field is used by code in rtfsdeviceconfig.c
                                             to configure buffering for the device when it is mounted. No other Rtfs modules rely on or know about the
                                             device type filed.

                                                    The currently set of device type constants includes BLK_DEVICE_TYPE_MMC, BLK_DEVICE_TYPE_NAND and
                                                    BLK_DEVICE_TYPE_USB. To add a new device types you must add a new constant to rtfsblkmedia.h and modify
                                                                                    rtfsdeviceconfig.c.

                    int   unit_number;               This field contains the instance of the device type that was just installed. For example if two MMC cards are
                                             installed then pc_rtfs_media_insert() is called twice. In both instance the device_type filed contains BLK_DEVICE_TYPE_MMC,
                                                                             but the unit_number filed contains 0 and 1 respectively.


    -------------------

    If the pc_rtfs_media_insert function is only being called once, this may indicate that the driver is not configured for 2 MMC/SD cards.

    Yi Hou said:
    I read the Block Media document and it said it only support one device at one time, is it right?

    We should confirm this with Sandeep, but if the above experiment shows that pc_rtfs_media_insert is only being called once then this may be the reason.

    Steve

  • Hi Yi,

    Yi Hou said:
    I read the Block Media document and it said it only support one device at one time, is it right?

    I think you are refering to section 12.5.1 of the userguide, C6748_BIOSPSP_Userguide.pdf. It says, at a time only one media can be registered as a raw device.

     

    What is the value of "PSP_BLK_DRV_MAX" in your setup, it should be '7'.  I guess you have defined CHIP_C6748 in the project file of the blockmedia?

     

    Are you able to release from the function "blkmediaCallback()" when you insert the second card on SD1?

     

    One more thing i would like to ask is, have you modfied the file "pspdrivers_01_30_01\packages\ti\pspiom\platforms\evm6748\src\mmcsd_startup.c" for MMCSD1?

     

    Let me investigate more and comeback to you.

    Thanks and Regards,

    Sandeep K

     

     

     

     

  • Hi Sandeep,

    Thank you for your help. 

    The PSP_BLK_DRV_MAX is 7 and I defined CHIP_C6748 in my project. We are using MicroSD and do not use the card detection for MicroSD0 (internal), only use for SD1 (external). The cal back function looks fine.

    I changed the mmcsd_startup.c to use both cards.

    Thanks,

    Yi

  • Hi Steve,

    Thank you for your help. Sorry for late reply. 

    I cannot debug the " pc_rtfs_media_insert" because I do not has the source of the FIle System. Only binary.

    Any suggestion?

    Thanks,

    Yi

  • Yi,

    Yes, the sources are not shipped for RTFS (in order to get them you must contact EBS, the company who wrote RTFS).

    The documentation is also a bit lacking on it, too.  Here's the function description.  What return code are you seeing?

    /* int pc_rtfs_media_insert(struct rtfs_media_insert_args *pmedia_parms)

    Rtfs device mount entry point. This function is to be called by the blk_dev driver when a new media device
    is activated.

    All fields in the struct rtfs_media_insert_args *pmedia_parms structure must be initialized before this function is called.

    It instructs Rtfs to bind the assigned drive numbers to partitions on this device.

    Returns:

    0 == success
    -1 == Media layer passed invalid arguments
    -2 == Already inserted
    -3 == Rtfs out of media structures
    -4 == Unsupported device type
    -5 == Adaptation layer out of resources
    -6 == Adaptation layer returned invalid values
    -7 == Driveid already in use or no drive ids availabl
    -8 == Rtfs out of drive semaphores
    -9 == IO error on first access to device
    -10== Error allocating buffers to access device
    */
    
    
    One more thing you could try. Can you try the RAM disk example? It should create a single RAM disk and call getdriveid() once.
    I'm wondering if you can try modifying the RAM disk example to create two RAM disks and call getdriveid() twice, similar to what you are trying for the 2 SD cards you have. It may be easier to get the RAM disk working first, and if it does work it would give us insight into the issue.
    Steve