2020-04-30 06:12 AM
Hi,
I am using the STEVAL-STWINKT1 board with STM32L4R9 MCU. I want the USB work as Mass Storage linked to 4GB SD Card, connected by SDMMC 4 bits peripheral. SD Card is formated in FAT mode. Dare are read throught FAT_FS Middleware.
It is currently working but once I connect USB to PC it takes almost 1 minute to see it on my computer device manager as a 4 GB mass storage.
The code in usbd_storage_if. has been modified as it follows
extern SD_HandleTypeDef hsd1;
int8_t STORAGE_GetCapacity_FS(uint8_t lun, uint32_t *block_num, uint16_t *block_size)
{
/* USER CODE BEGIN 3 */
*block_num = hsd1.SdCard.LogBlockNbr;
*block_size = hsd1.SdCard.LogBlockSize;
//*block_num = STORAGE_BLK_NBR;
//*block_size = STORAGE_BLK_SIZ;
return (USBD_OK);
/* USER CODE END 3 */
}
int8_t STORAGE_Read_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)
{
/* USER CODE BEGIN 6 */
HAL_SD_ReadBlocks(&hsd1, buf, blk_addr, (uint32_t) blk_len, 10);
return (USBD_OK);
/* USER CODE END 6 */
}
int8_t STORAGE_Write_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)
{
/* USER CODE BEGIN 7 */
HAL_SD_WriteBlocks(&hsd1, buf, blk_addr, (uint32_t) blk_len, 10);
return (USBD_OK);
/* USER CODE END 7 */
}
In debug mode, I notice the information about SD card and block size are always null. They are populated after several seconds.
Do you have any suggestions to get it faster, please?
Thank you