Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32S3 USB MSC speed lower than expected (IDFGH-9776) #11110

Open
3 tasks done
zhongpang opened this issue Apr 3, 2023 · 8 comments · May be fixed by espressif/esp-usb#131
Open
3 tasks done

ESP32S3 USB MSC speed lower than expected (IDFGH-9776) #11110

zhongpang opened this issue Apr 3, 2023 · 8 comments · May be fixed by espressif/esp-usb#131
Assignees
Labels
Status: In Progress Work is in progress

Comments

@zhongpang
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

Chip: ESP32S3
IDF version: 5.0.1
USB Stack: TinyUSB from example folder
We implemented a usb mass storage on ESP32S3, the storage backend is a Nand Flash, everything works fine now except the copy speed of file is lower than expected: around 8KBytes/S on Mac and Windows.
We logged the tud_msc_read10_cb() function, and found Nand Flash read operation only cost less than 1MS/4096 Bytes, but the tud_msc_read10_cb() been called every 5MS, which close to the data copy speed we tested: 8KBytes/S = 4K * 1000/5.
From the document, it says S3 USB 2.0 speed could be 12Mbit/S, which means 1.5MBytes/S.
Is there any way to enhance the copy speed from 8KBytes/S to close to 1.5MBytes/S? Thanks very much!

@espressif-bot espressif-bot added the Status: Opened Issue is new label Apr 3, 2023
@github-actions github-actions bot changed the title ESP32S3 USB MSC speed lower than expected ESP32S3 USB MSC speed lower than expected (IDFGH-9776) Apr 3, 2023
@tore-espressif
Copy link
Collaborator

Hello @zhongpang , Thanks for the bug report and letting us know about this. I'll need some more information in order to help you debug this

Could you please share what Flash chip you used, how is it connected to ESP32s3 and how do you access it from the user code?

@espressif-bot espressif-bot added Status: Selected for Development Issue is selected for development and removed Status: Opened Issue is new labels May 23, 2023
@espressif-bot espressif-bot added Status: Opened Issue is new and removed Status: Selected for Development Issue is selected for development labels Oct 10, 2023
@Hinalikp
Copy link

Any update? I am also getting slow speed(0.155 MBytes/s) instead of 1.5MBytes/S. I used this example(esp-idf/examples/peripherals/usb/device/tusb_msc/) on esp32s3.
IDF version: 5.1.2

@tore-espressif
Copy link
Collaborator

Sorry this has sat around for an extraordinary long time without further feedback.

We found the data throughput bottleneck and experimented with some improvements.

However, we are now busy with USB support for upcoming ESP32-P4 and HUB support for USB Host. This improvement request is next in line. We'll keep this ticket updated

@kraftwerk-zone
Copy link

kraftwerk-zone commented Mar 18, 2024

Another raised hand for improved MSC speed. Max I can get is 120kB/sec, average is 90kB/sec

@espressif-bot espressif-bot added Status: Selected for Development Issue is selected for development and removed Status: Opened Issue is new labels Dec 12, 2024
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Selected for Development Issue is selected for development labels Jan 7, 2025
@FloHomi
Copy link

FloHomi commented Jan 10, 2025

I have the same Issue, with the ESP32-S3-DevkitC-1 and the example tusb_msc code from V5.4. using internal flash.
write speed 88KB/s (thats what windows says) with a 1953KB bin file. In reality It takes 4:50 minutes and only writes in ~20% increments with looooong stops in between. The Writing part could be 88KB/s.
From the ESP to the PC the same file takes ~3Sec...

@FloHomi
Copy link

FloHomi commented Jan 31, 2025

Hi there :)
you you have any idea how long it could take to fix this bug?
I urgently need it for a product deployment and do not know how to fix it myself... :(

@tore-espressif
Copy link
Collaborator

Hi everyone,

We’ve been investigating the slow write issues, and here are our initial findings:

When implementing a Mass Storage Class (MSC) device on ESP32 chips, using the internal flash as the storage medium is strongly discouraged. Our example uses internal flash only to demonstrate the functionality without requiring extra components.

The core limitation is that the program memory and storage reside on the same flash chip. During a flash write operation, program execution from flash is suspended, and interrupts that are not loaded into IRAM cannot run. As a result, USB transfers are severely slowed down.

Our recommended approach is to use a dedicated storage medium (e.g., an external SD card or flash) for the MSC disk. This setup can achieve write speeds of around 1 MB/s.

We will update both the example and our official documentation to better reflect this recommendation. If you have any further questions or feedback, please let us know.

@FloHomi
Copy link

FloHomi commented Feb 1, 2025

Thank you very much for your investigation!
I have an AtomS3 with display where i need to load data to it via msc and then do a ota update of other devices.
I sadly have therefore no other options, than using the internal flash. Can you suggest me maybe a solution on how to improve the situation? If 2MB is transfered in at least 10sec that would be fine with me too...
Kind regards and best wishes!

igi540 added a commit to espressif/esp-usb that referenced this issue Feb 5, 2025
…P32S3

Cached `get_sector_size` and `get_sector_count` to improve performance and avoid redundant calls.
Ping-pong buffering mechanism is enabled only for ESP32S3 targets since it
negatively impacts SD card write speed on other platforms.

Closes espressif/esp-idf#11110
igi540 added a commit to espressif/esp-usb that referenced this issue Feb 5, 2025
…P32S3

Cached `get_sector_size` and `get_sector_count` to improve performance and avoid redundant calls.
Ping-pong buffering mechanism is enabled only for ESP32S3 targets since it
negatively impacts SD card write speed on other platforms.

Closes espressif/esp-idf#11110
igi540 added a commit to espressif/esp-usb that referenced this issue Feb 5, 2025
…P32S3

Cached `get_sector_size` and `get_sector_count` to improve performance and avoid redundant calls.
Ping-pong buffering mechanism is enabled only for ESP32S3 targets since it
negatively impacts SD card write speed on other platforms.

Closes espressif/esp-idf#11110
igi540 added a commit to espressif/esp-usb that referenced this issue Feb 7, 2025
Cached `get_sector_size` and `get_sector_count` to improve performance and avoid redundant calls.
Storage buffering mechanism is enabled only for ESP32S3 targets since it
negatively impacts SD card write speed on other platforms.

Closes espressif/esp-idf#11110
igi540 added a commit to espressif/esp-usb that referenced this issue Feb 7, 2025
Cached `get_sector_size` and `get_sector_count` to improve performance and avoid redundant calls.
Storage buffering mechanism is enabled only for ESP32S3 targets since it
negatively impacts SD card write speed on other platforms.

Closes espressif/esp-idf#11110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Progress Work is in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants