CardInfo has a bug that caused it to report the wrong size for cards larger than 4 GB.
CardInfo uses a uint32_t which is limited to 4,294,967,295 so you get some truncated wrong answer.
- Code: Select all
uint32_t volumesize;
You can change the section that prints the volume type and size like this
- Code: Select all
// print the type and size of the first FAT-type volume
uint32_t volumesize;
Serial.print("\nVolume type is FAT");
Serial.println(volume.fatType(), DEC);
Serial.println();
volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
if (volumesize < 0X800000) {
volumesize *= 512; // SD card blocks are always 512 bytes
Serial.print("Volume size (bytes): ");
Serial.println(volumesize);
volumesize /= 1024;
} else {
volumesize /= 2;
}
Serial.print("Volume size (Kbytes): ");
Serial.println(volumesize);
Serial.print("Volume size (Mbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
Then an 8GB card will print something like this:
Volume size (Kbytes): 7753728
Volume size (Mbytes): 7572
And a 2GB will print the byte count:
Volume size (bytes): 1977286656
Volume size (Kbytes): 1930944
Volume size (Mbytes): 1885