-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Poor SD read speed of fread() (IDFGH-903) #3249
Comments
Hi @keelung-yang, what read speed do you need to achieve? |
Hi @igrr , > 50KB/s is enough to feed our 500kbps CAN bus application in theory. Since I've built a task which read data from SD card to a Ring Buffer, and then our CAN application fetch data from the Ring Buffer. But, I found this while struggling with read spead: https://esp32.com/viewtopic.php?t=1942
It's not appropriate. |
Hi @keelung-yang, the default file buffer size is a compile-time constant of the C library (newlib). Since we are not building newlib as part of IDF build process, it is not easily possible to modify it using sdkconfig. Currently you can do one of the following things to improve the read speed:
We will also look into enabling the unbuffered stream read optimization in the next release of the toolchain. This will not change the behavior in the default (buffered) case, but will allow the |
FWIW, if anyone else trips across this, I've just been doing some testing (SPI 1 bit on a Wemos D32-Pro) and with the standard buffering it was taking some 60 seconds to read a 50MB file. With a 16k buffer, that's cut down to ~29 seconds. I tried 32 and 64k but that didn't improve it any more and an 8k buffer was slower. Still not brilliant but twice as good as before. HTH |
@igrr What is the highest rate if use SPI mode? |
Hello @keelung-yang, thank you for reporting this issue. At Espressif we really appreciate it when our users report issues as it helps us make our products better. Unfortunately there hasn't been any progress with this issue for the last 2 years and it looks like it's been explained and there are workarounds proposed. Because of that we are closing it to keep our backlog manageable. If you don't agree with this decision, please feel free to reopen the issue or contact me directly. Regards, Tomas |
I'm using the last master branch since fopen() failed in v3.3 while opening large file which more than 7MB.
Test results on Kingston 32GB 90MB/s TF(Micro SD) Class10 UHS-I:
And my test code:
The text was updated successfully, but these errors were encountered: