Notes on the care and use of flash memory



Introduction

Your camera uses flash memory to store images. "Flash" is a form of solid-state memory that retains its information even when powered off. Flash cards are not indestructible but are robust enough to last years with a little care.

The type of card defines the physical package and the electronic interface. The most common flash card formats in use in cameras are Compact Flash (CF), Secure Digital (SD), Secure Digital High Capacity (SDHC), MultiMediaCard (MMC) and xD-Picture Card (xD).

The typical life expectancy of cells on a flash card is around 10000 write cycles. The contacts on a card are rated for 10000 insertions. For most of us the card will outlast the camera in which it's used. Today's cards are much better than they were just a few years. Expect continuing improvements in the life expectancy and reliability of flash memory, especially now that the technology has matured enough to be a hard-disk replacement on high-end laptops.

The inner workings of flash memory are beyond the scope of this article but if you do want to know more then download this guide from Kingston or head to Wikipedia.

Flash cards are a "disk drive"

Your camera and PCs treat flash cards as a type of disk drive. Cards are formatted using either the Microsoft FAT (a.k.a. FAT16) or FAT32 disk format. Cards are divided into a number of blocks, an image file is allocated a number of these blocks to hold the image. There are a number of blocks reserved at the start of a card for a File Allocation Table (hence the name FAT) that lists which data blocks belong to which file and which are unused.

simplified file storage diagram

Files take up at least one block. If a file does not fill a block then the unused space at the end of the file is not available for another file. Even a 1 byte file takes up a whole disk block. Files may span more than one block. Normally the camera tries to assign contiguous blocks to a file as this makes later access faster. However if you've previously deleted pictures then there may not be a large enough gap, in this case the camera will use the next available blocks. This is called "fragmentation" and is not a good thing as it leads to longer read and write times for pictures. It's good practice to never delete images in-camera, wait until you've transferred your images to a computer and then reformat the card (see below).

As with all storage devices "bad blocks" can occur. These blocks can no longer be read or written safely. If these bad blocks are within an image file then the image will be corrupted and may become unreadable. If a bad block occurs with the allocation table then the entire card may not be able to be read correctly. A typical flash card has a number of spare or reserved blocks that do not form part of the space available for files. If the controller circuitry on the card detects a bad block it will try to use a ‘spare’ block instead of the damaged block. This means that the apparent capacity of the card is not reduced. However the supply of these spare blocks is limited and eventually the card will not be able to replace damaged blocks with spares. When this happens the capacity of the card will fall.

The card marks known bad blocks within the File Allocation Table. When your camera writes a file to the flash card it uses this bad block list to avoid problems. However when your camera formats a card it uses a "quick format" that only clears down the used block list but does not update the bad block list. You need to occasionally perform a full format using a PC that will find and mark any bad blocks. Follow this with a format in your camera to restore any camera specific files and directory layout.

Formatting

When you receive a new card it's a good idea to first perform a full format using a PC and then reformat in your camera. Perform a full format on your PC every few months or if you notice errors in files. If your card is less than 1Gb in size then you should format using the FAT format, cards over 2Gb must be formatted as FAT32. Cards between 1Gb and 2Gb can use either format. FAT is more efficient than FAT32 on small cards but cannot access more than 2Gb of memory.

Try not to delete individual files on the card. Instead reformat the card after transferring your images. By deleting individual files you are likely to decrease the performance of the card as you will cause file fragmentation. Your camera will have to spend longer looking for free blocks when it writes a file (similarly read times will be increased). By causing fragmentation you also run a greater risk of corrupting the file tables on the card (although this is a slight risk).

If your camera reports an error when writing to the card remove the card immediately. Do not attempt to save any more images. You may be able to rescue images already on the card using a product such as Image Rescue.

Note that in order to perform a full format of your card using a PC you will need to use a card reader or PCMCIA adaptor. It is not possible to perform a full format using most cameras.

If you notice that the capacity of a card is falling after a full format then it may be time to replace that card.

Physical care of your cards

Your card will normally come in a plastic storage container. Keep your card in this container when you’re not using it, this will help protect the card from dust and moisture.

Flash cards are sensitive to static electricity and magnetic fields. Don’t store them near electrical equipment or in the same pocket as your mobile phone.

Compact Flash cards are designed to withstand a 10-foot fall onto a hard surface but it's best not to rely on this protection. Take care not to drop or shock your cards. Other card types are not as robust as CF and should be treated with even more care.

