I am using LPC1788 with Keil MDK4 along with RLFlash FS[4GB External NAND] & RTX Kernel. In my application i use the NAND Flash to store TEST Reports & activity logs.
Each report is stored in individual file & there are 500 reports in each folder with a max count of 5000 reports[10 folders].data is written only once in the report file[open->write->close]
In the activity log file, the data is appended.In my case, i have appended data to the file around 10000 times[~50 bytes per append].Every time after appending i close the file & then reopen the next time.
Now, i am unable to access any files in the NAND.When i read the directory, the files can be seen, but when i try to open it, the system hangs.infact, the debugger that i am using also hangs[ULINK2] & i have to reset it as well.
I have read somewhere that it is not a good practice to append small data to files again & again..
Please guide..!
Hello Punit,
If it is only one file, then I wouldn't worry about mutexes. The defaults should be more than enough.
Can you check the return values of each fopen() and fclose()? Was the fclose() before the hanging fopen() successful?
I think 16384 is the block size, 8 pages, each page of 2048 bytes. The File_Config.c could confirm this configuration.
The file system counts the available blocks (clusters) for the file system remaining size. This calculation returns much faster, so the calculation of available space isn't as granular (per file or lack thereof) as one might think. I don't think there's a mistake, here. The bytes are just used as a unit of measurement, rather than granularity.
For example, if you added another 925 bytes, ffree() should still return the same value, with 16384 (one block) less than an empty filesystem, right? It would write to remaining free sectors in the same block.
If the log files are not important, you may try another fformat() with the option LOW_EB: http://www.keil.com/support/man/docs/rlarm/rlarm_fformat.htm before retesting the file system.
Thanks, Zack
Hello Zack,
I open only a single file at a time for reading from or writing into..But still i will try by increasing the mutex count..
Another thing that i observed is that after any new file is created, the free space in NAND reduces by 16384 bytes.I check this with ffree() at power on.However,with FINFO the file size of the newly created file is only 925 bytes.
Is there any mistake in File system or NAND Flash configuration?
Thanks, Punit
If fopen() hangs, it may be because the max # of open files has been reached, and the function waits for a mutex that can never be given. I think this situation was improved with an error message later in the newer File System Component. Try increasing max # of open files in "File_Config.c".
RTX's configuration file also specifies the number of mutexes in OS_MUTEXCNT. It may also be increased, to allow more mutexes for the arm standard runtime library that will be used underneath fopen().
What you are worrying about is called data fragmentation. With EFS, we had the defrag() function, but with a FAT(32?) file system on NAND flash, you don't have that option.
Overall, it may be helpful to periodically copy smaller log files into larger ones, then delete the smaller log files. This is an immediate performance penalty for improved performance in the future. Have you tried increasing the number of cached pages?
View all questions in Keil forum