cancel
Showing results for 
Search instead for 
Did you mean: 

Time taken to change USB state

Nico3
Senior

I am running USB in Mass Storage host mode. On connecting the device, USB FLASH stick, it takes around 20 seconds to change the Appli_Sate from APPLICATION_START to APPLICATION_READY in usb_host.c file. 

It is normal ? Can the time be reduced ?

 

 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

ok, so via swd + DWT counter ->

AScha3_0-1710860337759.png

about 9,2 ms from inserted to fatfs mounted ok;

is 64 GB (noname chinese..) USB stick, exfat , 50GB free.

btw

How often you call the  MX_USB_HOST_Process(); ?

I call it in main loop about every some 5us ....nothing else to do now, waiting for first command.

So this might be maximum speed, that can be achieved .

ed

+

Just for fun - had the idea, to try an old SanDisk 32GB stick, fat32,  also, got ->

AScha3_0-1710870499646.png

about 15ms insert to mounted. Ok for this piece of plastic shi.t , i think.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

11 REPLIES 11
FBL
ST Employee

Hello @Nico3 

Are you sure you are not printing to VCP/ UART or any terminal while debugging? It seems like an amount of time taken for printing debug information.

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi

Please note I am not printing anything. I also commented my remaning code and just checked the change in state on inserting the USB stick. It takes ~30 second to go from APPLICATION_START to APPLICATION_READY.

I checked both on STM32F4 discovery as well on board designed by me. It is coming same ~30 seconds.

The USB stick is 32 GB, SCANDISK & FAT formatted.

 

Pavel A.
Evangelist III

Then the contrary, add some prints/traces to understand where it spends its time.

Do not set breakpoints because USB requires realtime reaction from the device.

Of course, 30 sec. delay is not normal.

Please suggest what should I trace. 

 

Hi,

i never tested , but if you want, i could try to catch the time : Appli_Sate from APPLICATION_START to APPLICATION_READY

on my H743 , at 200M core (so not too far away from your F4 ?? cpu ).

If you feel a post has answered your question, please click "Accept as Solution".

please check if you can.. 

I used 32 GB flashstick and formatted in FAT mode. 

@Nico3 Trace:

- where the host reads various device (the USB stick) descriptors and strings

- where the host decides that the MCS device is fully detected and starts sending class-specific requests

- where the host successfully receives data from MSC device

- where errors and timeouts  are detected in the above steps, and the app retries them

 

 

ok, so via swd + DWT counter ->

AScha3_0-1710860337759.png

about 9,2 ms from inserted to fatfs mounted ok;

is 64 GB (noname chinese..) USB stick, exfat , 50GB free.

btw

How often you call the  MX_USB_HOST_Process(); ?

I call it in main loop about every some 5us ....nothing else to do now, waiting for first command.

So this might be maximum speed, that can be achieved .

ed

+

Just for fun - had the idea, to try an old SanDisk 32GB stick, fat32,  also, got ->

AScha3_0-1710870499646.png

about 15ms insert to mounted. Ok for this piece of plastic shi.t , i think.

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

about 9,2 ms

about 15ms insert to mounted. 

This is what should be.

Time individual MSC class requests to find where it wastes time. The capacity in bytes vs block numbers look suspicious.