i hashed together a sketch for data logging and was wondering what happens when the SD card becomes full. the sketch is just opening a file adding a new line and closing it again. the plan is to do this for a long period of time.
I cant seem to find any information about it (properly looking with my eyes shut).
Well the SD card will be intelligent enough to return an error back and nothing will happen.
But if you are logging information with a SD card of 16GB, damn mate you have mouths of storage!!
I will try to be serious and avoid using bites per mouth. So this is about the gibibyte (GiB) which is 2^30 bytes and the gigabyte (GB) which is 10^9 bytes. See Definitions of the SI units: The binary prefixes.
Well each saved log character is a byte and 16GB are 17.179.869.184 bytes
SD card capacity is specified as decimal GB just like disk drives. 17.179.869.184 is 16 gibibytes.
A 16 GB card has about 16,000,000,000 bytes. I checked a 16 GB micros SD and it had 31,291,392 blocks (512 bytes/block) or 16,021,192,704 bytes, not 2^34 bytes.
None of the above matters much for the original question:
the sketch is just opening a file adding a new line and closing it again. the plan is to do this for a long period of time.
The maximum size of a FAT16/FAT32 file is 4,294,967,295 bytes (4 GiB - 1). So when the file reaches that size, an error should be returned.
SdFat has a bug and a corrupt file will result. I used a max size of 4 GiB which overflows the 32-bit file size.
I will fix the next version of SdFat but the old version of SdFat in SD.h will not get fixed.
It's unlikely programmers will ever use the NIST units:
Examples and comparisons with SI prefixes
one kibibit 1 Kibit = 2^10 bit = 1024 bit
one kilobit 1 kbit = 10^3 bit = 1000 bit
one mebibyte 1 MiB = 2^20 B = 1 048 576 B
one megabyte 1 MB = 10^6 B = 1 000 000 B
one gibibyte 1 GiB = 2^30 B = 1 073 741 824 B
one gigabyte 1 GB = 10^9 B = 1 000 000 000 B
You are right fat16lib, i didn't remember that, physical storage in computers usually come labeled in Gibibit and not Gigabit
Also fat16 formating type, have a limitation of storage per file which i believe is 4GB, so OP you need to make sure that when the file is 4GB you create a new one
tsunamy_boy:
You are right fat16lib, i didn't remember that, physical storage in computers usually come labeled in Gibibit and not Gigabit
Also fat16 formating type, have a limitation of storage per file which i believe is 4GB, so OP you need to make sure that when the file is 4GB you create a new one
Most programmers don't have a clue about SI vs IEC Standard Names.
The correct word for 10^9 bytes is gigabyte and for 2^30 bytes it is gibibyte. I am not very careful when I use GiB or GB. When I wrote SdFat I did the following to point out storage is decimal.
cardSize: 3965.19 MB (MB = 1,000,000 bytes)
fat16 formating type, have a limitation of storage per file which i believe is 4GB,
FAT16 volumes are limited to 65,524 clusters and on SD cards, the max cluster size is 32,768 bytes. So you can't have a file larger than 2,147,090,432 bytes on a properly formatted FAT16 SD card. SDHC cards that are larger than 2,147,090,432 bytes must be formatted FAT32.
The FAT file size limit is 4,294,967,295 bytes, one short of 4 GiB. For disks on Windows 2000 and later, FAT16 volumes can have 65,536 byte clusters so you can have a 4,294,180,864 byte file on a FAT16 Windows disk.