cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 F429 USB CDC vs USB MSD with USB FS

Uros Males
Associate II
Posted on October 29, 2015 at 13:58

Hello all,

I have a strange question regarding speed od USB CDC and USB MSD driver for STM32F429.

I implemented USB MSD + eMMC with FatFS support and I am getting 

0.51 MB/s write and 0.69 MB/s read speed results with USB Flash Benchmark app (on Windows).

Now I implemented USB CDC and I am generating 100MB of data and sending out to USB. Write speed (sending from FW to PC) is only 75kB/s .

I expected CDC should be faster than result frm MSD + eMMC test. I do not know, what else to check or test to achieve higher speeds.

I have USB FS type on the board. HS is not possible due to hardware design.

What speed should I normally get from this setups?

Thanks, Uros

#stm32f429-usb-msd-cdc-speed
7 REPLIES 7
Posted on October 29, 2015 at 14:15

Well the MSC can respond with at least 512 bytes per request, often significantly more. 600-700 KBps would be expected. The CDC likely sends a handful of bytes per packet, with more back-n-forth handshaking, probably not going to hit those kinds of numbers. Look at how you can fill every packet that crosses the wire.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
qwer.asdf
Senior
Posted on October 29, 2015 at 14:17

I just benchmarked my STM32F407-based device. It's working at 48MHz, SDIO is at 24MHz, I'm using FatFS + SDIO (2GB SandDisk microSD) + USB FS Mass Storage.

read speed is ~800KB/s

write speed is ~460KB/s

The speeds are not very different from your case.

Uros Males
Associate II
Posted on October 29, 2015 at 14:30

I am generating dummy data, buffer size is 64 and I am sending this buffer to CDC.

uint32_t testSize = 100000000; //100MB
uint32_t dummyCounter = 0;
uint8_t APP_TX_DATA_SIZE = 64;
uint8_t buff_TX[APP_TX_DATA_SIZE]; 
for(uint8_t i = 0; i < APP_TX_DATA_SIZE; i++)
{
buff_TX[i] = i;
}
uint64_t StartTimeStamp = iMos_SysDateTime_Get_SysLiveTime( iMos_TimeUnit_ms );
while(dummyCounter < (testSize / APP_TX_DATA_SIZE))
{
usbStatus = CDC_Transmit_FS(buff_TX, sizeof(buff_TX));
dummyCounter++;
}
uint64_t StopTimeStamp = iMos_SysDateTime_Get_SysLiveTime( iMos_TimeUnit_ms );

StopTimeStamp returns me back current value in miliseconds since the Task is started. With USB MSD speed, I am satisfied, but not with USB CDC. The RCC settings I used I posted

/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32%20F429%20USB%20MSD%20with%20eMMC%20%2b%20FatFS&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=1

. On board I have 32kHz (on LSE) and 24MHz (on HSE) crystal. APB1 and APB2 peripheral clocks are 42 MHz
qwer.asdf
Senior
Posted on October 29, 2015 at 14:41

Tune your parameters in usbd_conf.h (I presume you are using STM32_USB-Host-Device_Lib_V2.1.0.

Try to increase the APP_RX_DATA_SIZE, make it 10240 for example, and decrease the CDC_IN_FRAME_INTERVAL value, for example set it 0.

Also, check out this

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/USB%20Device%20VCP%20Speed%20issue%20in%20STM32F405&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&c...

.

Uros Males
Associate II
Posted on October 29, 2015 at 14:43

Thanks! I will try this settings and I'll post results as soon as I have them.

Uros Males
Associate II
Uros Males
Associate II
Posted on November 04, 2015 at 11:20

Update to the thread:

I learned that the speed of USB CDC is highly depending on what you are doing with data on the PC side.

TeraTerm freezes, Terminal by Br@y hangs after receiving large amount of data,... so I made my own terminal app for Windows and I learned that displaying received data takes much longer as only storing received data in temporary file.

Result: displaying of data in real time is slowing down the transfer speed.

When I was displaying data in my terminal app, speed was only around 15kB/s, then I changed processing, so now, when I am expecting to get large volume of data, I store it to temporary file and then display this file when transmission is done.

With this change, I was able to get USB CDC speed around 775 kB/s (+/- 5 kB/s).

============================================

Test 7 sending 10 MB of data (tested with own terminal app - saving to file)

START: 6055 ms

END: 18949 ms

=============

10 MB / 12849 ms = 778 kB/s

============================================

Test 8 sending 100 MB of data (tested with own terminal app - saving to file)

START: 6055

END: 134934

=============

100 MB / 128879 ms = 775 kB/s

============================================