sdcard: Compute CRC7 for all SPI commands.#1088
Conversation
d1cb87a to
95f72a7
Compare
|
@dpgeorge - This fix is needed to make the SD card work on the AE3 for the battery shield: https://openmv.io/collections/openmv-ae3-accessories/products/openmv-ae3-battery-shield?variant=42433436385374 |
|
See #765, which does this and other improvements. I gave a lot of feedback on that PR and was waiting for it to be addressed, but it looks like that might never happen... |
|
Oh... yeah, way to many changes in one commit in that PR. I tried to make sure this one just fixes what was causing problems. Nothing else to make it easy to review. If that PR is in limbo, then would appreciate this being considered instead. The only change that needed to be done was to add CRC7 support. |
|
...that PR's been hanging out for three years now. This is at least the 3rd independent re-implementation of the crc7 stuff for this module i've seen so far; because people need it to make this module actually work. Lets get this in so people can stop re-inventing wheels. Perfect is the enemy of good. |
Some SD cards (e.g. SDXC) have CRC checking permanently enabled in SPI mode. Sending commands with CRC=0x00 causes them to return ILLEGAL_COMMAND, making initialisation fail. Fix this by computing a valid CRC7 for every command. Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
Writes and reads 1 MB through the FAT filesystem and prints throughput in KB/s. Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
95f72a7 to
d0511a4
Compare
Some SD cards (e.g., SDXC) permanently enable CRC checking in SPI mode. Sending commands with CRC=0x00 causes them to return ILLEGAL_COMMAND, making initialisation fail. Fixed this by computing a valid CRC7 for every command. Most of my SD cards did not work with the SPI code. After adding CRC support all the cards worked.
Also added a performance test to the test script to benchmark things (using baudrate of 20MHz):