How work exactly the MFS?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How work exactly the MFS?

跳至解决方案
2,854 次查看
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,313 次查看
arnogir
Senior Contributor II

Hello

Flush memory is the good solution!

在原帖中查看解决方案

0 项奖励
回复
7 回复数
2,313 次查看
arnogir
Senior Contributor II

Hello

No body to inform me?:smileycry:

0 项奖励
回复
2,313 次查看
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,313 次查看
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,313 次查看
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,314 次查看
arnogir
Senior Contributor II

Hello

Flush memory is the good solution!

0 项奖励
回复
2,313 次查看
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,313 次查看
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 项奖励
回复