-
Notifications
You must be signed in to change notification settings - Fork 62
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
Ardunio SD.h lib faster? #2
Comments
Arduino SD.h runs at half speed. Also SD.h is just a wrapper for a 2009 version of SdFat.
|
Yes, but the When I change: to
the So I guess the mystery is why the wrapped 2009 SdFat lib is able to run at full speed when the modern ones are not. |
The new SdFat is able to run much faster than the 2009 version. The problem is an SPI error. That suggests a hardware problem with the new SdFat-beta having a different access pattern to the SPI bus. Strange since the M0 Pro uses slow programmed I/O. While the SPI clock may be fast there will be a lot of dead time between bytes. I have been optimizing SdFat-beta for new faster systems with DMA like the Particle Photon. On the Due at full speed I get over 4 MB/sec read/write. What do you get with the bench example?
I don't have a M0 Pro so I can't connect my scope and see why SD status is getting garbled over the SPI bus. You might try enabling CRC to check for transmission errors. Edit SdFatConfig.h and set this
See if this catches more errors. |
Ouch, yeah I'm only getting 140 KB/sec.
Card InfoCard is class 10 SanDisk Extreme. Type is FAT32 Manufacturer ID: 0X3 5 MB file / 512 B buffer tests write speed and latency Starting read test, please wait. read speed and latency 20 MB file / 16KB buffer tests File size 20 MB write speed and latency speed,max,min,avg |
Wow that's less than a Uno. Here is an Uno with a 32GB SanDisk Extreme.
Too bad the M0 Pro has a such a slow SPI driver I am using SdFat on many other systems. I bought a $19 Particle Photon: I has 30 MHz SPI and I get over 3 MB/sec read/write with the stock SPI driver. It is a sweet WiFi development board. I get over 7 MB/sec with this STM32 board using SDIO instead of SPI. |
Thanks for all the background (and for SdFat itself!). Yeah the photon looks great. I'm using the M0 Pro as a dev board for a project that will embed a SAMD21. Just fyi when I load the Arduino Zero bootloader and run with the arduino.cc libs it's even slower (100KB/s vs 140KB/s). Others have run into this too: https://forum.arduino.cc/index.php?topic=358160.30 For our project it will have to do, until a DMA SPI driver is available for the SAMD duino's. |
Hi, |
I am not planning on doing a custom driver for M0. Also I don't support the old SD.h library that I wrote 2009. SD.h is maintained by the Arduino company. |
More of a mystery than a bug, reporting on the off chance it is of interet.
I'm able to run the
OpenNext.ino
example atSPI_HALF_SPEED
but atSPI_FULL_SPEED
I getI understand there are a lot of possible causes for this, in particular long paths in the SPI circuit. The reason I'm reporting this is that I can connect the same circuit at full speed using the
CardInfo.ino
example and the ArduinoSD.h
lib.I found my way to the beta from greiman/SdFat#16
(Looks like among other things, the beta configures the SPI layer to use automatically, which is nice. 👍)
Using https://github.com/greiman/SdFat with
#define SD_SPI_CONFIGURATION 1
I'm able to run on the M0 Pro, but as with SdFat-beta, only at half speed.I've run with each s/w config a dozen times and the results are consistent.
The mystery is how the standard Arduino library could be faster than SdFat.
Environment
The text was updated successfully, but these errors were encountered: