Skip to main content
Senior
March 18, 2024
Solved

Time taken to change USB state

  • March 18, 2024
  • 3 replies
  • 2494 views

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

Best answer by AScha.3

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.

3 replies

Technical Moderator
March 18, 2024

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 "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
Nico3Author
Senior
March 19, 2024

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.
Super User
March 19, 2024

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.

Nico3Author
Senior
March 19, 2024

Please suggest what should I trace. 

 

AScha.3
Super User
March 19, 2024

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""."
Pavel A.
Super User
March 19, 2024

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.