cancel
Showing results for 
Search instead for 
Did you mean: 

FATFS + eMMC always FR_DISK_ERROR

Charlie CHEN
Associate III

Hi all,

I am using STM32CUBEMX to build a project which includes eMMC and FATFS .

Then I try to format and read the eMMC like down below.

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

0690X00000ArvEVQAZ.png------------------------------------------------------------------------------------------------------ 0690X00000ArvEaQAJ.png

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

It always stuck in HAL_GetTick() and return the print Timeout error.

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

0690X00000ArvEpQAJ.png

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

The f_mount pass ,but f_mkfs and f_opendir return FR_DISK_ERROR everytime.

I have checked the hardware initial and HAL setting, I`m not sure where I should to set.

 

If you need any detail ,I will show you.

Hope anyone can help!

Thanks a lot !!

New Topic on:https://community.st.com/s/question/0D50X0000BcSNexSQG/emmc-on-stm32h743-always-disk-error

 

 

Thanks!

6 REPLIES 6
Charlie CHEN
Associate III

Is there anyone can help?

I`ll really appreciate.

Not using CubeMX here, so insight rather limited there.

Assuming this is on an H7

The H7 needs cache coherency code with DMA. The F7 in DTCMRAM does not.

Check if the DMA address is on a 32-byte boundary.

If it is going into a FatFs structure the InvalidateDCache_by_Addr is still unduly broad, and destructive.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Charlie CHEN
Associate III

@Community member​  Thanks for your reply.

Mine is H7 series, what does DMA address on 32-byte boundary mean?

I just search from my code down below, is this you mean about?

It`s in "core_cm7.h" file.

/**
  \brief   D-Cache Invalidate by address
  \details Invalidates D-Cache for the given address
  \param[in]   addr    address (aligned to 32-byte boundary)
  \param[in]   dsize   size of memory block (in number of bytes)
*/
__STATIC_INLINE void SCB_InvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize)
{
  #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
     int32_t op_size = dsize;
    uint32_t op_addr = (uint32_t)addr;
     int32_t linesize = 32;                /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */
 
    __DSB();
 
    while (op_size > 0) {
      SCB->DCIMVAC = op_addr;
      op_addr += (uint32_t)linesize;
      op_size -=           linesize;
    }
 
    __DSB();
    __ISB();
  #endif
}

>>what does DMA address on 32-byte boundary mean?

It means how is the buffer aligned in memory. You've got an address, how is it aligned? Is it cleanly divisible by 32, or NOT?

The cache line unit used by InvalidateDCache_by_Addr is 32-bytes.

ST is using the function without fully understanding the ramifications, and secondary effects.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Charlie CHEN
Associate III

@Community member​  I understand that ,but when I use the same way for SDCard,it can work.

Is it different setting to eMMC or something I need to notice?

Charlie CHEN
Associate III