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.

Question about MMCSD FAT on C6748 of SD1

Other Parts Discussed in Thread: OMAPL138, SYSBIOS

Dear engineer:

      Now we are debugging MMCSD FAT on C6748 of MMCSD1(we use the TF card) with JTAG,We encounter the following issues:

MMCSD1 checks card Successfully,but it will hung in "f_mkfs(DRIVE, 0, 0)"????,we changed TF card many times,the result are same.We do not know why???

We have some screenshots about MMCSD1 registers as follows:

1.when connect the JTAG

2.when running" mmcsdStorageInit()",it return success;

3.when ran "checkMediaCard(MMC_INST_ID)",it check TF card successfuuly!! 

4. when Executed down,it will hung in "f_mkfs(DRIVE, 0, 0)",we donnot know why???

our gel and code are As shown in Annex.

    Looking forward to your reply!!

   Best wishes!!

3755.C6748.gelc6748_mmcsd_FAT_test.rar

         

  • Hi,
    Is that code developed by your own or TI provided ?
    What package are you using ?
    How about your hw ?
    Custom or EVM ?
  • Hi Titus S:

         Thanks for your reply very much.

         The codes are developed by our own referred TI provided .

         The  hw is our own too.

         Because the EVM used MMCSD0,but our hw used MMCSD1, so I just changed two places:

         one:  the MMCSD1 pinmux

    //SD1
    /* Mask and value of the pinmux registers for mmcsd 1                         */
    #define PINMUX18_MMCSD1_MASK         0x00F000FFu
    #define PINMUX18_MMCSD1_ENABLE       0x11022200u
    #define PINMUX19_MMCSD1_MASK         0xFFF00000u
    #define PINMUX19_MMCSD1_ENABLE       0x00022211u

    #define PINMUX19_GPIO_MMCSD1_MASK   0xFFFFFF00u
    #define PINMUX19_GPIO_MMCSD1_ENABLE 0x00000088u

      static Void configMmcsd1()

    {

       CSL_SyscfgRegsOvly sysCfgRegs = (CSL_SyscfgRegsOvly)CSL_SYSCFG_0_REGS;

    #ifdef KICK_REG_ENABLE

       /*Enable write access to PINMUX and CFG registers in KICK0R and KICK1R    */

       KICK0R = KICK0R_MMCSD_ENABLE;

       KICK1R = KICK1R_MMCSD_ENABLE;

    #endif

       /* enable the pinmux configuration for the MMCSD device                   */

       sysCfgRegs->PINMUX18 &= PINMUX18_MMCSD1_MASK;

       sysCfgRegs->PINMUX18 |= PINMUX18_MMCSD1_ENABLE;

       sysCfgRegs->PINMUX19 &= PINMUX19_MMCSD1_MASK;

       sysCfgRegs->PINMUX19 |= PINMUX19_MMCSD1_ENABLE;

       /* enable the pinmux registers for GPIO                                   */

       /* enable GPIO4_2 and GPIO4_1 for CD and INS support                      */

       sysCfgRegs->PINMUX19 &= PINMUX19_GPIO_MMCSD1_MASK;

       sysCfgRegs->PINMUX19 |= PINMUX19_GPIO_MMCSD1_ENABLE;

    }

    two:the "initMmcsd(Ptr edmaHandle)"function ,change MMC_INST_ID = 1

    static Int32 initMmcsd(Ptr edmaHandle)
    {
        Int32 result = IOM_EBADARGS;
        PSP_MmcsdConfig mmcsdConfig;
        if (NULL != edmaHandle)
        {
            mmcsdConfig.opMode = PSP_MMCSD_OPMODE_DMAINTERRUPT;
            mmcsdConfig.hEdma = edmaHandle;
            mmcsdConfig.eventQ = PSP_MMCSD_EDMA3_EVENTQ_0;
            mmcsdConfig.hwiNumber = 7u;
            mmcsdConfig.pscPwrmEnable = FALSE;/* default no power management reqd */
            mmcsdConfig.pllDomain = PSP_MMCSD_PLL_DOMAIN_0;
            result = PSP_mmcsdDrvInit(MMCSD_CLK_FREQ, MMC_INST_ID, &mmcsdConfig);
            if (IOM_COMPLETED != result)
            {
                /* Driver init failed */
            }
        }
        return result;
    }

    I just changed the two places,

     If  no changing ,The codes can run on EVM succeed.

    If changed as the above,The codes can run on our hw failed,which hung in "f_mkfs(DRIVE, 0, 0)"

    what's wrong,are there still some Parameters need to change ?  and How?

    waiting for your reply!!

    best wishes!!

  • Hi Jie wang,

    Have you compared the register values for both EVM and custom board after running your own build code ?
    What changes you observe in register values ?

    P.S-- Please convert your print messages in English for our understanding.
  • Hi Arvind Singh:

          Thanks for your reply,yes we have Screenshots for both EVM and custom board after running our own build codes,but different gel files(because the gel file depends on hw).

    EVM use SD card with 8Gb on MMCSD0, Custom board use TF card with 4Gb on MMCSD1

    the Screenshots are as follows:

    1. when the JTAG connect the board:

    EVM board:                                                                                                                                                                                                                         custom board:                                                                                                                                                                                                                                                                                                                                                                                                                            

    2. when ran the function "mmcsdStorageInit()" (as the Red Shadow),and both are successful!!

    Void taskMain(UArg arg1, UArg arg2)
    {
        Int32 result;

       configureMmcsd1();
       result = mmcsdStorageInit();

       if (IOM_COMPLETED == result)
       {
                printf("\nMMCSD_SAMPLE: Starting Sample Application,Using BLOCK MEDIA \n");

               MMCSDTest();
               result = mmcsdStorageDeInit();
              if (IOM_COMPLETED == result)
             {
                         printf("MMCSD_SAMPLE: mmcsdStorageDeInit Success!!!\n");
              }
              else
             {
                      printf("MMCSD_SAMPLE: mmcsdStorageDeInit Failed!!!\n");
             }
    }
    else
     {
          printf("MMCSD_SAMPLE:mmcsdStorageInit Failed!!!\n");
     }

    }

    EVM board:                                                                                                                                                                                                                           custom board:                  

    3. when ran the function "checkMediaCard(MMC_INST_ID)" (as the Red Shadow),and both can check SD card successfully!!!!

    Void MMCSDTest()
    {
        Int32   retVal = IOM_COMPLETED;
        FILE    *pFile;
        Int32   result;
       
        checkMediaCard(MMC_INST_ID);
        printf("MMCSD_SAMPLE:Card is inserted!\r\n");
      
        result = PSP_blkmediaFATfsRegister(MMC_INST_ID, DRIVE);
        if(IOM_COMPLETED == result )
       {
         printf("MMCSD_SAMPLE:Media is registered with FATfs\r\n");
       }
       else
       {
         printf("MMCSD_SAMPLE:Media is registered with FATfs FAILED\r\n");
       }
       printf("Format???\n");
       retVal = getchar();
      if(strcmp((const char *)&retVal, "y") == 0)
      {
                printf("MMCSD_SAMPLE:Create Fat format on MMCSD\r\n");
                f_mkfs(DRIVE, 0, 0);
       }
    printf("open the mmscd file for reading\n");
    pFile = fopen("fat:1:zhanll.txt", "wt+");
    if(NULL == pFile)
    {
            printf("open file failed!!\n");
            return;
    }
    }

    EVM board:                                                                                                                                                                                                             Custom board:               

    4. when ran the function "f_mkfs(DRIVE, 0, 0);" (as the yellow Shadow),EVM board can run  successfully!!!!,but custom board hung in ,and cannot get out of the function!!

    EVM board:                                                                                                                                                                                                             Custom board:  (when pause ,the value of MMCSD1 registers)

    I really donnot know why????? we hope your help very much !!!

    Best   Wishes!!!

  • Hi Arvind Singh:

          Thanks for your reply,yes we have Screenshots for both EVM and custom board after running our own build codes,but different gel files(because the gel file depends on hw).

    EVM use SD card with 8Gb on MMCSD0, Custom board use TF card with 4Gb on MMCSD1

    the Screenshots are as follows:

    1. when the JTAG connect the board:

    EVM board:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  

     custom board:  

    2. when ran the function "mmcsdStorageInit()" (as the Red Shadow),and both are successful!!

    Void taskMain(UArg arg1, UArg arg2)
    {
        Int32 result;

       configureMmcsd1();
       result = mmcsdStorageInit();

       if (IOM_COMPLETED == result)
       {
                printf("\nMMCSD_SAMPLE: Starting Sample Application,Using BLOCK MEDIA \n");

               MMCSDTest();
               result = mmcsdStorageDeInit();
              if (IOM_COMPLETED == result)
             {
                         printf("MMCSD_SAMPLE: mmcsdStorageDeInit Success!!!\n");
              }
              else
             {
                      printf("MMCSD_SAMPLE: mmcsdStorageDeInit Failed!!!\n");
             }
    }
    else
     {
          printf("MMCSD_SAMPLE:mmcsdStorageInit Failed!!!\n");
     }

    }

    EVM board:                                                                                                                                                                                                                                        

     custom board:    

    3. when ran the function "checkMediaCard(MMC_INST_ID)" (as the Red Shadow),and both can check SD card successfully!!!!

    Void MMCSDTest()
    {
        Int32   retVal = IOM_COMPLETED;
        FILE    *pFile;
        Int32   result;
       
        checkMediaCard(MMC_INST_ID);
        printf("MMCSD_SAMPLE:Card is inserted!\r\n");
      
        result = PSP_blkmediaFATfsRegister(MMC_INST_ID, DRIVE);
        if(IOM_COMPLETED == result )
       {
         printf("MMCSD_SAMPLE:Media is registered with FATfs\r\n");
       }
       else
       {
         printf("MMCSD_SAMPLE:Media is registered with FATfs FAILED\r\n");
       }
       printf("Format???\n");
       retVal = getchar();
      if(strcmp((const char *)&retVal, "y") == 0)
      {
                printf("MMCSD_SAMPLE:Create Fat format on MMCSD\r\n");
                f_mkfs(DRIVE, 0, 0);
       }
    printf("open the mmscd file for reading\n");
    pFile = fopen("fat:1:zhanll.txt", "wt+");
    if(NULL == pFile)
    {
            printf("open file failed!!\n");
            return;
    }
    }

    EVM board:                                                                                                                                                                                                                        

    Custom board:    

    4. when ran the function "f_mkfs(DRIVE, 0, 0);" (as the yellow Shadow),EVM board can run  successfully!!!!,but custom board hung in ,and cannot get out of the function!!

    Void MMCSDTest()
    {
        Int32   retVal = IOM_COMPLETED;
        FILE    *pFile;
        Int32   result;
       
        checkMediaCard(MMC_INST_ID);
        printf("MMCSD_SAMPLE:Card is inserted!\r\n");
      
        result = PSP_blkmediaFATfsRegister(MMC_INST_ID, DRIVE);
        if(IOM_COMPLETED == result )
       {
         printf("MMCSD_SAMPLE:Media is registered with FATfs\r\n");
       }
       else
       {
         printf("MMCSD_SAMPLE:Media is registered with FATfs FAILED\r\n");
       }
       printf("Format???\n");
       retVal = getchar();
      if(strcmp((const char *)&retVal, "y") == 0)
      {
                printf("MMCSD_SAMPLE:Create Fat format on MMCSD\r\n");
                f_mkfs(DRIVE, 0, 0);
       }
    printf("open the mmscd file for reading\n");
    pFile = fopen("fat:1:zhanll.txt", "wt+");
    if(NULL == pFile)
    {
            printf("open file failed!!\n");
            return;
    }
    }

    EVM board:                                                                                                                                                                                                             

    Custom board:  (when pause ,the value of MMCSD1 registers)

    I really donnot know why????? we hope your help very much !!!

    Best   Wishes!!!

  • Hi Jie wang,

    Apologies for delayed response.

    Here is what i can suggest you is-
    1. Check return value of

    result = PSP_blkmediaFATfsRegister(MMC_INST_ID, DRIVE);

    I suspect here itself this API might not getting success.
    If it goes well, then check for

    2. Return value from f_mkfs(DRIVE,0,0) function.
    edit f_mkfs(DRIVE,0,0); by return = f_mkfs(DRIVE,0,0);

    These are the expected return types
    FR_OK
    FR_DISK_ERR
    FR_NOT_READY
    FR_WRITE_PROTECTED
    FR_INVALID_DRIVE
    FR_NOT_ENABLED
    FR_MKFS_ABORTED
    FR_INVALID_PARAMETER.
    Compare your return value with expected return values, and try to narrow down your issue.

    3. Also read chapter 10 Block Media Driver of "C6748_BIOSPSP_Userguide" for more information on Driver API's .

    P.S- Please convert your screenshot comments(printf contents) into English and paste them again for our and other fellow engineers understanding.
  • HI Arvind Singh:

         Thanks for your reply.

         1. The return value of "PSP_blkmediaFATfsRegister(MMC_INST_ID, DRIVE)"  is "IOM_COMPLETED"which means it goes well;

         2.but when it run " f_mkfs(DRIVE,0,0)",it will block in the function,and cannot get out of the function ,so we cannot get the return value;

       The only difference between Demo board and Our custom board is just custom board uses MMCSD1 FAT,but demo board uses MMCSD0 FAT.

    we really donnot kown what is wrong???

    or do  you have examples about MMCSD1 FAT for us?

    Thanks very much!! waiting for your reply!!

    Best wishes!!!

             

             

  • Hi Jie wang,

    Unfortunately we do not have example code for MMCSD1.
    Have you tried other operations on MMCSD1 other then FAT ?
    What i will suggest you is first validate that your MMCSD1 controller is working fine.
    Create some basic example code of reading and writing from MMCSD card and try whether everything is going good.
  • Hi Arvind Singh:

    Thanks for your reply.

    Yes.We have tried some basic example code of reading and writing from MMCSD1 card and it goes well, everything is going good.

    So we can sure MMCSD1 controller is working fine and the TF card is OK too;

    But when with FAT,everything is going good before "f_mkfs(DRIVE,0,0)";

    Why??

    Do C6748 SYS/BOIS MMCSD1 with FAT have been tested or evaluated?

    if yes,Do you have test codes for us?

    if not ,Does the SYS/BOIS underlying driver support MMCSD1 with FAT?

    we use "bios_6_34_02_18" and "biospsp_03_00_01_00"  and CCS5.3

    waiting for your reply!!

    Best wishes!!

  • Hi,
    Any other hw changes have you been made other than MMC/SD controller on your custom board ?
    MMC/SD data width or any hw changes ?

  • Hi Titusrathinaraj Stalin:

       Thanks for your reply,

       No other hw changes have we been made other than MMC/SD controller.

      The MMC/SD data width ,clk(which is 37.5MHZ,and we have tried lower clk too) and so on are the same as EVM board.

     We have detected the MMC/SD clk with Oscilloscope which shows OK.

    and We have detected the MMC/SD data lines with Oscilloscope too,There are level changes which means there has data transmission.

    So,we really donnot know what is wrong??

    Waiting for your reply!

    Best wishes!

  • Hi Titusrathinaraj Stalin:

        Thanks for your reply,

        No,we have not made  Any other hw changes  other than MMC/SD controller.

       The MMC/SD data width and the CLK and other configs are the same as the EVM board which can be show on the registers values.

       And we check the CLK、Command  and data lines with Oscilloscope,They all have  level changes which means working well.

      But we really donnot kown what is wrong?

      How can we do?

    Waiting for your reply!!

    Best wishes!!

  • Hi Titusrathinaraj Stalin:

        Thanks for your reply,

        No,we have not made  Any other hw changes  other than MMC/SD controller.

       The MMC/SD data width and the CLK and other configs are the same as the EVM board which can be show on the registers values.

       And we check the CLK、Command  and data lines with Oscilloscope,They all have  level changes which means working well.

      But we really donnot kown what is wrong?

      How can we do?

    Waiting for your reply!!

    Best wishes!

  • Not sure if I can help.

    In the file mmcsd_evmInit.c,

    #define PINMUX18_MMCSD1_ENABLE 0x11022200u
    #define PINMUX19_MMCSD1_ENABLE 0x00022211u
    #define PINMUX19_GPIO_MMCSD1_ENABLE 0x00000088u

    Note that PINMUX19_GPIO_MMCSD1_ENABLE will overwrite thw lower 2 settings of PINMUX19_MMCSD1_ENABLE. This means MMCSD1_DAT[4] will be changed to GP8[8] and MMCSD1_DAT[5] will be changed to GP8[9]. That's probably okay with 4-bit SD. Not okay with 8-bit MMC.

    Perhaps the EDMA is not quite working with SD1. Try using PSP_MMCSD_OPMODE_POLLED instead of PSP_MMCSD_OPMODE_DMAINTERRUPT in initMmcsd().
  • Hi guys,

    I am having this exact same issue at the moment.. just wondering if you found a resolution?

    Thanks

    Brian

  • Dear Brian,
    Can you please tell us whats the problem ?
  • Hi Brian Boru,

    I would recommend you to open up a new thread stating the problem in detail.

    Appending the queries to the old post will get very less attention compared to the new threads.
  • Hi Titus, Shankari,

    Titus, it's the exact same problem - moving from Logic PD with SD card configured as MMC_INST_ID = 0; our custom board needs MMC_INST_ID = 1. After making the changes, the FatFs function f_mkfs() function hangs indefinitely. I tried Norman Wong's suggestion to change it to polled mode instead of EDMA mode and (after much longer than usual time) the mmcsd_fatfs_sample_application ran and passed. So it appears to be an issue with EDMA configuration. I haven't worked too much with EDMA yet; if you could point me in the right direction, would be much appreciated.

    Thanks

    Brian

  • Any suggestions?

  • Dear Brian,
    The major difference between MMC0 and MMC1 is PSC domain.

    MMC0 is in PSC0 (LPSC 5) whereas MMC1 is in PSC1 (LPSC 18)
    Please refer to OMAPL138 TRM.
  • Hi Titus,

    Thanks for your suggestion, I am following up on this and have hit a road block. This function is called from the main in the BIOS PSP MMCSD sample application in biospsp_03_00_01_00\platforms\evm6748\src/mmcsd_evminit.c

    Void mmcsdPscInit(Void)
    {
    #ifdef BIOS_PWRM_ENABLE
    /* Bring the GPIO module out of sleep state */
    Power_setDependency((Power_Resource)CSL_LPSC_NUMBER_GPIO_0);
    #endif
    }

    And CSL_LPSC_NUMBER_GPIO_0 is defined in soc_6748.h as follows:

    /* Peripherals in PSC1 */
    #define CSL_LPSC_NUMBER_GPIO_0 CSL_PSC_GPIO



    BIOS_PWRM_ENABLE is not defined by default, so I added this define and linked the XDC power module from SYS/BIOS to include Power_setDependency(). This all compiled ok, and I can step through Power_setDependency(), which is actually called before the default main() breakpoint on start-up. The issue I have now is that when I link the XDC Power module, my application now hangs before it reaches the default main() function breakpoint. It's hanging in sysbios/family/c674/pmi/pmi_i2c.c at line 180:

    asm(" .global _PMI_waitT1");

    This happens even when I do not define BIOS_PWRM_ENABLE, so it's an issue with the Power module. For some reason, when I link the Power module, it tries to initialise, but hangs at this point.

    Any idea why this might be?

    Thanks

    Brian
  • Hi Titus,

    Could you tell me if the EDMA controller is split into different PSC domains? Maybe MMC0 and MMC1 use EDMA controllers/instances in corresponding PSC domains?

    Thanks 

    Brian

  • EDMA3 instance 0 is in PSC0 domain and EDMA3 instance 1 is in PSC1.
    Please make sure that difference EDMA3 instance is used for different MMC.

    Also, please check the PSC register of MMC1 whether its enabled or not (i.e enable state)
  • Ok. I can use MMC1 in polled mode, it just hangs when I try to run in DMA mode, so I believe MMC1 PSC register is ok. Does MMC1 need to use EDMA instance 1, or can MMC1 use EDMA instance 0 as long as nothing else is using EDMA instance 0? Do I need to configure PSC registers of EDMA intance 1 in the Gel file, or can this be done in the application?

    Thanks 

    Brian

  • Hi Titus,

    I think I've found the answer to my above question. MMCSD1 needs to use EDMA3 Channel Controller 1.See page 101 of the C6748 datasheet www.ti.com/.../tms320c6748.pdf
    I am now turning my attention to GPIO mapping; this might be different for EDMA3 Channel Controller 1

    Brian
  • Dear Brian,
    Superb, thanks, that's good finding.