"SD.h" works and "tinyFAT" not ...

Hi,

I have an Arduino MEGA and shielded with TFT with SD card.

When I use "# include <SD.h> everything works ok ..

But when I use "# include <tinyFAT.h> can not open the card

I tried to format on windows FAT(Predefinition) and FAT32

ALL LIBRARIES ARE ORIGINALS:

tinyFAT --> Electronics - Henning Karlsen

the next code return: "Unsupported filesystem"

#include <tinyFAT.h>
#include <avr/pgmspace.h>

byte res;
long msStart, msEnd, msTotal, msAvg, msHigh, msLow;

char *verboseError(byte err)
{
	switch (err)
	{
	case ERROR_MBR_READ_ERROR:
		return "Error reading MBR";
		break;
	case ERROR_MBR_SIGNATURE:
		return "MBR Signature error";
		break;
	case ERROR_MBR_INVALID_FS:
		return "Unsupported filesystem";
		break;
	case ERROR_BOOTSEC_READ_ERROR:
		return "Error reading Boot Sector";
		break;
	case ERROR_BOOTSEC_SIGNATURE:
		return "Boot Sector Signature error";
		break;
	default:
		return "Unknown error";
		break;
	}
}

void setup() {
  // Initialize serial communication at 115200 baud
  Serial.begin(9600);
  Serial.println();
  
  // Initialize tinyFAT 
  // You might need to select a lower speed than the default SPISPEED_HIGH
 
  res=file.initFAT();
  
  Serial.println(res,HEX);
  
  if (res!=NO_ERROR)
  {
    Serial.print("***** ERROR: ");
    Serial.println(verboseError(res));
    while (true) {};
  }

  Serial.println("This program will measure the average time a call to the writeLn()-function takes.");
  Serial.println();
  Serial.println("***** Send any character to start *****");
  while (!Serial.available()) {};
  Serial.flush();
  
  if (file.exists("SPDCHK.FIL"))
    file.delFile("SPDCHK.FIL");
    
  file.create("SPDCHK.FIL");
  
  res=file.openFile("SPDCHK.FIL", FILEMODE_TEXT_WRITE);
  if (res==NO_ERROR)
  {
    msTotal=0;
    msLow=1000000;
    msHigh=0;
    
    Serial.print("<");
    for (int cc=0; cc<64; cc++)
    {
      if (((cc+1)%16)!=0)
        Serial.print("-");
      else
        Serial.print("+");
    }    
    Serial.println(">");
    
    Serial.print(" ");
    for (int cc=0; cc<1024; cc++)
    {
      msStart=millis();
      file.writeLn("SpeedCheck - This is just a random line of text.");
      msEnd=millis();

      msTotal+=(msEnd-msStart);
      if ((msEnd-msStart)<msLow)
        msLow=msEnd-msStart;
      if ((msEnd-msStart)>msHigh)
        msHigh=msEnd-msStart;
        
      if (((cc+1)%256)==0)
        Serial.print("+");
      else if (((cc+1)%16)==0)
        Serial.print("-");
    }
    file.closeFile();
    file.delFile("SPDCHK.FIL");
    Serial.println();
    Serial.println();
  }
  else
  {
    switch(res)
    {
      case ERROR_ANOTHER_FILE_OPEN:
        Serial.println("** ERROR: Another file is already open...");
        break;
      default:
        Serial.print("** ERROR: ");
        Serial.println(res, HEX);
        break;
    }
  }
  Serial.println("Sample size : 1024 samples");
  Serial.print  ("Average time: ");
  Serial.print  (msTotal/1024, DEC);
  Serial.println(" ms");
  Serial.print  ("Highest time: ");
  Serial.print  (msHigh, DEC);
  Serial.println(" ms");
  Serial.print  ("Lowest time : ");
  Serial.print  (msLow, DEC);
  Serial.println(" ms");
  Serial.println();
  Serial.println("***** All done... *****");
  
}  

void loop() 
{
}

I tried to format on windows FAT(Predefinition) and FAT32

Curious.

The library supports FAT16 formatted SD cards up to 2GB in size. 4GB FAT16 formatted SD cards does not work. Long filenames are not supported. Keep you filenames compliant with the old 8.3 standard.

The library supports FAT16 formatted SD cards up to 2GB in size. 4GB FAT16 formatted SD cards does not work. Long filenames are not supported. Keep you filenames compliant with the old 8.3 standard.

temporary resolve the problem..

i see this:

cards up to 2GB in size

...

I changed my card 2 gb for a 1 gb ... formatted in FAT16 and it worked very well..

I think im having the same issue. Using the Sainsmart 3.2" LCD / touch / sd shield.
Have set the SS pin to 53 for the mega, and tried all the SPISPEED settings, but cant talk to the SD card, it just reports "Unsupported filesystem"
Using a 2GB card formatted to FAT16, loaded with the sample images from UTFT_tinyFAT demo, but it wont go.
Other demos worked great, its a good set of libraries.

The funny thing is if I use the ardunio's SD library, then the CardInfo example works fine, detects the card, the FAT16 and lists the correct files, so I know its connected up fine and able to work!

I'll have to see if I can dig up a 1GB SD card from somewhere and give that a try, shame though as I wanted the space.

what do you know I managed to resolve it.

I have SDFAT and TinyFAT both running finally! I was formatting the SD Card to FAT (ie FAT16) previously using WinXP. For some reason TinyFAT did not like it.
Then I downloaded SD Card Formatter 4.0 from the SD association ;

Using this I did a full format (overwrite) and lo and behold it reads in using tinyFAT OK now!

So, that's a 2GB card checking in OK, wonder if that works for you jot4p.. though its been a while you prbly moved on.
Hopefully it will help the next guy :slight_smile:

viksahota:
what do you know I managed to resolve it.

I have SDFAT and TinyFAT both running finally! I was formatting the SD Card to FAT (ie FAT16) previously using WinXP. For some reason TinyFAT did not like it.
Then I downloaded SD Card Formatter 4.0 from the SD association ;
https://www.sdcard.org/downloads/formatter_4/

Using this I did a full format (overwrite) and lo and behold it reads in using tinyFAT OK now!

So, that's a 2GB card checking in OK, wonder if that works for you jot4p.. though its been a while you prbly moved on.
Hopefully it will help the next guy :slight_smile:

THX alot. This worked for me very well.

viksahota:
what do you know I managed to resolve it.

I have SDFAT and TinyFAT both running finally! I was formatting the SD Card to FAT (ie FAT16) previously using WinXP. For some reason TinyFAT did not like it.
Then I downloaded SD Card Formatter 4.0 from the SD association ;
SD Memory Card Formatter for Windows/Mac | SD Association

Using this I did a full format (overwrite) and lo and behold it reads in using tinyFAT OK now!

So, that's a 2GB card checking in OK, wonder if that works for you jot4p.. though its been a while you prbly moved on.
Hopefully it will help the next guy :slight_smile:

Thank you viksahota it worked :slight_smile: