Go Down

Topic: SD Card Info Returns wrong size (Read 1 time) previous topic - next topic

Melbfella

G'day all,

I'm working with a 1.8" TFT display, which has an SD card reader installed into it.  The display was bought off EBay :

http://www.ebay.com.au/itm/1-8-Serial-SPI-TFT-LCD-Module-Display-PCB-Adapter-Power-IC-SD-Socket-128X160-/200926655502?pt=AU_B_I_Electrical_Test_Equipment&hash=item2ec829740e&_uhb=1

The display works great, and I'm able to create and write files to a 16GB SD card with no problem.

The issue I have is when I run 'Card Info' from the SD example library, it returns these values :

Code: [Select]

Initializing SD card...Wiring is correct and a card is present.

Card type: SDHC

Volume type is FAT32

Volume size (bytes): 3038248960
Volume size (Kbytes): 2967040
Volume size (Mbytes): 2897


It reports that it's size is 3038248960 bytes, equating to a little under 29GB.  This is obviously incorrect, as the card is only 16GB to start with.

I used SD formatter from Adafruit to format the card, and it happily reports it's size as 14.8GB formatted, which I believe is correct.

Any thoughts would be greatly appreciated - I need to monitor how much free space is on the card, and I really would prefer not to have some type of offset to arrive at the correct number.

Thanks in advance :)

fat16lib

This is a well known bug in SD.h, not sure why the Arduino company has not fixed it.  CardInfo was written by Adafruit.

The reported value in bytes is truncated to 32-bits so it is incorrect for cards over 4 GB.

3038248960 is not 29 GB.  It is 3,038,248,960 bytes, about 3 GB,

Melbfella

Thanks for your reply fat16lib.

How embarrassing, you are correct re the 29gb.  Stupid decimal points ;)

So, given that the reported value is incorrect, am I still able to write to all 16gb of the card?

Looks like the SD "CardInfo" example sketch still has not been fixed in IDE 1.6.0.
The issue is that the long variable used to hold the calculated storage capacity overflows for cards with more than 4GB.
The fix is straightforward but does not appear to have made it into the latest Arduino release.
Anyone?
... Adrian_The_Canadian

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy