-
Notifications
You must be signed in to change notification settings - Fork 440
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
Help Test SDIO for RP2040/RP2350 #2562
Comments
Very nice! Using my just made SD->Pico (RP2040 @ stock 133MHZ) adapter on an old SanDisk Extreme 32GB "U3" "V30" card I'm getting ~13MB/s Pinout and clocks
Results
AdapterI couldn't find a way of low-level erasing the card beforehand (like secure erase for SSDs) under Linux, so assume these #s are on a card that's been beaten to death in an old cell phone. The stack free function needs a bit of work, and there look to be some functions in the SDIO routine with >500 bytes of stack needed (which is not an error but might cause weirdness in real apps with other stack users in the call chain). Is there something specific you wanted to try out? My real high perf cards for my DSLRs are all full-size, so I can't use this adapter. But 13MB/s seems like a pretty good # even so on a random old one... |
There might be some CPU limitation, it seems. I bumped to 200MHZ on the same card and got the following
|
Use the SdFormatter example. The erase option quickly low level erases an SD.
I may remove the free stack function from SdFat examples since it is over 10 years old and was for 328 boards. Buffering for alignment problem is a problem. I have avoided allocating dynamic memory and don't like using the stack. Any suggestions?
I suspect few apps need more. |
+1 for minimizing dynamic memory allocation! It's not nearly as important on the 2040(256K) or 2350 (512K!!!) as the 8266 or AVRs, but every little bit helps avoid memory fragmentation. Not sure what you mean by buffer alignment, but using We also have a HW DMA engine that's 2x faster for large blocks than memcpy. It only works for 4-byte aligned offset, 4-byte aligned length, though. But it's a drop-in-replacement of --edit-- A quick sprinkling of |
SdFormatter didn't seem to change the resumts on the SanDisk card so it was probably still relatively clean. I did get a different on a generic MicroCenter-branded "U10" card, whose results follow. I suppose the 12-13MB/s read is due to a bottleneck somewhere in the MCU since it's the same as the "good" card, while the write limitation is down to the very cheap card. In any case, very consistent success using the SDIO mode even with spaghetti wiring!
|
Read/write calls often occur with non aligned buffers. Also if the file positioned is not a multiple of four bytes the copies to form complete sectors will not be aligned. The bench example with 512 byte transfers will never need the copies. Try bench with 513 byte transfers to insure no crashes due to alignment problems. Performance suffers with lots of nonaligned copies. Here is RP2040 with 512 byte transfers at 133 MHz using a low cost PNY 32GB microSD.
Here is the result with 513 byte transfers:
Modern SD cards have huge flash pages, 32KB or more. Low end SD cards don't pipeline reads as well as high end cards. High end cards have lots of buffering and they read ahead and pipeline the data stream for sequential reads. High end SD cards are incredibly complex, some even use Pseudo-SLC cache like SSD drives. I was amazed to see high end SD cards setup read steam buffer policy based on how a file was written. SD cards expect a standard file format as specified by the SD Association. The SD expects standard locations and sizes for clusters and other file structures. FAT areas are managed in a different way than data areas. Some SD cards try to optimize for multiple open files or random I/O. For best results use the Official SD Association formatter. |
Gotcha. Misaligned accesses (byte-wise? ugh!) are always brutal, anyway. The DMA copy won't help you there in most cases, sadly. Your examples have several boards w/SDIO pins defined manually I can add those defines to the board variant headers and it will "just work" without you needing to manually include the values for every example. In any case, is there a timeline for beta->release on the new SDFAT? My fork had minimal changes to work with our |
About the only variant that is safe is AdaFruit Metro RP2040, it has an onboard SDIO/SPI socket. Other users of the beta select different pins than my test cases. The current beta has lots of changes for other boards. I have done tests with some of the most popular Arduino and AdaFruit boards. There are now thousands of "Arduino Compatible" boards plus custom boards that use SdFat so I can no longer test a fraction of these boards. If I don't get any serious issues, I will post a release on SdFat in about a week. |
Just chiming in:
|
@greiman do you support bit reversal on the SDIO data pins? Looking at the SparkFun Thing Plus RP2040 it looks like GPIOs map from a low GPIO SDIO3 to a higher GPIO SDIO0. https://cdn.sparkfun.com/assets/5/4/f/6/b/RP2040_Thing_Plus_Schematic.pdf SDIO3=GPIO 9 |
I noticed the SparkFun Thing Plus RP2040 but never pursued it. It seemed I might flip bits in each nibble by using IN_SHIFTDIR and OUT_SHIFTDIR in the PIO state machine but I assumed the nibbles in a 32-bit word would be in the wrong order but never verified this. Here are is the places for IN_SHIFTDIR and OUT_SHIFTDIR. Edit: I looked at the datasheet and it looks like the bits in a nibble are not changed by shift direction:
|
Thanks for checking. I guess software-based bit reversal would be needed there. The RP2350 version of that SparkFun Thing Plus board has a SD slot but only 1-bit wired so it's probably not worth delving into. |
Please help test this beta version of SdFat that supports fast SDIO.
A number of users have requested this feature and hope it will be include in this package for RP2040/RP2350.
Here are some of my test results for the SdFat bench example with a Lexar Silver Plus card:
The text was updated successfully, but these errors were encountered: