I am using fle system middleware component to store some data in the RAM of LPC1768.But whenever the function fmount() is called after calling finit() function, it returns an error code of fsNoFileSystem. What could be causing this issue ?
It means, that there is no file system on the drive, i.e. drive is not formatted. Just call fformat() and thats it.
I called fformat fucntion before calling fmount() one but it also returns an error code of fsMediaEroor.
I suggest that you take a look at the File_Demo example. It does something like:
fsStatus stat; /* Initialize and mount drive "R0" */ stat = finit ("R0:"); if (stat == fsOK) { stat = fmount ("R0:"); if (stat == fsOK) { printf ("Drive R0 ready!\n"); } else if (stat == fsNoFileSystem) { /* Format the drive */ if (fformat ("R0:", "") == fsOK) { printf ("Format completed.\n"); } else { printf ("Formatting failed. Check your peripheral driver for errors.\n"); } } else { printf ("Drive R0 mount failed with error code %d\n", stat); } } else { printf ("Drive R0 initialization failed!\n"); }
I was calling the fformat function before even calling fmount function.As soon as I proceeded the way given in above example code, I was able to format the drive successfully and also mount it successfully by calling fmount() function.
I am sorry to poke you again but I have been encountered with one more issue.My code looks like this :-
#include "lpc17xx.h" #include "rl_fs.h" #include <stdio.h> char *opt ="NULL"; fsStatus stat; char *fname="r.txt"; FILE *f; void init_filesystem (void) { LPC_PINCON->PINSEL4=0X00000000; LPC_GPIO2->FIODIR=0XFFFFFFFF; LPC_PINCON->PINSEL2=0X00000000; LPC_GPIO1->FIODIR=0XFFFFFFFF; stat = finit ("R0:"); if (stat == fsOK){ stat = fmount ("R0:"); if(stat==fsOK) { LPC_GPIO1->FIOPIN=0XFFFFFFFF; } else if(stat==fsNoFileSystem) { if (fformat ("R0:", "") == fsOK){ stat = fmount ("R0:"); if(stat==fsOK) { LPC_GPIO2->FIOPIN=0X0000000F; }} }} } void tst_fopen (void) { f = fopen ("R0:\\r.txt","r"); if (f == NULL) { LPC_GPIO2->FIOPIN=0XFFFFFFF3; } else { LPC_GPIO2->FIOPIN=0XFFFFFFF6; } } int main (void) { SystemInit(); init_filesystem(); tst_fopen(); }
Calling init_filesystem() initializes and mounts the RAM drive successfully and turns the corresponding pins of PORT2 HIGH.This happens so if am not calling the tst_fopen() function.But whenever am calling tst_fopen function,fopen() runs out by an exception and the corresponding pins of PORT2 are switched as LOW. What could be the issue ?