I’m hacking on adding SDHC over SPI block device support to the Zephyr Project RTOS.
I’m currently getting 224 KiB/s on an Arduino Zero with a 4 MHz bus and 1 KiB read size, which is an OK-ish 46 % of the top bus capacity.
Here’s where the time goes:
- 4550 us - total time to read 2x 512 byte blocks from the card
- 80 us - time spent in ELM FS (impressive!) and timing code
- 330 us - time for the no-name SD card to make the sector ready
- 1500 us - time to transfer 512 bytes over SPI
- 330 us - time to calculate the CRC to check the sector
The SPI transfer itself is done in bursts of 16 bytes (~32 us) and the SPI driver has a turn-around time of 16 us.
Turning that into percentages,
- 4 % is in core code
- 15 % is in the SD card
- 67 % is in the SPI transfer
- 15 % is in the CRC
The next steps are to optimise the SPI driver and use the hardware CRC
unit. That could bring the time per block down to
(80 + 330 + 1000 + 100) =
~1500 us and the transfer rate up to
332 KiB/s / 67 % utilisation.