SD card cannot be formatted

I am trying to use the sample code for the SD card module found here:

When I call the function

 pStoreI.Format("FAT16", 0, true);

I get an ArgumentException exception. There is an SD card in the SD card module.

I am not adding the SD card in the Gadgeteer Designer.

I got it working. I was using a very old “Palm” SD card of 14 MBytes size. I put in a recent SD card formatted FAT32, it works ok.

MF only supports FAT32 formatted SDs. But, I was unable to find this in any documentation. GHI?

GHI docs says that it does support FAT16: “NETMF support for the FAT File System is only capable of FAT32 and FAT16. A media formatted as FAT12 will not work. This shouldn’t be an issue since FAT12 is no longer in use.”

@ iamin -

Seems a bit confusing? What about FAT16?

Mike, I have googled a bit:

[em]Debug.Print(“Storage is not formatted. Format on PC with FAT32/FAT16 first.”);

[em]FAT32 and FAT16 formats are supported, but FAT12 is not. You can format your
storage device on a PC with a FAT32 or FAT16 option before using on ChipworkX.[/em]

I tried to use FAT16 because the example code in the GHI SD Card developer’s guide has this line (commented out): //pStoreI.Format(“FAT16”, 0, true); here:
This code does not work. So far, I have not been able to read or write files. I am using a Raptor board with a SDCard module. Does anyone have sample code that is known to work, that can read and write a simple binary file using the GHI SD Card module?

@ dspacek -

I don’t think FAT16 is still used because limitation only 2G.
You can use a simple

vol.Format("FAT", 0);

it should work fine.

You might want to try a different SD Card as some cards don’t seem to work.

Thanks, I re-formatted the SD card on my PC and now it works, I am able to read and write files. Probably the formatting was corrupted.

Another question: In the NETMF Format function

public void Format (
         string fileSystem,
         UInt32 parameter,
         bool force

There are these parameters:

parameter - A parameter to guide formatting for the specified file system.
force - Set to true in order to force removal of the rooted namespace of this volume, or false otherwise.

What are these parameters for, “parameter” and “force”? What do they do? Should “force” be true or false?

fileSystem is the type of filesystem to be created on the media, it should be "FAT"
parameter varies according to fileSystem; but, since fileSystem is always “FAT,” this is either 16 or 32
force if true then all open files are closed.