Search code examples
csd-cardcapacity

SD Card Size Calculation


I'm just trying to extract the size of a 16GB SD card but it doesn't seem to work out exactly.

As per the SD specifications I'm extracting the variable C_SIZE as follows...

uint32_t c_size = (((uint32_t)csd[7] & 0x3F) << 16) | ((uint16_t)csd[8] << 8) | csd[9];

I get 30386. Then I calculate how many kb by doing what is also outlined in the specification...

memory capacity = (C_SIZE+1) * 512KByte

Then I just multiply by 1024 to turn that into a number of bytes.

The problem is that for my 16GB card I get 15,931,539,456 bytes based on the calculations above, and when I go to the SD Card's properties in Windows I get a capacity of 15,923,150,848 bytes (98,304 used, 15,923,052,544 free).

What am I missing?


Solution

  • Nothing. Your calculations are correct.

    The size of the card you've calculated is the total amount of raw storage available on the device. The size reported by Windows is the amount of storage available for files after formatting.