sdcardio: Use CMD25 across multiple writeblocks() calls #5510
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This increases write rates (of gifio from #5490) from about 2.4fps to over 5fps by making more efficient use of the SD card protocol.
Because of details of oofatfs, it usually manages 64 writes in a single CMD25, then two writes in a different area of the SD card (presumably, filesystem metadata). I couldn't find where to increase "64" to a higher number. 512*64 = 32768 bytes is the cluster size of the filesystem.
I tried preallocating too, but oddly it significantly lowered the write rate.
Any trailing data is committed when the file is close()d, or when the
sync
method of the SDCard object is called. You can check that this is happening by looking for the same token on the first & last lines of the file.Test code (no gifio required):
code-cmd25.zip
Test board: Kaluga (v1.3), 32GB "class 10" micro SD card with "G.SKILL" branding in a https://www.adafruit.com/product/254
Speed in the test program increased from about 260KiB/s to over 725KiB/s.