apache / nuttx

Apache NuttX is a mature, real-time embedded operating system (RTOS)
https://nuttx.apache.org/
Apache License 2.0
2.91k stars 1.18k forks source link

USB Mass Storage write speed is too slow #10248

Open laoniaokkk opened 1 year ago

laoniaokkk commented 1 year ago

My NUTTX system version is 12.2.1, when I write to the U disk through TFTP or copy data from the SD card to the U disk, I find that the writing speed of the U disk is only 5~6KB/s, this speed is too slow, is there any way to improve the writing speed of the U disk? I used the STM32F407 and STM32H743, USB OTG configuration in full-speed mode

acassis commented 1 year ago

Hi @laoniaokkk just to make sure: you are plugging a Thumb Drive (probably called UDisk in China) in the STM32 boards and trying to transfer files to it, correct?

I never did profile tests, but I think the speed was not that slow, maybe some recent modification introduced some regression.

There are two approaches you could try:

1) Test an old version (like the version I used in my video tutorial at NuttX Channel) and if it is faster, try to git bisect to find the commit that introduced the regression; or

2) Use J-Link SystemView with NuttX awareness to profile the system and discover what is causing the slow down.

laoniaokkk commented 1 year ago

Hi @acassis Yes,i am plugging a Thumb Drive(U Disk) in the STM32 boards and trying to transfer files to it.When I open the USB debug output, I find that there are a lot of error outputs during the transfer of files on the U Disk: 'OTGFS ERROR: Transfer Failed. ret=-11'。 I don't know why this problem occurs, then I tried to change a U Disk but the problem is still the same

acassis commented 1 year ago

@laoniaokkk I think you can try to enable to USB Debug or the USB Trace to collect more data. But remember that debugging USB is trick, when you enable to debugging you introduces pauses and other things that normally will stop it to work.

Other option is using a USB sniffer to see if there are some issue in the communication itself, like this low cost sniffer: https://github.com/ataradov/usb-sniffer

laoniaokkk commented 1 year ago

Hi @acassis I don't have a USB sniffer yet, but there is a logic analyzer, this is the USB packet I caught with the logic analyzer, I found that every time some data is transmitted, a NAK is generated, and then after 20+ms, it will continue to transmit data, I don't know why this happens, can you help me? This packet can be opened by the "DSView" software, and the test chip is stm32f407zg msc_tftp.zip