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: eMMC write timeout

Part Number: AM3352


Tool/software: TI-RTOS

I have a customized AM3352 board, it is almost same to beagleboard-black.

A SD card slot is soldered at MMC0, an eMMC chip is attached at MMC1.

The board is running with TIRTOS, built upon pdk 'pdk_am335x_1_0_14'.

After code modification (pinmux) were made to pdk, the eMMC (on MMC1 port) FAT partitions can be successfully mount and written.

But the write operation not stable, it randomly return with error,.

While continuously write to eMMC partition file (according to fatfs f_write), a random FR_DISK_ERR may return and then filesystem get stuck.

Despite the fatfs, I built a test uppon ''MMCSD_evmAM335x_armTestProject" by directly writing eMMC with 'MMCSD_write'. It also return a MMCSD_ERR at some random place.

Sometimes, 1GBytes were successfully written before the write error, sometimes it only has 60MBytes written.

By tracking down the code of pdk, in call stack 'MMCSD_v1_write -> MMCSD_v1_transfer', a SD_STAT(bit CTO) is captured after CMD25 was sent.

The timeout is the point. 

By modifying the write blockCount, it has different behavors:

1) Each time write 16 blocks (or less, 16*512 = 8KB), the timeout comes soon. Within 1GB were written, there is must a timeout.
2) Each time write 2048 Blocks (2048*512 =1MB), the timeout comes later. After several loops of test done and several GB were written, the timeout raised.

The timeout didn't happen at the fix block or a fix time, it always comes randomly.

We tried to run Linux on the same board, everything goes fine.

The eMMC partitions were written to full and then clear, the test ran several loops, without any error captured.

  • Hi,

    When you run the RTOS MMCSD example on MMC1 (EMMC), do you use the same HW attribute as in MMCSD_v1_HwAttrs MMCSDInitCfg[MMCSD_CNT] in the pdk_am335x_1_0_14\packages\ti\drv\mmcsd\soc\am335x\MMCSD_soc.c? Do you have 8-bit interface?

    Regards, Eric

  • The official examples has "pdk_am335x_1_0_14\packages\ti\drv\mmcsd\soc\am335x\MMCSD_soc.c" linked into project, the MMCSDInitCfg settings are reserved without any changes made. When the error occur, register SD_STAT has value of '0x18010', the most bit 1 (CTO) indicates no response is received for this command(cmd25).  While I tried each time MMCSD_write with 512B, the bitrates becomes very slow(about 233KBps), it kept running over 12 hours without any errors, but the bitrates are too slow to meet customers requirment.

  • Hi,

    What is the eMMC clock frequency you are using? Can you try to keep the same block size 8KB or 2MB but reduce the clock frequency? What eMMC chip are you using on MMC1?

    It sounds like a timing issue to me. The answers to the above questions may help us to pin-point the root cause.

    Ming 

  • Hi,

    Does the reduce eMMC clock frequency help to resolve the issue? Please let us know the latest status. We plan to close this thread and consider it is resolve, if there is no further feedback.

    Ming

  • Sorry for late reply. 

    Our customized board has a 'MTFC64GJVDN-4M IT' eMMC chip soldered, in 8-bit mode (MMC1_DAT0 ~ MMC1_DAT7), with capacity 64GB. The initial of eMMC is in source 'pdk\packages\ti\drv\mmcsd\src\v1\MMCSD_v1.c' . In the function MMCSD_v1_initEmmc(), it read out capacity information from the eMMC chip, then set MMC controller in 8-bit mode, and supply 26MHz clock. I tried to set the clock up to 52MHz or down to 20MHz, but the random fail were still there. It looks like to be a timing issue, but I can't find out where to adjust the timing settings (other than clock and bus width). By decreasing the frequency of CPU, modifying the timeout setting of MMC (HSMMCSDSetDataTimeout), changing timeout setting of fatfs, ...  after dozens of such tests, the error is still there.

    [1]

    While I am still in confusing how the timeout raised, I get a way to fix it. In source 'MMCSD_drv.c', when MMCSD_write or MMCSD_read return error, a recover function will be called, then re-submit the failed request of write/read .

    MMCSD_recover()

    {

    MMCSD_close();

    MMCSD_open(handle);

    }
    When the write/read failed, a recover is scheduled, then the next re-write/re-read always succeed. After the whole capacity (64GB) were written, dozens of this fix were scheduled. I think its the SOFTRESET and initialization in open fixed the error.  Then I added fatfs and made test with writing files, everything become OK.

    [2]

    While trying to added format function, I found a bug in f_mkfs (packages\ti\fs\fatfs\src). 

    if (n_vol < 0x10000) {

    st_word(tbl + BPB_TotSec16, (WORD)n_vol);

    } else {

    - st_word(tbl + BPB_TotSec32, (WORD)n_vol);

    + st_word(tbl +BPB_TotalSec32, (DWORD)n_vol);

    }

    After applied this fix, you can successfully format the eMMC partition in FAT32 format and then mount it for file operations. No more ways are needed (recommend in other posts such as connect to PC via USB and format it on PC).

  • Hi,

    I am not sure this is related to your issue or not, but according to the EMMC specification, all the CMD and DAT lines have to be pulled up on the board. Can you double check on the schematics of the customer board to confirm this?

    Best regards,

    Ming 

  • Hi,

    Thank you so much for your reply. I will report your fixes for the format function to the development team. I will close this thread for now.

    Ming