Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Ardunio SD.h lib faster? #2
More of a mystery than a bug, reporting on the off chance it is of interet.
I'm able to run the
I 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
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
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.
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:
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 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
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.