Memorial day is 05/25/2015 – Orders will ship out on May 26th. There will not be any deliveries or shipping on Monday. Any order placed after 11am ET on Friday May 22nd will not start to ship out until Tuesday May 26th.

CardInfo reports wrong size on Logger Shield
Moderators: adafruit_support_bill, adafruit

CardInfo reports wrong size on Logger Shield

by pgrunwald on Mon Dec 24, 2012 11:40 pm

I have an 8GB Samsung Micro SD Card in an adapter. I formatted the card with the SD Formatted Utility from the SD site and it and Windows reports 7.4GB usable area.

I get this when I run CardInfo:

Code: Select all | TOGGLE FULL SIZE
Initializing SD card...
Card type: SDHC

Volume type is FAT32

Volume size (bytes): 3658711040
Volume size (Kbytes): 3572960
Volume size (Mbytes): 3489

Files found on the card (name, date and size in bytes):
DATALOG.TXT   2000-01-01 01:00:00 2886


Datalogger worked find and the file is readable in Windows. What am I missing?

Thanks,
Paul

pgrunwald
 
Posts: 33
Joined: Tue Jul 14, 2009 10:32 pm

Re: CardInfo reports wrong size on Logger Shield

by fat16lib on Wed Dec 26, 2012 5:27 pm

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 | TOGGLE FULL SIZE
  uint32_t volumesize;


You can change the section that prints the volume type and size like this
Code: Select all | TOGGLE FULL SIZE
  // 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
Last edited by fat16lib on Wed Dec 26, 2012 9:16 pm, edited 1 time in total.
fat16lib
 
Posts: 593
Joined: Wed Dec 24, 2008 1:54 pm

Re: CardInfo reports wrong size on Logger Shield

by pgrunwald on Wed Dec 26, 2012 5:49 pm

Thanks!

pgrunwald
 
Posts: 33
Joined: Tue Jul 14, 2009 10:32 pm