adafruit / Adafruit_CircuitPython_SD

SD card drivers for Adafruit CircuitPython
MIT License
37 stars 17 forks source link

Doesn't properly detect capacity >32GB #34

Open jepler opened 4 years ago

jepler commented 4 years ago

I have a card marked "SAMSUNG EVO 64" with the Micro SD XC logo. adafruit_sdcard detects its capacity as 57933824 512-byte blocks (0x3740000 blocks); other systems detect it as 125042688 512-byte blocks (0x7740000). Notice how the top bit is shaved off of the capacity number.

I didn't track it down fully, but it seems that the "v2 card" detection isn't complete; it leaves the card returning a "v1 csd", which is limited to 32GB.

card version check r= 1
card version v2
(58 #1) ocr= bytearray(b'@\xff\x80\x00')
(58 #1) ocr= bytearray(b'\xc0\xff\x80\x00')
(58 #2) ocr= bytearray(b'\xc0\xff\x80\x00')
csd version 1
csd 400e00325b590001dcff7f800a4040f1

I believe, but didn't verify, that e.g., my work in progess code to use SDIO on STM32F4 Feather is getting a csd version 2, but I didn't determine why/how yet.

This problem also exists in the WIP code for SD-over-SPI in the core, since it copied the "flow" of adafruit_sdcard.