This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

FS Crash on MCB2300 with SD_File Example

I try to use RL-FlashFS. Exactly SD_File Example on MCB2300. RL-ARM Version 3.21. MDK-ARM Version 3.20.
I modified cmd_fill function:

/*----------------------------------------------------------------------------
 *        Create a file and fill it with some text
 *---------------------------------------------------------------------------*/
static void cmd_fill (char *par) {
   char *fname, *next;
   FILE *f;
   int i,cnt = 1000;

   fname = get_entry (par, &next);
   if (fname == NULL) {
      printf ("\nFilename missing.\n");
      return;
   }
   if (next) {
      par = get_entry (next, &next);
      if (sscanf (par,"%d", &cnt) == 0) {
         printf ("\nCommand error.\n");
         return;
      }
   }

   f = fopen (fname, "w");              /* open a file for writing           */
   if (f == NULL) {
      printf ("\nCan not open file!\n");/* error when trying to open file    */
      return;
   }
   fclose (f);                        /* close the output file               */
   for (i = 0; i < cnt; i++)  {
      f = fopen (fname, "a");         
      fprintf (f, "This is line # %d in file %s\n", i, fname);
       if(ferror (f))
          {
            printf("\nFile ERROR!!!\n");
            fclose (f);
                break;
          }

          fflush (f);
          fclose (f);                        /* close the output file               */
   }
   //fclose (f);                        /* close the output file               */
   printf ("\nFile closed.\n");
}

After that, when I cause function of 10 times successively file system collapses.

format

Format Flash Memory Card? [Y/N]
Memory Card Formatted.
Card Label is KEIL

Cmd> dir

File System Directory...
No files...
                                              14.733.312 bytes free.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_2.txt 20

File closed.

Cmd> dir

File System Directory...
FILL_1.TXT                                           360   01.01.2008  12:00
FILL_2.TXT                                           730   01.01.2008  12:00
                      2 File(s)                    1.090 bytes
                                              14.610.432 bytes free.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> dir

File System Directory...
FILL_2.TXT                                           730   01.01.2008  12:00
FILL_1.TXT                                           360   01.01.2008  12:00
                      2 File(s)                    1.090 bytes
                                              14.405.632 bytes free.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> fill fill_1.txt 10

File closed.

Cmd> dir

File System Directory...
FILL_2.TXT                                           730   01.01.2008  12:00
FILL_1.TXT                                             0   01.01.2008  12:00
                      2 File(s)                      730 bytes
                                              13.955.072 bytes free.

Cmd>

Where the problem?