2022-02-16 03:30 PM
Hi to all,
I use the Device MSC provided by CubeMX.
I wrote my own diskio.c file and every works fine with an SD of 2Gb formatted in FAT.
When I use n SD of 8Gb formatted in FAT32, WIndows take about 2 minutes to access the root directory. After this time, the Mass storage works fine.
What is the delay in enumerating files in FAT32?
Attached my usbd_storage_if.c
P.S.: FATFS works great with the same user_diskio.c and user_spi_diskio.c (attached)
Thanks to all.
2022-10-11 03:11 PM
>>Changing the parameter MSC_MAX_FS_PACKET has no effect.
Sure, because the size of USB packets is defined by the interface.
You should instrument the sector level read/write code, and establish the transfer sizes at the card, one sector (512 bytes) is going to have lamentable performance.
The OS, caching, and sizes of directory and cluster tables will also have a significant impact from the host side.
USB FS (12-Mbps) will likely top out at about 700-800 KBps. I modern time scales that's pretty slow. About 20 years ago when USB 2.0 (HS) first appeared with 480-Mbps performance was significantly better.
2022-10-11 03:20 PM
MSC_MEDIA_PACKET is pushed through the MSC's descriptor so the host OS knows how to decimate/deblock the transfers into sizes the storage device was capable of sustaining.
In earlier instantiations of the library MSC_MAX_PACKET, but within the MSC's Configuration Descriptor
__ALIGN_BEGIN uint8_t USBD_MSC_CfgDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
{
0x09, /* bLength: Configuation Descriptor size */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
USB_MSC_CONFIG_DESC_SIZ,
0x00,
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: */
0x04, /* iConfiguration: */
0xC0, /* bmAttributes: */
0x32, /* MaxPower 100 mA */
/******************** Mass Storage interface ********************/
0x09, /* bLength: Interface Descriptor size */
0x04, /* bDescriptorType: */
0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints*/
0x08, /* bInterfaceClass: MSC Class */
0x06, /* bInterfaceSubClass : SCSI transparent*/
0x50, /* nInterfaceProtocol */
0x05, /* iInterface: */
/******************** Mass Storage Endpoints ********************/
0x07, /*Endpoint descriptor length = 7*/
0x05, /*Endpoint descriptor type */
MSC_IN_EP, /*Endpoint address (IN, address 1) */
0x02, /*Bulk endpoint type */
LOBYTE(MSC_MAX_PACKET),
HIBYTE(MSC_MAX_PACKET),
0x00, /*Polling interval in milliseconds */
0x07, /*Endpoint descriptor length = 7 */
0x05, /*Endpoint descriptor type */
MSC_OUT_EP, /*Endpoint address (OUT, address 1) */
0x02, /*Bulk endpoint type */
LOBYTE(MSC_MAX_PACKET),
HIBYTE(MSC_MAX_PACKET),
0x00 /*Polling interval in milliseconds*/
};
2022-10-17 10:16 AM
Thanks. I'll move in this direction.
2023-07-04 03:36 AM
Hello, ABatt.1, Have you managed to solve the problem? I have the same symptoms with 8 Gb MMC - it takes too long for Windows to recognize.
2024-06-20 09:17 AM
Hello, I've received a lot of help from your uploaded source code and now I'm facing the same problem, too. I wonder if you have found some solutions. Thank you.
2024-06-20 09:25 AM
Two years later it might be healthier to describe your specific situation and expectations.
2024-06-20 09:47 AM
What a surprise few minute answer for years old question. Well, it is nothing different from the original problem. Windows took too much time to recognize when it is plugged in. It would be better if I could use HS device as you mentions, but my device is stm32f1 and only supports FS.
2024-06-20 10:00 AM
Well the STM32F1/SPI implementation isn't going to be particularly fast, and the FAT32 / EXFAT tables can get colossal.
Does the F1 part you've chosen support SDIO ?
The transfer size can also make a big difference to how efficiently the OS and the card interact with each other.
Outputting telemetry will give you some insight to the type and scope of interaction that is occurring.