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.

RTOS/TMS320C6746: emmc pdk driver

Part Number: TMS320C6746
Other Parts Discussed in Thread: OMAPL138, CSD

Tool/software: TI-RTOS

Hi

we are using our own board with the c6746 DSP and an sandisk emmc (4.51) device connected using 8 data bit to mmcsd0.

I am using the latest omap138 pdk 4.1.0.6 

I am trying to use the mmc driver example project :

MMCSD_lcdkOMAPL138_c674xTestProject

but instead of using the main.c test source, that is for testing the SD card I am using the main_emmc.c for emmc device.

as the omap138 is not define i added definition for omap138  when ever there is a definition for omap137 DEVICE (as the emmc module of both part need to be the same)

I also added the line:

hwAttrsConfig.supportedBusWidth = MMCSD_BUS_WIDTH_8BIT;

as I use 8bit data interface.

The test file mmc configuration look like this:

if(MMCSD_socGetInitCfg(MMCSD_INSTANCE_EMMC,&hwAttrsConfig)!=0) {
MMCSD_log ("\nUnable to obtain config.Exiting. TEST FAILED.\r\n");
return;
}

#ifdef MMCSD_EDMA_ENABLED
gEdmaHandle = (EDMA3_RM_Handle)edma3init(MMCSD_EDMACC_NUM, &edmaResult);
#endif

//#if defined(SOC_OMAPL137)
#if defined (SOC_OMAPL137)|| defined (SOC_OMAPL138)
/* There is no eMMC support for OMAPL137. This test is verified
* with MMC card inserted into the same slot used for SD card testing.
* Default card type will be SD. Change the card type to eMMC for the test here
*/
hwAttrsConfig.cardType = MMCSD_CARD_EMMC;

hwAttrsConfig.supportedBusWidth = MMCSD_BUS_WIDTH_8BIT; //ilan
#endif
#ifndef MMCSD_EDMA_ENABLED
if(hwAttrsConfig.enableInterrupt==1) {
MMCSD_log ("\n****** Non-DMA: Interrupt Mode ******\r\n");
} else {
MMCSD_log ("\n****** Non-DMA: Polling Mode ******\r\n");
}
#else
MMCSD_log ("\n****** DMA Mode ******\r\n");
#endif
MMCSD_log("Read/Write test with sector size %d bytes which involves ",SECTORSIZE);
MMCSD_log("reading/writing %d blocks at a time, with a total transfer size of %d bytes\n",TESTSECTORS,TEST_TOTAL_BYTES_TO_TRANSFER);

#ifdef MMCSD_EDMA_ENABLED
hwAttrsConfig.edmaHandle = gEdmaHandle;
#endif
if(MMCSD_socSetInitCfg(MMCSD_INSTANCE_EMMC,&hwAttrsConfig)!=0) {
MMCSD_log ("\nUnable to set config.Exiting. TEST FAILED.\r\n");
return;
}

#if !defined(SOC_OMAPL137) && !defined(SOC_OMAPL138)
GPIO_init();

EmmcsReset();
#endif

#ifdef MEASURE_TIME
profile_init();
#endif

ret =MMCSD_init();

if ((ret = MMCSD_open(MMCSD_INSTANCE_EMMC, NULL, &handle))!=MMCSD_OK)
{
MMCSD_log ("\nMMCSD Open failed with return code %d\n",ret);
}

HSMMCSDReadWriteTest(handle);

I can see the application run till the MMCSD_open line but do not come out from the open command.

as the driver is probably complied with optimization it is hard for me to debug the driver code.

what can be the reason that the open command fails?

for my board I also tried to configure all the relevant pin for MMCSD pinmux and reset line. I also notice (in debug mode) that the mmcsd registers did not changed , as if they were not configred at all. 

I tried to run the code on LCDK 6748 board and the test pass for sd card ( i use the main.c file as there is an SD card on the LCDK board)

is there any configuration for the emmc that I miss? do I need to call 

MMCSD_Params_init(&MMCSDParams);
I didnt find any documentation that define the
MMCSD_Params

