I'm using the FFS library with the example project (NAND Flash File System patch for Freescale MQX™ RTOS 4.0.0). After running the format command from the shell I always get 10 723 328 bytes free disk space.
I want to enlarge the drive to cover e.g. 100M of NANDFLASH. I tried modifiying NANDFLASH_1ST_DATA_DRIVE_SIZE_IN_BLOCK but without effect.
Has anyone got a hint for me, please? Thank you!
Solved! Go to Solution.
Hi Frieder,
I opened the nandflash_wl.ffs.h header in the ffs_twrk70f120m project and changed the define as follows:
#define NANDFLASH_1ST_DATA_DRIVE_SIZE_IN_BLOCK 200 //DES was 90
Recompile the ffs, then recompile the mfs_nandflash_twrk70f120m example project and it did increase the disk space.
Note that the default 90 size gave a 10.7MB disk and a 200 size gave a 251MB size.
So the example we have is generating (or partitioning) a small disk on the NAND flash and not making it one big disk.
The specific NAND device information is in the bsp_twrk70f120m MT29F2G16.c file.
When I changed the block to 1937 (2048-110-1) I got a big disk.
Regards,
David
Hi David,
Thank you. It worked for me also. I want to ask you that after power on reset if I call "fsopen" it says "you must format disk to continue". I lose all of my data, if I format. How can I solve this. I attached the console output also , too show what I did.
Hi Okan,
You must issue a "fsclose" after adding files/directories to the NAND device. Then you are OK to power off and then power on, issue "fsopen" and life should be good.
Regards,
David
Hi David, thank you...
It worked.
I tried couple of things. If you call "fsclose", you don't lose anything with POR. But if you made change in file and reset your device, you lose your changes. Isn't it a bug. For example, I have log file and I am continuously writing in it, suddenly power is gone. After reset I lost all of my data. Should I call fsclose and fsopen after any changes in filesystem?
Best Regards,
Okan
Hi Okan,
It is all up to user how to implement. Other customers I have open, write, close a log file just to ensure the data is good should there be a brown out or total lose of power.
I'm heading out on vacation so not back until July 8th.
You might snoop around to see if there is a flush command that might help.
But in general the FAT table is in RAM and if power gone file system gets corrupted.
Regards,
David
Hi David,
I am using TWR-K60F120, CW10.4 and MQX4.0.2. When I change the
#define NANDFLASH_1ST_DATA_DRIVE_SIZE_IN_BLOCK 90
#define NANDFLASH_1ST_DATA_DRIVE_START_BLOCK 110
to
#define NANDFLASH_1ST_DATA_DRIVE_SIZE_IN_BLOCK 1937
#define NANDFLASH_1ST_DATA_DRIVE_START_BLOCK 110
the disk space is 126212096 bytes. It changed but is still not the correct value.
I tried to delete the file and replace it by a new one but it still does not show the correct free space.
Thank you.
-Daniel
Hi Daniel,
There is a difference. Don’t know why but I am asking our MQX team and will respond with answer later.
Going back in time to MQX4.0.0 and the FFS applied to it and comparing the ddi_nand_data_drive_get_info.cpp files shows a difference.
If you look at the FFS 4.0.2 version it had added a “/2” to line 64 which halved the memory size for the NAND. If I removed it to make it same as MQX FFS4.0.0 I see the correct NAND size and testing seems to work fine.
Regards,
David
Hi David,
Thank you.
Another question for NAND Flash is that is there any ioctl command used for page erase?
I read that it has the block erase but didn't see anything about the page erase.
-Daniel
Hi Daniel,
The data sheet for the Micron NAND flash indicates there is only Block erase capability.
No page erase capability that I can see.
Regards,
David
Hi David,
Thank you for your answer.
In that case, I need to erase a block before I can write to a page.
But how could I keep the content in the rest of pages?
Thank you.
-Daniel
Hi Daniel,
I think you are looking too deep into using the NAND flash driver.
Please review following document in MQX path:
C:\Freescale\Freescale_MQX_4_0_2\doc\ffs\MQXFFSUG.pdf Section 3.2.
My read of it indicates that once the MFS is mounted on top of the wear-leveling FFS you just access it as a file system and it will handle things for you.
Regards,
David
Hi David,
I am using TWRK60F120M board. in nandflash I am creating datalog so I have to write continuosly in nandflash & to save data properly after every 10-15 sec I am closing nandflash & then reopening it to write next data but here I checked after 4-5 cycle of nand close & open next time when I sent nandopen command my task is goes in block state, when I checked task summary I see unhandled interrupt state for that task & idle task become active.
Thank you.
Hi adt123,
How much data are you writing to the NAND in the 10-15 second interval?
Are you using MQX4.1 or older MQX?
Do you get an error on the fsclose()?
Are you using the mfs_nandflash_twrk60F120m example or your own code?
Regards,
David
Hi David,
I am using TWRK60F120M board CW10.5 MQX4.0.2 & FFS4.0.2
In source code of FFS I have changed
#define NANDFLASH_1ST_DATA_DRIVE_SIZE_IN_BLOCK 1937 //previous was 90
#define NANDFLASH_1ST_DATA_DRIVE_START_BLOCK 110
for this I am getting free disk space as 252694528
I wrote some 30 Mb data to nandflash successfully but after that I am unable to write any data or overwrite any previous file saved in nandflash, then I tried to format device but I got error as Error while formatting: 0x301d
then I send command nanderasechip after this fsopen for fsopen I got error as
C:/Freescale/Freescale_MQX_4
_0/ffs/source/wearleveling/ddi/common/page_order_map.cpp, line 199.
after getting this error I tried to reopen nandflash after some time but got the same error but if do changes in wearleveling like
#define NANDFLASH_1ST_DATA_DRIVE_SIZE_IN_BLOCK 90 //from 1937
#define NANDFLASH_1ST_DATA_DRIVE_START_BLOCK 110
and after this again I erased the chip & sent fsopen it worked.
How can I overcome this problem?
Thanks.
Hi adt123,
Two things to try please:
1) Test with MQX4.1
2) Workaround is not to use append mode, open the file rather for modification (r+) and perform seek to SEEK_END before write.
Regards,
David
Thank you David I will check this one.
Hi David,
I am using MQX4.0.2 & I am using the mfs_nandflash_twrk60f120m example but not using the shell part I am sending fsopen/fsclose commands through my coding.since I wanted demo.c instead of demo.cpp from ffs example I used the code from post https://community.freescale.com/thread/308605
About data after writing nearly about 2-3 Kb I am closing nandflash & again immediately I send the cmd fsopen to reopen nandflash. but after 5-6 times I got nandflash uninstalled but for fsopen my task goes to block state.
& if I reset the controller I got error for fsopen as
assertion failed: logicalIndex < m_entryCount, file C:/Freescale/Freescale_MQX_4
_0/ffs/source/wearleveling/ddi/common/page_order_map.cpp, line 199.
Thank you
Hi David,
My problem is that when I use the wear-leveling FFS and combine this in the USB MSD. When I get a read request, it shows: assertion failed: 0, file simple_mutex.cpp line 141. My understanding is that in USB part, if I use FFS, the mutex is disabled somehow.
Thank you.
-Daniel
Hi David,
Just calling "fflush (filesystem_handle)" after changing file solve this problem. Thank you...
Best Regards,
Okan
Hi Okan,
I've tried the same call to fflush(...) but it doesn't work for me. While trying to understand what happens, I have seen the function _io_nandflash_wl_ioctl() doesn't make anything in the case of IO_IOCTL_FLUSH_OUTPUT command... Can you tell me what does fflush(...) function execute in your case?
Thank you!
Hi David,
Thank you... Have a nice vacation..