CardInfo reports wrong size on Logger Shield

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

CardInfo reports wrong size on Logger Shield

Postby pgrunwald » Mon Dec 24, 2012 10: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
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 9:32 pm

Re: CardInfo reports wrong size on Logger Shield

Postby fat16lib » Wed Dec 26, 2012 4: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
  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
Last edited by fat16lib on Wed Dec 26, 2012 8:16 pm, edited 1 time in total.
fat16lib
 
Posts: 586
Joined: Wed Dec 24, 2008 12:54 pm

Re: CardInfo reports wrong size on Logger Shield

Postby pgrunwald » Wed Dec 26, 2012 4:49 pm

Thanks!
pgrunwald
 
Posts: 33
Joined: Tue Jul 14, 2009 9:32 pm


Return to Arduino Shields from Adafruit

Who is online

Users browsing this forum: ArekKindAcere, daz1761 and 9 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [114]

Raspberry Pi[82]
 
FLORA[24]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[12]
Arduino[60]
 
NETduino[14]
 
BeagleBone[23]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[39]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[9]


 
Breakout Boards[35]
LCDs & Displays[49]
Components & Parts[70]
Batteries & Power[54]
EL Wire/Tape/Panel[52]
LEDs[112]
 
Wireless[16]
Cables[66]
 
Lasers[6]
Sensors/Parts[147]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[41]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[25]


 
Stickers[41]
 
Skill badges[55]
 
Books[26]
 
Circuit Playground[7]
 
Gift Certificates[4]