cancel
Showing results for 
Search instead for 
Did you mean: 

How to drive the emmc chip in stm32l4r5 ?

ydong
Associate II

hello.

I am an embedded software engineer from China ,At the moment I'm trying

Drive emmc on stm32l4r5 ,but I failed .Who can give me a demo about how to drive emmc on stm32l4xx , thank you

6 REPLIES 6

I have a demo running on the NUCLEO -L4R5ZI ​

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

Hi.

i am try to it for a week ,but i failed .can you give me a demo ,thanks you .

Outputs via ST-LINK VCP at 115200 8N1

eMMC should be connected in 4-bit mode, using PC8-PC12, and PD2 pins.

email for a quote.

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

Thank you for your help, but hex file Can't help me solve the problem,

i find when i send cmd8 to read EXT_CSD but data is error .

Here's my code:

ExtCsdBuf = (uint32_t *)(&(E->EMMC_extcid.emmc_ext_csd_buf[0]));

 //

SDIO_DataInitStructure.DataTimeOut = SDMMC_DATATIMEOUT;

 SDIO_DataInitStructure.DataLength = (uint32_t)512;

 SDIO_DataInitStructure.DataBlockSize = (uint32_t) 9 << 4;

 SDIO_DataInitStructure.TransferDir = SDMMC_TRANSFER_DIR_TO_SDMMC;

 SDIO_DataInitStructure.TransferMode = SDMMC_TRANSFER_MODE_BLOCK;

 SDIO_DataInitStructure.DPSM = SDMMC_DPSM_ENABLE;

(void)SDMMC_ConfigData(hsd->Instance, &SDIO_DataInitStructure);

/* CMD8 */

 errorstate = SDMMC_CmdOperCond(hsd->Instance);

 if (errorstate != HAL_SD_ERROR_NONE)

 {

  return(errorstate);

 }

 while(!__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_RXOVERR | SDMMC_FLAG_DCRCFAIL | SDMMC_FLAG_DTIMEOUT | SDMMC_FLAG_DBCKEND| SDMMC_FLAG_DATAEND ))

  {

   if (__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_RXFIFOHF))

{

for (count = 0; count < 512; count++)

{

*(Test_Emmc + count) = SDMMC_ReadFIFO(hsd->Instance);

}

 }

if((HAL_GetTick()-Timeout) >= SDMMC_DATATIMEOUT)

{

hsd->ErrorCode = HAL_SD_ERROR_TIMEOUT;

hsd->State= HAL_SD_STATE_READY;

return HAL_TIMEOUT;

}

}

  if (__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_DTIMEOUT))

  {

   __HAL_SD_CLEAR_FLAG(hsd, SDMMC_FLAG_DTIMEOUT);

    

   errorstate = 0;

    

   return errorstate;

  }

  else if (__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_DCRCFAIL))

  {

   __HAL_SD_CLEAR_FLAG(hsd, SDMMC_FLAG_DCRCFAIL);

    

   errorstate = SDMMC_ERROR_DATA_CRC_FAIL;

    

   return errorstate;

  }

  else if (__HAL_SD_GET_FLAG(hsd, SDMMC_FLAG_RXOVERR))

  {

   __HAL_SD_CLEAR_FLAG(hsd, SDMMC_FLAG_RXOVERR);

    

   errorstate = SDMMC_ERROR_RX_OVERRUN;

    

   return errorstate;

  }

  else

  {

   /* No error flag set */

  }

 count = SDMMC_DATATIMEOUT;

// while ((__HAL_SD_GET_FLAG(hsd, SDMMC_FIFO_FIFODATA) != RESET) && (count > 0))

// {

//  *ExtCsdBuf = SDMMC_ReadFIFO(hsd->Instance);

//  ExtCsdBuf++;

//  count--;

// }

  

 /*!< Clear all the static flags */

 __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS);

 return errorstate;

}

___________________________________________________________

Can you take a look at it for me?Thank you

The FIFO holds words not bytes. HF (Half-Full) indicates there are 8 words available.

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

>>Thank you for your help, but hex file Can't help me solve the problem, i find when i send cmd8 to read EXT_CSD but data is error 

It will at least validate baseline functionality.

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