cancel
Showing results for 
Search instead for 
Did you mean: 

USB Mass storage + SDMMC read write too slow

Hau Lam
Associate II
Posted on May 08, 2018 at 13:11

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.

11 REPLIES 11
Posted on May 23, 2018 at 07:56

Hi

Turvey.Clive.002

‌,

So how can i help you , im willing to

Posted on May 23, 2018 at 19:34

My grass always need mowing, and I have a large fence that needs reseating and repainting.

The biography on my profile page also provides some details.

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