Here is a link to an article that discusses jffs2. It includes the quote about NAND flash and buffers that follows.
http://www.linux-mtd.infradead.org/faq/jffs2.html "On NAND FLASHM and NOR ECC FLASH we have a write-buffer for writing only full pages to the chips. There could be a loss of data, when the write-buffer is not flushed before power down. There are some mechanisms to ensure, that the write-buffer is flushed. You can force the flush of the write-buffer by using fsync() or sync() in your application. JFFS2 has a timed flush of the write buffer, which forces the flush of the buffer to flash, if there are no writes to the filesystem for more than about 5 seconds. The time depends on the cycle-time of kupdated, which can be adjusted via /proc/sys/vm/dirty_expire_centisecs" Adjusting kupdated would seem to affect more than just jffs2 so it may not be the best way to improve this but it is at one person's opinion on a salution. This made me rethink why this problem wasn't experienced in the last project in which I used jffs2. Since that device included NOR flash this buffering is not used. Keith -----Original Message----- From: uclinux-dev-boun...@uclinux.org [mailto:uclinux-dev-boun...@uclinux.org] On Behalf Of Allen Yang Sent: Thursday, October 15, 2009 7:29 AM To: uClinux development list Subject: RE: [uClinux-dev] JFFS2 file corrupt at power down. I didn't realize I hijack the thread. Sorry about that. I can use fsync() or sync(). However, power can be turned off at any time even during the sync() in the embedded systems. So I think using backup file is necessary to recover from corrupt files. UBIFS doesn't have this type of problems? Regards, Allen -----Original Message----- From: uclinux-dev-boun...@uclinux.org [mailto:uclinux-dev-boun...@uclinux.org] On Behalf Of Allon Stern Sent: Thursday, October 15, 2009 8:53 AM To: uClinux development list Subject: Re: [uClinux-dev] JFFS2 file corrupt at power down. On Oct 14, 2009, at 1:04 PM, Allen Yang wrote: > The problem I have now is sometimes the XML files get corrupted when > board is powered down. The corrupt XML file size is 0 or only a > portion > of the good file size. > > Is JFFS2 supposed to be power down safe? Maybe I missed something when > using JFFS2. (thread hijacking aside) I had a number of problems with JFFS2 on my uClinux board; we ended up switching to UBIFS, which seems to handle powerdowns pretty well. Filesystem notwithstanding, make sure that any changes you want committed are followed up with an fsync. If you don't fsync, then there's a chance that the write will be cached in memory and lost before being stored persistently. This is true for any filesystem. - allon _______________________________________________ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ _______________________________________________ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev _______________________________________________ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev