2013-11-18 06:54 AM
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 #stm32f-usb2013-11-18 08:07 AM
The NAND Flash on the USB drive likely has 128KB blocks, writing more than 512 bytes, and closer to 32KB might help. Not sure anything on the 107 is going to be particularly rapid (72 vs 2500-3500 MHz, and a GB of caching, USB 2.0 HS).
Thought about SDIO?2013-11-18 08:36 AM
Hi Clive,
Thank you so much for your fast response. I did the 32K block as you suggested and it now does it in approx. 1 second ( Was 12 seconds ). We needed it down below 5 seconds so happy days.Thanks Again,Louis2013-11-19 01:03 AM
Sorry... Should clarify...
The approx. one second ( actually 1.5 seconds ) was for the STM3220G-Eval board using the High Speed USB Interface. For Reference if you are doing something similarOn the STM32F107 it is about 4.5 seconds for 2MByte file save( Full speed USB Interface )On the STM32F207 it is about 3.5 seconds for 2MByte file save( Full speed USB Interface )Louis2015-06-17 06:34 AM
hi clive1....
i am using STM32_USB-Host-Device_Lib_V2.1.0.... in stm32f205vgt6. i trying to write data in 4GB pendrive. so after writing around 30MB data, the program get stuck in do-while loop in disk read() / disk write() function in usbh_msc_fatfs.c. I did debugging and found that whenever program is stuck there, the URB_Status in USBH_MSC_BOTXfer() is not updating and always keeping as URB_Idle. I read on other forums that, people had similar issues but it resolved by changing the otg interrupt priority to higher level. I did same, but problem is not resolved. so made a logic that if program gets stuck in do-while loop, then break the loop and reset USB module, it worked, but after few resets, after enumeration, the URB_Status in USBH_MSC_BOTXfer() is updated as URB_Notready.can you help in this case.????2015-06-17 07:56 AM
can you help in this case.????
Probably not. You'd want to take a look at what exactly is happening with a USB analyzer, or sufficiently instrument your code and it's interaction with the bus. Stepping around in the debugger probably not going to give you the insight you want, and will disturb the timing/interaction.2015-06-18 06:10 AM