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/AM3352: Data read by EMMC2 is inconsistent with data written

Part Number: AM3352

Tool/software: TI-RTOS

Hi 

        When I use project MMCSD_bbbAM335x_EMMC_armTestproject to test EMMC,

the function 

MMCSD_open(peripheralNum, &MMCSDParams) returns 0;
MMCSD_write(MMCSD, TxBuffer , startBlock, numBlock);returns 0
and MMCSD_read(MMCSD, rxBuffer , startBlock, numBlock) returns 0
they mean write and read data are successful,
I write 0xAA to EMMC's sector,but read 0 from the same EMMC's sector.

haw can I debug this ?
my PDK version is pdk_am335x_1_0_13 and I use EMMC2 interface in my board.

THANKS!
  • Hi,

    Do you know if using Linux, you have EMMC on MMC2 working properly? That is, you can write a pattern and read it back? Or, you can save some files to EMMC and use it later.

    Regards, Eric
  • Hi Eric

            I'm sure it works by linux,Our product is ready to switch from the Linux platform to the RTOS platform,

    and I am now doing debugging on the driver side.

    The problem now lies with the EMMC driver and the FATFS file system.

    you have resolved many questions for me,thank you very much,

    please help me to debug the EMMC issue.

    Summarize my changes to MMC2

    1. Modify the Board_moduleClockInit() function by adding PRCMModuleEnable(CHIPDB_MOD_ID_MMCSD, 2U, 0U);

    2. Modify the Board_pinmuxConfig function by adding: PINMUXModuleConfig(CHIPDB_MOD_ID_MMCSD, 2U, NULL);

    3. Modify the gMmcsdPinCfg array in pinmux_data.c file and add {2, TRUE, gMmcsd2PinCfg},

    the hardware of MMC2 is configured with the pinmux tool.

    4. In the.cfg file, add:

    * Define the base address of the 1 Meg page the peripheral resides in

    Var peripheralBaseAddr = 0 x47810000;

    Configure the corresponding MMU page descriptor

    Mmu. SetFirstLevelDescMeta (peripheralBaseAddr,

    PeripheralBaseAddr,

    PeripheralAttrs);

    in main_emmc.c file,I have change MMCSD_INSTANCE_EMMC from 1 to 2.

    in MMCSD_soc.c file, I have modyfied the MMCSDInitCfg arry like MMC1.

    about the EMMC issue,I have initiated several posts, and all of them were answered by you.

  • I have init the rxbuf to 0xff,and after read,the rxbuf changed to 0x00,I think it may be write failed.

    I have trid to use MMCSD_control(handle, MMCSD_CMD_GETMEDIAPARAMS,(void *)&mediaparams) to get the params.

    when I read the params,it is right.shall I must format the card type to FATS?

    I have tried to format the card to vfat format by linux command,,read data are 0.

  • Is there any update today?
  • Hi,

    You need to format that EMMC as FAT32. Are you able to do that under Linux? That would be the simplest way.

    If not, you may try the latest Processor SDK RTOS 5.3 release, under USB driver, there is a project called USB_DevMsc_emmc_bbbAM335x_armExampleProject. This exposes the EMMC as a hard drive through the USB port, it works for our BBB board. For you to use this, you board needs have USB port and use TI USB driver, you may also need to change the EMMC instance.

    Plug you board into a Windows PC via USB and run the above application, the Windows PC should be able to detect the EMMC as a new drive (like a USB thumb drive). Then you can format the EMMC drive to FAT32 format.

    Then the MMCSD write and read should expect to work.

    Regards, Eric
  • Hi

        I can format the EMMC card as FAT32 under linux,but when write and then read data ,it's still different.

    I can get the params of EMMC,such as size of block,number of block.

    and when I init the rxbuf to 0xff,after read,the rxbuf changed to 0x00.

    can it mean read successful,but write failed.

    if write failed,why the write function returns OK? 

  • Hi,

    I am not sure about it. If you write a file using RTOS to EMMC with some pattern. Are you able to see the file name under Linux? Then are you able to read the file under Linux to determine if you saw the pattern or all 0x00? This we may understand if write failed or not.

    Regards, Eric
  • Hi

    Today, I talked with our company's technical experts and discussed that

    it is very troublesome to read and write the sectors of emmc card under Linux,

    and it is not recommended to have such a lack of confirmation.

    Now parameters of emmc card can be correctly obtained through TI's function interface.

    Can it be proved that emmc driver can work normally?

    Currently, after reading and writing, the return code is correct, but the data results are inconsistent.

    Do you have any good methods or Suggestions to help me solve this problem.

    BR!

  • Hi Eric

        I have proved that if I write data 0x5a to the EMMC by command on dd command in linux.

    after that, I read the data on RTOS at the same sector,the received buf is 0x0a,

    it seems read low 4bit data only.

    our board has 4 data bus line,and I have set the bus width as MMCSD_BUS_WIDTH_4BIT,

    how can I solve this issue?

  • It has been several days. Is there any update

  • Hi,

    I discussed with the development team. The issue may be the AM335x MMCSD driver had-coded EMMC with 8-bit bus width, ignoring user application configuration. Our EVM has EMMC chip wired with 8 data lines for maximum throughput and tested by the driver.

    We need some change in the driver code, allowing the user application to set the bus width in hardware attribute and pass through into the driver. I opened a ticket for the fix.

    Regards, Eric
  • Hi Eric

    I am very glad that you have found the cause of the problem. Also, I found that the parameters configured in the file MMCSD_soc. C did not take effect.

    When the program executes to MMCSD_v1_initEmmc, some parameters are solidified, such as bus voltage, bus width, etc.

    I tried to set the bus width to 4bit, but the reading was still wrong.

    When I write  data  58eb 6d90 646b 736f 7366 0000 0802 0006 to EMMC by linux command.

    The read data becomes b8 0d b4 f3 in RTOS, it  seems to be a combination of the lower 4 bits of 2 8bit datas into an 8bit data.

    These are my results.

    Now the problem has been located and confirmed to be a bug in EMMC driver library. May I ask when the bug can be solved?

    Or could you please provide me with a work around solution as soon as possible?

    BR!

  • Hi,

    We will review the open issues and fix plan next week. I will update you the schedule. We have PRSDK RTOS release every quarter and 6.0 release is coming out end of June. Given the code is frozen already for a while, it is unlikely we can provide the fix in 6.0. Most likely 6.1 release (end of Sept) we can fix it. But please wait for my update.

    Regards, Eric

  • Hi

          I have resolved this issue:

    in founction MMCSD_v1_initEmmc,t it sets the bus width to 8bit,I have modified some codes like these:

    if(MMCSD_OK == ret)
    {
    transaction.cmd = MMCSD_CMD(6U);
    transaction.arg = 0x03B70100;//before is 0x03B70200 ,0:1bit,1:4bit 2:8bit
    transaction.flags = MMCSD_CMDRSP_BUSY;

    ret = MMCSD_v1_transfer(handle, &transaction);
    }

    /* NOTE: Add delay */
    delay(100U);

    if (MMCSD_OK == ret)
    {
    HSMMCSDSetBusWidth(hwAttrs->baseAddr, HS_MMCSD_BUS_WIDTH_4BIT);//before is HS_MMCSD_BUS_WIDTH_8BIT
    }

    /* NOTE: Add delay */
    delay(100U);

    you can double check these changes.I think it is correctly,if not,you can tell me a better solution.

    BR!