AnsweredAssumed Answered

STM32F107 and USB Lib Mass Storage Device Speed Issue

Question asked by ryan.louis on Nov 18, 2013
Latest reply on Jun 18, 2015 by sid.m
Hi,
I am using the STM3210C-Eval board and the STM32_USB-Host-Device_Lib_V2.1.0 Host MSD example.

It is working i.e it reads and writes to disk but it is slow. I need to make / save a 2 Mbyte file on the USB.

The code section is :- usbh_usr.c // I modified the source to write bigger file

     bytesToWrite = 512;
      
      for(nLinesToWrite=0;nLinesToWrite<4000;nLinesToWrite++){
                    
        res= f_write (&file, writeTextBuff, bytesToWrite, (void *)&bytesWritten);   
           
        if((bytesWritten == 0) || (res != FR_OK)) /*EOF or Error*/
          {
          TerminalWriteString("Error Writing file \r\n");
          }
      
      }

It does work ( It writes a file to the USB drive ) but takes between 12 and 18 seconds to write. the USB drive I am using came with the kit and on a windows PC it writes the same size ( 2 MByte ) file under 1 second.

When I send a line count to a RS232 terminal it tends to run for approx. 256 lines ( nLinesToWrite ) and then stall, then run again and stall. The stall time is approx. 0.25 to 0.5 seconds.
The 256 is not fixed and does vary. 

It is like the system is erasing flash sectors but why so slow compared to a PC?

Is this a problem with the USB lib?

Are there better / faster USB lib's out there?

Any help appreciated.

Thanks,
Louis

Outcomes