Don't touch the contacts on cards where these contacts are exposed, for example SD/xD card formats. Touching the contacts transfers grease from your fingers and this attract dirt and encourages oxidisation. Eventually this reduces the conductivity of the contacts. If you do accidentally touch the contacts then wipe them with a soft dry cloth that is free from grease. Do not use abrasive cleaners or solvents.

Before inserting a CF card in your camera spare a couple of seconds to check that none of the holes in the connector are blocked. If they are do not insert the card as you could damage the connector inside your camera meaning an expensive repair.

Don't immerse your flash cards in water; they're not waterproof, not even a little bit. On wet days carry your cards in their protective cases inside your coat or bag.

Always let your camera finish writing to the card before powering down. Most cameras will not power down without finishing a write operation but it’s safer to check.

Before you insert or remove a flash card ensure that your camera is turned off. An incomplete write operation can permanently damage the flash card.

How fast do you need?

The base transfer rate of flash memory is 150Kb/s (the same as CD). Card transfer rates are usually given as multiples of this; for example a card with a quoted transfer rate of 20x has an actual write speed of 20 x 150Kb/s or 3.0Gb/s.

High transfer rates are not necessarily better. Faster cards are usually much more expensive than slower cards so it’s worth thinking about what type of photographs you make. As I mostly shoot landscapes I am happy with the lower rate cards (around 45x) although I do have a couple of 133x cards for the odd action shoot. On my D200 a 16Mb NEF (raw) image takes about 2.3 seconds to write to the card. For my faster cards this drops to just less than a second.

How big do you need?

This depends on the size of image that your camera produces and where you draw the line between convenience and safety. Larger cards mean more images and less card changes but at the risk of losing more images should the card be corrupted. I shoot mainly on 1 or 2Gb cards but I also have a couple of 4Gb cards. For my D200 producing a 16Mb raw image, this equates to approximately 60 images on a 1Gb card, 120 on a 2Gb card and 240 on a 4Gb card. Personally I feel that the 4Gb card is as large a card as I would want to risk.

Who's card should I buy?

The brands we recommend (in no particular order) are Kingston, SanDisk and Lexar. That is not to say that other brands are unreliable, it's just that we've used these cards for many years without problems. In general we use SanDisk or Lexar where performance is a requirement or Kingston for general use as these are typically cheaper than the other two brands.

Troubleshooting

My card claims to be 1Gb but when I format it I only get 900Mb of disk space.

This is normal for flash cards for two reasons;
  1. The overhead of the file system takes up some space so not all the memory on the flash card is available to store images.
  2. Your computer is lying to you! To a computer, 1Gb is 1024 * 1024 * 1024 bytes, i.e. 1Gb = 1,073,741,824 bytes. However to a flash card manufacturer 1Gb = 1000 * 1000 * 1000 bytes, i.e. 1Gb = 1,000,000,000 bytes.

    The SI units defining disk capacity have changed and the flash card manufacturers are using the correct notation. Unfortunately Microsoft (et al.) aren't. In SI units 1Gb (gigabyte) is now defined as 1,000,000,000 bytes and a "gigibyte" (or GiB) is defined as 1,073,741,824 bytes. The two sizes are used interchangeably when they shouldn't. Your computer filing system is reporting the size of a flash card in gigibytes but calling the result gigabytes.


My card shows only 2Gb of space but I have a 4Gb card.

You've probably formatted your card as FAT rather than FAT32. The FAT filing system can only address 2Gb whereas FAT32 can address much more than this.

Writes to my card seem to be slowing down.

You probably deleted individual files from the card and are now experiencing "fragmentation". This means that instead of being able to write an image in consecutive blocks of the flash card, the controller has to search for free blocks slowing down the whole write process. Best practice is to not delete individual files but format the entire card in the camera when you've transferred your images. This ensures that new images can now be written in consecutive blocks.

I get occasional blank or black frames

If your battery is low this may be the culprit, the camera requires more power to write to the card than for normal operation. It may be that power is just dipping below required levels during a write.

A second possibility is that you have a bad block on the card that has not been marked as bad. Recover all your other images then perform a full format on a PC. This will find and mark any bad blocks.

I get corruption in images, either colour streaks or blank sections

This is probably the result of an undetected bad block. See the previous answer for the solution.

Your PC complains about damaged files or there are missing image files.

This is probably the result of a bad block in the file allocation table or other corruption due to exposure to magnetic fields or similar. The best solution is to use a disk recovery tool such as Image Rescue from Lexar or Photo Rescue from Data Rescue and then perform a full format on this card.