AnsweredAssumed Answered

MFS nandflash corruption?

Question asked by arnogir on May 20, 2016
Latest reply on May 22, 2016 by Daniel Chen

Hello

 

 

I'm  working with a K701M with  external Flash (like tower K70) with MQX 4.1

I install a nandflash system like bellow.

 

 

 

 

In my system flash, I have many files.

But after test, it seems if I modify the size of one file, other file(s) will be corrupted.

Like if when I add data in a file, place in Nandflash overpass the current Memory block, then take the following block.

But the following block is already busy by other file, then data are overwritten.

 

 

I think the MFS managed all this but it is the feel I have.

 

 

Have I forget something in my code?:

 

 

 

----------------- Init phase ---------------------
MQX_FILE_PTR nandFlashFilePtr;
MQX_FILE_PTR FileHandle;
_io_nandflash_wl_install(&_bsp_nandflash_wl_init, "nandflash_wl:")
nandFlashFilePtr = fopen("nandflash_wl:", NANDWL_OPEN_NORMAL);
_io_mfs_install(nandFlashFilePtr , "a:", (_file_size)0);
FileHandle = fopen("a:", NULL);
ErrorCode = ferror (FileHandle );
if ((ErrorCode != MFS_NO_ERROR) && (ErrorCode != MFS_NOT_A_DOS_DISK))
{
   printf("Error opening filesystem: %s\n", MFS_Error_text((uint32_t)ErrorCode));
   return(MQX_ERROR);
}
printf("\nNAND flash was installed.\n");
----------------- life phase to read or write data in a file---------------------
pointer FilePtr;
FilePtr = fopen("a:\\MyFile.bin", "r+");
fseek(FilePtr , MyAddress);
Write(FilePtr , DataPtr, DataLength);
or
Read(FilePtr , DataPtr, DataLength);
fclose(FilePtr);

 

Thank you

Outcomes