Best Regards
Ilan
  • Hi,

    I've notified the RTOS team. Their feedback will be posted directly here.

    Best Regards,
    Yordan
  • Hi Ilan,

    You shouldn't need to call MMCSD_Params_init(&MMCSDParams) as MMCSD_open is passing NULL parameter which will pass the default values anyway.

    What do you see when you halt the program? Is it stuck in a while loop somewhere or is it giving you an error?

    Best,
    Sahin

  • Hi Sahin

    when I am halting the program it stops in function 

    MMCSD_v0_transfer(MMCSD_Handle handle,MMCSD_v0_Transaction *transaction, mmcsdCmd_t cmd)

    in the line in red:

    /*
    * Wait for the transfer to complete here.
    * It's OK to block from here because the MMCSD's Hwi will unblock
    * upon errors
    */
    if(0U != hwAttrs->enableInterrupt)
    {
    MMCSD_osalPendLock(object->commandComplete, SemaphoreP_WAIT_FOREVER);
    }
    else
    {
    uint32_t status =0;
    cnt = MMCSD_TIME_OUT_COUNT;
    while(0 == (status & transaction->checkStatus) && (cnt != 0))
    {
    status = MMCSDGetIntrStatus(hwAttrs->baseAddr);
    MMCSD_v0_cmdStatusFxn((uintptr_t) handle, status);
    cnt--;
    }
    }

    I notes that In the driver file 

    MMCSD_V0.c

    the code that check for definition MMCSD_EDMA_ENABLED and ENABLE_EMMC are grey indicating that those definition are not defined.

    I looked at the project in predefined symbol and the  MMCSD_EDMA_ENABLED was defined but ENABLE_EMMC was not so I add it but it didn't change the behavior.

    do I need to define some predefined symbol like MMCSD_EDMA_ENABLED and ENABLE_EMMC before driver compilation? (I tried to define it in the driver code and recompile it, but without any change)

    As i don't use uart0 in my board I cannot see the error message from the driver

    Is there a way to compile the driver without optimization so I could debug the driver code?

    Best Regards

    Ilan

  • Hello Ilan,

    You can change optimization settings by going to Project Properties -> Build -> Compiler -> Optimization

    Regards,
    Sahin

  • Hi

    I need to change driver code optimization and not the test example project. I build the drivers by using gmake, is there any option to compile the driver for debug?

    If I look on the mmcsd0 lines with scope I can see that after the open command there is some activity in the CMD line, and clk=215.5khz, and no activity on data lines.

    Best Regards

    Ilan

  • Hello,

    Within the makefile, add the compiler flag -Ooff to turn off optimization and then rebuild the library. I believe you can also add the predefine variable LOG_EN to enable logging.

    Regards,
    Sahin
  • Hi Ilan,

    I haven't heard back from you so I just wanted to see, have you already resolved your issue?

    Regards,
    Sahin
  • Hi Sahin

    I still have this problem. I managed to compile the mmcsd driver in a way that i can use the debugger by moving all the driver source to my test project. in that way i can debug the code and use breakpoints.

    when I call the open function it calls the function MMCSD_v0_initEmmc. this function send command to the emmc device. the commands are sent on the CMD and CLK lines. the first command that is being sent has the ID 0. this is used to reset the device. the second command  with ID 1 is sent and the emmc need to return an answer - the OCR register value with bit31=1. this indicates that the device is ready. I check the CMD line with scope and I can see that the first and second command are being sent to the device and the device return (only a single time after power up) the value 0x00ff8080. in the device datasheet it says that the device need to return the value 0xc0ff8080. (bit31 indicate that the device is ready) but in my case the device return not ready. 

    The driver send command 1 in a loop till the device will return that it is ready but in my case the device return an answare only on the first try after power up with the value not ready. after that the device do not return any value even after reset.

    I check the printed board and it seems OK. we tried also to make an X RAY check on the memory chip and the company that assembled the board found out that there may be a problem with the device assembly so they assembled it again. but still I have the same problem.

    Currently I am trying to contact the device manufacturer - the device is from sandisk, SDIN8DE2-4G-XI.

    It seems strange that after power up the device return an answer that is is not ready but after that it does not return any answer. even if I start the test program (in the test program I also set the device reset line)

    the device do not response. it seems that the reset line do not work as there is some hardware problem. 

    Any advice will be welcome

    Best Regards

    Ilan 

  • Hi

    We found out that the problem was not in the hardware but in the driver - according to JEDEC v4.51, in CMD=1 we need to send the OCR register value. In the driver code this value was set to 

    MMCSD_OCR_AGRHL_REG_VAL      (0x00FF8000)

    we changed it to

    MMCSD_OCR_AGRHL_REG_VAL      (0x40FF8000)

    This tell the memory that we work with sector address mode instead of byte address mode, as our memory size is 4G (more then 2G) we must work with sector size and not byte size. if we set byte size the memory enter inactive mode.

    currently after making this change the open command succeed, but there is still a problem with the last command sent to the memory. in MMCSD_v0_initEmmc function, the last command sent to the memory is CMD 8. This command ask the memory to get its EXT_CSD register. the ext_csd that is beeing read from the device is 0. this is not a correct value, but the open command return with OK value.

    Then when the test call the write command (24 or 25) it is stuck. 

    It seems that the problem start after sending CMD8, I can see that the the command is sent to the device and the DAT0 line is set to 0 (In CMD8 the memory return its CSD_EXT register on the data lines).

    after sending the CMD8 command there is no clk on the clk pin. so after sending the CMD8 other command like write will not be sent and that is why the write command is stuck. 

    I change the CMD8 parameters to:

    cmdObj.cmd.cmdId = MMCSD_CMD(8U);
    cmdObj.cmd.rspType = MMCSD_RESPTYPE_R1;
    cmdObj.cmd.busy = MMCSD_RESPBUSY_NO;
    cmdObj.cmd.cmdType = MMCSD_CMDTYPE_ADTC;
    cmdObj.cmd.xferType = MMCSD_DIR_READ;// MMCSD_DIR_DONTCARE;
    cmdObj.cmd.lineChr = MMCSD_LINECHR_PUSHPULL;
    transaction.arg = object->rca << 16U;
    transaction.blockCount = 1U;
    transaction.blockSize = 512U;
    transaction.checkStatus = MMCSD_EVENT_EOFCMD | MMCSD_EVENT_READ; // MMCSD_EVENT_EOFCMD | MMCSD_EVENT_ERROR;
    transaction.flags = MMCSD_CMDRSP_READ | MMCSD_CMDRSP_DATA;// MMCSD_CMDRSP_READ | MMCSD_CMDRSP_WRITE;
    transaction.dataBuf = object->ecsd;
    ret = MMCSD_v0_transfer(handle, &transaction, cmdObj.cmd);

    as it is in the read command (in command 8 we need to read the ext_csr register)

    after changing the code the memory return a valid CSR EXT register and then the write and read command pass and the test pass.

    Currently My problem was solve, please let me know if you are planning to check those changes in the driver and maybe modify the driver so other may use it (all changes were made in MMCSD_v0.c flie).

    I looked at the mmcsd driver location and there are 2 version of the driver V0 and V1. for omap137 and omap138 the V0 version is in use. when I looked at V1 code I can see that both changes I made in the driver code are there (changes in CMD1 and in CMD8). Does the OMAP138 can work with V1 (if so why it is set to work with V0, file src_files_common.mk). what are the differences in those driver version?

    Best Regards

    Ilan 

  • Hi Ilan R,

              I'm trying to use the eMMC driver, and I use  a 16Gb eMMC device (MTFC16GAKAECN-2M),

              I follow the modifications as you did in the main_emmc.c file, while taking no changes with the MMCSD_v0.c file.

             I find the MMCSD_lcdkOMAPL138_c674xTestProject project, which is a non-DMA with polling mode test project, can work normally.

             But the MMCSD_lcdkOMAPL138_DMA_c674xTestProject project can not work normally:

           and then I modified the MMCSD_v0.c file as you did, nothing changes.

           Have you tried the driver with EDMA or with Interrupt?

           B.R.


    Frank

  • Hi Sahin Okur,

    I have the same problem with Ilan R. And in Ilan R's last post, he says
    "
    Currently My problem was solve, please let me know if you are planning to check those changes in the driver and maybe modify the driver so other may use it (all changes were made in MMCSD_v0.c flie).

    I looked at the mmcsd driver location and there are 2 version of the driver V0 and V1. for omap137 and omap138 the V0 version is in use. when I looked at V1 code I can see that both changes I made in the driver code are there (changes in CMD1 and in CMD8). Does the OMAP138 can work with V1 (if so why it is set to work with V0, file src_files_common.mk). what are the differences in those driver version?
    "
    Could you give an answer? Because I am also confused at this.
    Thank you.
    Frank
  • Hi Frank 

    you can use the following steps to build the DMA project:

    • import project: MMCSD_FatfsConsole_lcdkOMAPL138_DMA_c674xExampleProject

    • add files main_emmc.c , MMCSD_log.c , MMCSD_log .h that can be found at  \pdk_omapl138_1_0_2\packages\ti\drv\mmcsd\test\src

    • in main_emmc.c  change all SOC_OMAPL137 to SOC_OMAPL138

    • delete main.c

    • change file\pdk_omapl138_1_0_2\packages\ti\drv\mmcsd\src\v0\ MMCSD_v0.c  according to the instruction below (I had problem to upload the file)

    change line 159 to:

    #define EMMC_FIX

    /** \brief MMC Argument Register value for OCR command. */
    #ifdef EMMC_FIX
    #define MMCSD_OCR_AGRHL_REG_VAL (0x40FF8080)
    #else
    #define MMCSD_OCR_AGRHL_REG_VAL (0x00FF8000)
    #endif

    and lines 1753 to:

    #ifdef EMMC_FIX
    cmdObj.cmd.xferType = MMCSD_DIR_READ;
    #else
    cmdObj.cmd.xferType = MMCSD_DIR_DONTCARE;
    #endif
    cmdObj.cmd.lineChr = MMCSD_LINECHR_PUSHPULL;
    transaction.arg = object->rca << 16U;
    transaction.blockCount = 1U;
    transaction.blockSize = 512U;
    #ifdef EMMC_FIX
    transaction.checkStatus = MMCSD_EVENT_EOFCMD | MMCSD_EVENT_READ;
    transaction.flags = MMCSD_CMDRSP_READ | MMCSD_CMDRSP_DATA;
    #else
    transaction.checkStatus = MMCSD_EVENT_EOFCMD | MMCSD_EVENT_ERROR;
    transaction.flags = MMCSD_CMDRSP_READ | MMCSD_CMDRSP_WRITE;
    #endif

    • build the mmcsd driver according to ti instruction

    this test work for me but I had some other problems with the driver after trying to integrate it in my project

    •  if I try to read from memory after open, the read stuck after board power up (turning power off and on) but on the second run from debug it run correctly. this means that after programming the unit and switch it on, it will stuck. the work around I currently use is to write dummy data to the emmc to an address space not in use and then use the device normally.
    • I do not understand why can I read and write data from address 0, If I use address less then 0x4000 the read and write are unstable - it can work for 10 times and then fail
    • I have also have another board that work on debug but not on power up (even after the work around of writing and then reading.
    • I add also delay between write operation (I had some problem when reading write command one after the other without delay)

    It seems to be some problem with the Edma or memory that do not work correctly,

    In my project   I use the starterWare drivers (EDMA and other), as I didn't find support for EMMC in starterWare I tried this driver from the new SDK, but lately I found out that there is support for the emmc driver in starterWare sourceforge site I am planing to check it too and to find out if it work correctly.

    Sahin can you please let us know if you have any solution for the EMMC driver?

    What is the address space that I can use for read and write?

    why does after power up the read operation stuck (on EDMA transfer) after driver open?

    the changes I made in the driver code were -

    • argument for CMD1 was not correct in the original driver (the memory is block address and not byte address)
    • CMD 8 read CSD_EXT register using DMA and memory data lines so I change the transfer to be as read command

    Thanks

    Ilan

  • Hi Sahin
    I made some new test with another micron device MTFC16GAKAECN-2M (the first one was from Sandisk)
    with this memory there is no problem with reading right after initialization, and I can access low address space from address 0.
    I still have some problems:
    - I am testing the driver by writing and reading the memory and check its is the same, every once in a while the test fails.
    - the bus width was set to 8 but still when I look with scope I can see it work in low speed with only 1 data lines active

    I think you have some problem with this driver for the C6748 (OMAP138) or with the driver building scripts:
    - The driver for OMAP138 is compied with mmcsd driver V0 (all other devices work with V1), this is indicated by file
    \ti\pdk_omapl138_1_0_2\packages\ti\drv\mmcsd\src\src_files_common.mk
    - The driver for OMAP138 use ti/csl/src/ip/mmc/V1/mmcsd.h while all other chips use v0 version.
    - the MMCSD_BUSWIDTH_8BIT definition is not consistent in MMCSD.h it is 8, in mmcsd.h it is 0x100
    - driver V0 do not switch the memory to work in 8 line width - it need to send CMD 6 to memory to switch the memory mode.
    there is function to switch bus width but it is only for SD and not emmc.

    Can you please let me know when and if TI planed to update the c6748 driver for emmc devices?

    Best Regards
    Ilan
  • Hi ,

           Which exmaple do you use, the DMA version or the nonDMA version?

           I use MTFC16GAKAECN-2M, and I take some tests and find:

           https://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/112/t/668731

           The phenonmen is a little different from yours. But in conclusion, I agree with you, I think there is some problem with this driver for the C6748 (OMAP138) or with the driver building scripts.

           Need help from TI!

           B.R.

    Frank

  • Hi Sahin Okur,


    I use MTFC16GAKAECN-2M, and I take some tests and find:

    e2e.ti.com/.../668731

    The phenonmen is a little different from Ilan R. But in conclusion, I agree with Ilan R, I think there is some problem with this driver for the C6748 (OMAP138) or with the driver building scripts.
    Need help from TI!

    B.R.

    Frank

  • Hello,

    The MMCSD driver supports eMMC. You need to rebuild the driver with the "ENABLE_EMMC" flag defined to enable the eMMC functionality. However, the eMMC features have not been tested on the OMAPL13x platforms since these platforms do not have eMMC on-board memory.

    The driver currently only supports block sizes of 512 bytes and will hang during write operations for cards having 1024 byte block sizes. A fix is planned for this and will be rolled out in a future SDK release.

    There is a bug reported where the MMCSD DMA test project intermittently fails on the C6748 LCDK when boot switch 5 is set to ON and the rest are OFF. This seems to be fixed when switches 2,3,4 are ON and the rest are OFF. A bug fix for this is planned in a future release.
  • Hi Sahin

    Can you please let me know if Ti planed to update this driver - as I mention above the driver for OMAP138 and c6748 dsp is complied with V0 source files, and the problems currently detected:

    - the driver work with 1 data line width only - low speed and not with 8 data lines

    - there are bugs in CMD1 and CMD8 (see my report above)

    - some times the read and write operation fails (the data written is not the data that was reading)

    Best Regards

    Ilan

  • Hi Sahin,

          Thank you so much for reply.

          I follow your guide and rebuild the emmc driver (add #define ENABLE_EMMC in the MMCSD_v0.c ), and then run the nonDMA version test program, the program stuck at the emmc_write() function.

          Could you provide me a        DMA version project with Interrupt enabled that suit for C6748+eMMC, which can work normally?

          Could you provide me a nonDMA version project with Interrupt enabled that suit for C6748+eMMC, which can work normally? As I metioned, I found the nonDMA version have to use "delay" between emmc_write/emmc_read, which means the app cannot be used freely.

          We've stuck at this problem for several month. And if the emmc cannot be used, we have to give up C6748 and move to other platforms. Really need TI's help!

     

          For the block size of the MTFC16GAKAECN-2M I use, it's 512.

          For the boot mode, do you mean that. If the dsp BOOT MODE = 00010000  which means NAND16 boot, the DMA driver cannot work normally, while the if the Boot mode=00001110  which means  NAND8 boot, the driver can work normally? I use  BOOT MODE = 0001 1100, which is emmc boot, can the DMA driver work normally?

    Thank you so much!

    Frank

  • And " However, the eMMC features have not been tested on the OMAPL13x platforms since these platforms do not have eMMC on-board memory. "
    On which platforms have TI taken tests? I would like to buy the development board and test it, maybe that may provide some clues to find the bugs on C6748's driver.
  • Frank,

    Sahin is out of office this week, will reply you as soon as he comes back next week.

    Regards,
    Garrett
  • Hi Garrett Ding,

    Thanks.
    Best regards,

    Frank
  • Hi Garrett,

    Has Sahin come back?
    Regrads,
    Frank
  • Hi Frank,

    I've replied to your other thread here: e2e.ti.com/.../668731

    Let us continue the discussion in that thread. It makes issues easier to track. Thanks.