Datalogging shield displaying incorrect storage

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rahatmaini
 
Posts: 176
Joined: Wed Aug 29, 2012 5:15 pm

Datalogging shield displaying incorrect storage

Post by rahatmaini »

I ran the SD Card Cardinfo sketch on my Arduino Uno, I had a 8 GB card plugged in but the serial monitor said only 3508 Megabytes.

Help please!! :(

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Datalogging shield displaying incorrect storage

Post by adafruit_support_rick »

Is your card formatted as FAT16? That has a volume limit of 4GB. Can you plug it into a computer and check the volume size?
Try reformatting as FAT32.

User avatar
rogerc2288
 
Posts: 5
Joined: Thu Jul 25, 2013 11:04 am

Re: Datalogging shield displaying incorrect storage

Post by rogerc2288 »

I am getting the same thing on the 8gb card I just tested. It is a Dane Elec 8gb SDHC formatted as FAT32 with the suggested SD format app and when I look at it in the computer it says it is 8gb FAT32 but when in the Data Logger Shield using Cardinfo I get volume size as 3.5 gb. Any help appreciated

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Datalogging shield displaying incorrect storage

Post by adafruit_support_rick »

I just took a look at cardinfo. I think you're simply seeing an integer overflow. cardinfo uses a 32-bit unsigned integer to compute the volume size in bytes. That will overflow when the value exceeds 4.2GB.
You can add a couple of lines to cardinfo to see the numbers it uses to compute the volume size:

Code: Select all

  Serial.print("volume.blocksPerCluster: "); Serial.println(volume.blocksPerCluster());
  Serial.print("volume.clusterCount: "); Serial.println(volume.clusterCount());
  
  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  volumesize *= 512;                            // SD card blocks are always 512 bytes
  Serial.print("Volume size (bytes): ");
I've got a 4GB card here, and I get this:

Code: Select all

Initializing SD card...
Card type: SDHC

Volume type is FAT32

volume.blocksPerCluster: 64
volume.clusterCount: 120704
Volume size (bytes): 3955228672
So 64 * 120704 * 512 = 3955228672
If you add the lines to print out blocksPerCluster and clusterCount, you should be able to multiply the results together with 512 and verify that your card really does have 8GB available.

User avatar
rogerc2288
 
Posts: 5
Joined: Thu Jul 25, 2013 11:04 am

Re: Datalogging shield displaying incorrect storage

Post by rogerc2288 »

Thanks for that info Rick, it worked perfectly. I got 240467 clusters, 64 blocks per cluster and when I multiplied that with the 512 bytes per cluster I got exactly what my computer was telling me the size of the SD card was.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Datalogging shield displaying incorrect storage

Post by adafruit_support_rick »

Cool.

<*sigh*> I still remember when 32 was more bits than you would ever need.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”