• Welcome to SCdev.org. Please log in.

Welcome to the new SCdev forums!

libfat: Varying results with different SD cards

Started by Jospfh, November 16, 2006, 03:01:47 PM

Previous topic - Next topic

Jospfh

Hi,

I made a simple piece of code to test libfat on my Supercard. I found out that the code did not work (fatInit() failed) on my 512 MB DaneElec SD card.
Then I tried a 16MB SD card (SDC-16M Canon) and the code worked like a charm!

I have no problem running Beup and DSlinux which both do not use libfat.

Anyway, if there is an update I would be happy to test it!

I'm about to buy a 2 GB SD card. Can anyone let me know which brand and type SD works with libfat & supercard?

Here is some info:
NDS lite
SuperKey
Supercard (firmware 1.7, also tried firmware 1.63)
libfat-nds-20061028.tar.bz2
devkitpro 19b

The code:
  iprintf("fatInit()..");
  if (fatInit(4, true)) {
   iprintf("\tSuccess\n");
  } else {
   iprintf("\tFailure\n");
  }

  // Write to a file
  FILE *ostream, *fopen();
  if ((ostream = fopen("/test.txt", "w")) == NULL) {
   iprintf("Cannot open file\n");
  }else{
    iprintf("File opened.\n");
    char x[10] = "0123456789";
    fwrite(x, sizeof(x[0]), sizeof(x)/sizeof(x[0]), ostream);
    fclose(ostream); // close file
    iprintf("Wrote to file\n");
  }

  // Read the same file
  FILE *handle;
  if ((handle = fopen("/test.txt", "r")) == NULL) {
   iprintf("Cannot open file\n");
  }else{
    iprintf("File opened\n");
   fseek(handle, 0, SEEK_END);  // Go to end of file
   u32 size = ftell(handle);  // Get current position in file, because it is the end it will be the size
   char* text = (char*) malloc (size);  // Allocate memory for file
   fseek(handle, 0, SEEK_SET);  // Go to begining of file
   fread((void*)text, size, 1, handle); // Read all of file into memory
   fclose(handle); // Close file
 }

  while(1) {

     touchXY=touchReadXY();
     iprintf("\x1b[10;0HTouch x = %04X, %04X\n", touchXY.x, touchXY.px);
     iprintf("Touch y = %04X, %04X\n", touchXY.y, touchXY.py);

  }


http://www.circuitdb.com/fattest.zip
URL=http://www.circuitdb.com]CircuitDB: Your free circuit designs![/URL]