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).