cancel
Showing results for 
Search instead for 
Did you mean: 

USB Mass Storage Low Speed Even When Writing Multiple Sectors

Mohammad Hossein
Associate II

Hello,

I am using fatfs library developed by http://elm-chan.org/ for reading/writing file system in usb mass storage using stm32f4.As I know, for improving speed throughput one should write data buffer in a multiple of sector size (512B).

As stated in http://elm-chan.org/fsw/ff/doc/appnote.html:

The write throughput of the flash memory media becomes the worst at single sector write transaction. The write throughput increases as the number of sectors per a write transaction …. This effect more appears at faster interface speed and the performance ratio often becomes greater than ten…Therefore the application program should write the data in large block as possible. The ideal write chunk size and alighment is size of sector, and size of cluster is the best. Of course all layers between the application and the storage device must have consideration on multiple sector write, however most of open-source memory card drivers lack it. Do not split a multiple sector write request into single sector write transactions or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write operation.�?.

I searched in the web and found that the maximum speed that one can reach for writing in a usb mass storage (usb full speed), is about 800kB/s. But even when I increase buffer size to 32kB (64 sector) I can reach 460kB/s. I tested for 4,8,16,32KB buffer size and the maximum speed has not exceeded 500kB/s.

Another thing that I found during test is that the allocation uint size (cluster size) of mass storage (USB flash drive in this case) can affect the speed but I cannot find any clear relation between that and speed. It depends somewhat on flash drive manufacturer. I don’t know if there is any specific configuration option in fatfs library that I missed to set correctly or any point that can increase the speed at least to 800kB/s or even more to rated speed (1.5MB/s).

Thanks

3 REPLIES 3
Danish1
Lead II

Am I right in thinking that your overall system is:

stm32f4 -> USB Interface -> USB mass storage device

or perhaps

computer having lots of data -> USB Interface -> stm32f4 -> SDIO Interface -> SD-card storage device

How strongly do you know that the rate-limiting item is the storage device?

I wonder if the USB interface is reaching capacity. You don't say so I assume you're using a USB Full-Speed interface, which means 12M bit/s (most commercial things now use USB High-Speed at 480M bits/s, but stm32 generally needs an external PHY chip to support this).

12 MBit/s is 1.5 MByte/s if we ignore all the protocol overheads, so I would not be surprised if the highest practical data rate for USB Full Speed on stm32 is only around 500 kByte/s.

Hope this helps,

Danish

Mohammad Hossein
Associate II

Thanks for your help.

I use USB Full-Speed and my overall system is:

stm32f4 -> USB Interface -> USB mass storage device

When I run the same writing procedure on some usb flash drive (from different manufacturers and all of them are USB 2.0 devices), there is a little and sometimes a significant difference in writing speed between them. .Anyway, if 500kB/s is normal for usb full-speed as you said, I should use High-Speed with external PHY to reach higher speed.

You can also consider using an SD card instead, 4-wire SDIO can achieve more than 4 MByte/s (perhaps up to 8 or 10 MByte/s, but I didn't need more than 4).