AnsweredAssumed Answered

USB Mass storage  + SDMMC read write too slow

Question asked by Hau Lam on May 8, 2018
Latest reply on May 23, 2018 by Clive Two.Zero

i using STMF779I-EVAL board and try to  implement USB Mass Storage + SD Card . But the read/write speed i am getting when write/read from Window PC is too slow. 

Read : 1MB/s; Write : 200KB/s

Even I already used DMA mechanism to speed up the SDMMC driver .


This is my implementation for read/write

int8_t STORAGE_Write_HS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)
//printf("STORAGE_Write_HS \n");
HAL_SD_CardStateTypeDef sd_card_state_return;
HAL_SD_StateTypeDef state_return;
uint32_t timeout = 0;
if(HAL_OK != HAL_SD_WriteBlocks_DMA(&hsd1, buf, blk_addr, (uint32_t) blk_len))
printf("Error : STORAGE_Write_HS failed Err: %u, blk_addr : %u ; blk_len : %u\n", hsd1.ErrorCode, blk_addr, blk_len);
return USBD_FAIL;

// Callback HAL_SD_TxCpltCallback increare writestatus  to check writing status

while (writestatus == 0)

writestatus = 0;


/* Wait until SD card is ready to use for new operation */
while (HAL_SD_GetCardState(&hsd1) != HAL_SD_CARD_TRANSFER)
return (USBD_OK);
/* USER CODE END 14 */


void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
//printf("HAL_SD_TxCpltCallback \n");
if(hsd->Instance == SDMMC1)
writestatus = 1;



I think that the HAL_SD_GetCardState(0 to long time to change state to HAL_SD_CARD_TRANSFER.

Could you let me know what is the root cause and is there any way to improve the speed ?

Thank you very much.