C_SIZE on SD cards - problems...
Excuse me for duplicating a post, but I posted on the wrong forum yesterday in error. Admins feel free to delete the other post at *this location*
My problem is with C_SIZE and therefore determining an SD card's absolute size. I know this is the card size minus security protected areas, but I'm getting about 123 - 127MB for a 2GB card. Here's the original post:
Is my C_SIZE wrong? (0x3AE+1)
I'm asking here as I've searched through the posts pretty extensively and although found useful tips, nothing specific to this problem.
I bought a batch of 5 x 2GB Sandisk cards from aria.co.uk a while back and am writing a proprietary file system as it's commercial and I don't want FAT litigation + overheads etc. So, I've initialised the card, and get as far as reading the CSD and verifying CRC. Here it is:
CRC = 0x9FC5, checked + verified using separate program
So, I'm fairly happy the contents are valid. The problem lies in that if you match it up with the slices from the CSD register definitions, this is what I get:
READ_BL_LEN = 0x0A
C_SIZE = 3AE
C_SIZE_MULT = 5
This should give me the necessary info to calculate card size; Quoting from the physical layer specs:
This parameter is used to compute the user’s data card capacity (not include the security protected
area). The memory capacity of the card is computed from the entries C_SIZE, C_SIZE_MULT and
READ_BL_LEN as follows:
memory capacity = BLOCKNR * BLOCK_LEN
BLOCKNR = (C_SIZE+1) * MULT
MULT = 2C_SIZE_MULT+2 (C_SIZE_MULT < 8)
BLOCK_LEN = 2READ_BL_LEN, (READ_BL_LEN < 12)
To indicate 2 GByte card, BLOCK_LEN shall be 1024 bytes.
Therefore, the maximal capacity that can be coded is 4096*512*1024 = 2 G bytes.
Example: A 32 Mbyte card with BLOCK_LEN = 512 can be coded by C_SIZE_MULT = 3 and C_SIZE =
So for me then:
943 * 128 = 120704. BLOCKNR = 120704.
BLOCK_LEN = 2^10 = 1024.
120704 * 1024 = 123600896.
123MB??? What's going on?
The card is a standard 2GB sandisk SD card, formatted FAT as read in WinXP, size 1.83GB under properties. I have two of the five I bought doing the same thing. (exact same C_SIZE)
If anyone has any ideas I'd be grateful - I wonder if they might be fakes? They both have the same identical serial number - I hope that's a batch number not a unique identifier...
I have just tried a 4GB card from my camera but it didn't get past the ACMD41 stage; Need further investigation there. I might see what other cards I can find just to check.
Also, I have checked other cards:
Reading C_SIZE from several other cards:
512MB uSD: 3C7 -> 64MB (512Byte Blk / 2^7 mult)
2GB uSD: 3CD -> 127MB (1024Byte Blk / 2^7 mult)
1GB uSD: 3CA -> 15MB (512Byte Blk / 2^5 mult)
mults have had 2 added to exponent i.e. they read 5, 5, 3 in above cards.
The CRCs from the cards check out fine too. What am I doing wrong? Can't be misaligned, surely, as the CRCs would fail; I can see the FF,FE before the CSD is TX'd, and it's FF's after the buffer - I captured 32bytes just to make sure.
Hmm... Have I missed something in the calculations?
I'll try reading from / writing to the last block of a 2GB size card, as it's byte addressed, so I can easily read the last 512bytes for instance, and see if I get an error.
Any help or suggestions would be great, thank you.