How work exactly the MFS?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How work exactly the MFS?

ソリューションへジャンプ
2,851件の閲覧回数
arnogir
Senior Contributor II

Hello

I'm using MQX 4.1 on K70 with an external Nandflash linked to the NFC.

I open this device and mount a device ("a:") and then use to store a big file resource used by PEG (400 000 Bytes)

Also, for my application, I want save some parameter in a file.

Then I open a file, save some data and close the file.

But after a power off/On, data are note saved in the file. I must close the MFS.

But I think If I close to re open, My PEG resource could not run correctly..

Is mandatory to close the MFS to save definitely a file into the Nandflash?

How work the MFS? When data are realy saved in the nandflash?

Thanks

ラベル(1)
0 件の賞賛
返信
1 解決策
2,310件の閲覧回数
arnogir
Senior Contributor II

Hello

Flush memory is the good solution!

元の投稿で解決策を見る

0 件の賞賛
返信
7 返答(返信)
2,310件の閲覧回数
arnogir
Senior Contributor II

Hello

No body to inform me?:smileycry:

0 件の賞賛
返信
2,310件の閲覧回数
arnogir
Senior Contributor II

Is IOCtl Flush will resolved my problem?

If yes, should I do it on file handle or on mfs handle?

0 件の賞賛
返信
2,310件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi Arno,

Are you running the FFS with the MFS to access NAND flash?

NAND flash requires FFS (flash file system with wearleveling).

FFS has a fflush command using filesystem_handle:

/TASK

0 件の賞賛
返信
2,310件の閲覧回数
arnogir
Senior Contributor II

Hi

I'm using the following code to open the  flash.

if (_io_nandflash_wl_install(&_bsp_nandflash_wl_init, FFS_DEVICE) != MQX_OK) { printf("Can't install FFS!\n"); // _task_block();   } else { if (nandflash_handle == NULL) { /* Open nand flash wl in normal mode */ nandflash_handle = fopen(FFS_DEVICE, NANDWL_OPEN_NORMAL); if ( nandflash_handle == NULL ) { printf("Unable to open NAND Flash device.\n"); printf("\nYou must run \"ffs_repair\" command\n"); return -1; } /* Install MFS over nand_wl driver */ error_code = _io_mfs_install(nandflash_handle, filesystem_name, (_file_size)0); if (error_code != MFS_NO_ERROR) { printf("Error initializing MFS: %s\n", MFS_Error_text((uint32_t)error_code)); return -1; } if (filesystem_handle == NULL) { /* Open file system */ filesystem_handle = fopen(filesystem_name, NULL); error_code = ferror (filesystem_handle); if ((error_code != MFS_NO_ERROR) && (error_code != MFS_NOT_A_DOS_DISK)) { printf("Error opening filesystem: %s\n", MFS_Error_text((uint32_t)error_code)); return -1; } printf ("NAND flash installed to %s\n", filesystem_name); if ( error_code == MFS_NOT_A_DOS_DISK ) { printf("NOT A DOS DISK! Format will start.\n"); error_code = ioctl(filesystem_handle,IO_IOCTL_DEFAULT_FORMAT,NULL); if (error_code != MFS_NO_ERROR) { printf("Format finish with error code 0x%X", error_code); } else { printf("Format finish"); } return 0; } } else { printf("\nNAND flash was installed.\n"); } } else { printf("\nNAND flash device was opened.\n"); } return 0; }

After that I open a file by using path "a:/file.x"...

This answer to your question?

0 件の賞賛
返信
2,311件の閲覧回数
arnogir
Senior Contributor II

Hello

Flush memory is the good solution!

0 件の賞賛
返信
2,310件の閲覧回数
skteh
Contributor III

Hi Arnaud,

How you flush you memory?

I tried fflush(filesystem_handle), but it doesn't save.

After power off, the file gone.

Thankx

0 件の賞賛
返信
2,310件の閲覧回数
arnogir
Senior Contributor II

I do fflush only:

returnCode = fflush(My MQX_FILE_PTR)

Test the return code if return MQX_OK or other?

0 件の賞賛
返信