Which way to store log in flash on mpc8xx?
Hi all,
I am looking for a reliable way to store logfiles in flash. The logfiles are written by syslogd.
The problem is that I am running on a MPC8xx processor, and kernel 2.6 is not quite there yet for that processor, so I have to stick with 2.4. Kernel of choice seems to be denx linuxppc_2_4_devel, but I cannot trust the version of jffs2 used in that kernel anymore. Somtimes gc.c crashes with a BUG() in line 139, and sometimes processes are frozen for a looong time waiting for GC. I have debugged that problem a little bit, and definitely, the FLASH access works ok, and the chip is new. No CRC- or read-errors, but still gc.c crashes.
The version of mtd/jffs2 drivers in that kernel seem to be from march/2005 cvs code, but when I read the following, I get even more scared:
http://www.linux-mtd.infradead.org/source.html#kernelversions
So, I need something different. jffs (1) maybe ?
This must be a very common task (to store logfiles in flash), but I just can't seem to find the right way to do it.
Any advice is highly appreciated.
Sincerely,
Signature · 2 lines
David Jander Protonic Holland.
--- David JandJandervidaviddjandertprotonic nlote:
Quoted 6 lines
Hi all,
I am looking for a reliable way to store logflogfilesflash. The logflogfiles
written by syslsyslogd The problem is that I am running on a
MPC8MPCprocessor, and
Quoted 6 lines
kernel 2.6 is not
quite there yet for that processor, so I have to stick with 2.4.
Kernel of choice seems to bedenxdenxulinuxppc_devedeveltI cannot trust the
version of jffsjffsed in that kernel anymore. SomtSomtimescgc>
crashes with a
Quoted 9 lines
BUG()in line 139, and sometimes processes are frozen for a looolooonge
waiting for GC. GChave debugged that problem a little bit, and definitely,
the FLASH access works ok, okd the chip is new. No CRC-CRC read-errors, but
still gc.cgcrashes.
The version of mtd/mtdsjffsivers in that kernel seem to be from march/2005 cvs cvs code, but when I read the following, I
get even more scared:
Quoted 1 line
httphttpww.wwwulinux.mtdrinfradead/source.htmlhtmlnkernelversions
Quoted 11 lines
So, I need something different. jffsjffs maybe ? This must be a very common task (to store logflogfilesflash), but I just can't
seem to find the right way to do it.Any advice is highly appreciated.
Sincerely,
Signature · 1 line
David JandJanderProtProtonicland.
I'm using JFFSJFFS a 860 based board (to store log files amonamongster things) and haven't seen any of the problems you're expeexperiencing I were you, I would double check my configuration settings...
Quoted 5 lines
_______________________________________________
LinuLinuxppcedded mailing list LinuLinuxppcedded@ozlaozlabs httphttpszlaozlabs/mailman/listlistinfoulinuxppcedded
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
Quoted 4 lines · In message <[email protected]> you wrote:
Kernel of choice seems to be denx
linuxppc_2_4_devel, but I cannot trust the version of jffs2 used in that kernel anymore. Somtimesgc.ccrashes with aBUG()in line 139, and sometimes processes are frozen for a looong time
Can you provide a little more details? The MTD / JFFS2 code in this kernel is not too old, andwe use it in a couple of projects without such problems.
Quoted 3 lines
waiting for GC. I have debugged that problem a little bit, and definitely, the FLASH access works ok, and the chip is new. No CRC- or read-errors, but still
gc.ccrashes.
Can you provide soem more information for debugging?
Quoted 3 lines
The version of mtd/jffs2 drivers in that kernel seem to be from march/2005 cvs code, but when I read the following, I get even more scared:
http://www.linux-mtd.infradead.org/source.html#kernelversions
Don't worry. We backported the MTD / JFFS2 code. See the history of changes on our CVS or git server.
Quoted 2 lines
This must be a very common task (to store logfiles in flash), but I just can't seem to find the right way to do it.
Note that log files may cause a lot of trouble when using a JFFS2 file system. Youmay want to addd a buffering layer, like pramfs in a dedicated RAM area (SRAM ideally).
Best regards,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected] Never underestimate the bandwidth of a station wagon full of tapes. -- Dr. Warren Jackson, Director, UTCS
Hi again,
Thanks for helping,
Quoted 4 lines · Wolfgang Denk
[...]
Can you provide a little more details? The MTD / JFFS2 code in this kernel is not too old, andwe use it in a couple of projects without such problems.
Ok, good you asked, because I am willing to debug the problem until I get to the point where it fails, but I will need help, because I am not at home in jffs2 source-code nor its CVS history.
Here are more details:
Kernel: Denx CVS from around july 2005 or something. AFAIK there are no further modifications other than BSP-specific stuff to the MTD code since that day, so I won't bother upgrading any further right now.
Hardware: MPC852T custom board with a 32Mbyte mirror-bit flash-chip (x16 bus)
Software: System based on ELDK-3.1.1. Intended flash-layout and use:
rootfs : 10Mb, ro, hardly ever changed
app : 6Mb, ro, changed on software-upgrade by replacing partition.
log+config : 12Mb, rw
The log+config partition is extremely oversized, because we are aware of the inefficiency of jffs2 for such purposes, we have the available space and we want to stay out of trouble. Syslog writes to 4 log-files which are limited in size to 50..100kbyte each. Logs are then rotated and one rotated copy is kept. Maximum flash use is around 800kbyte for logs + 50kbyte for config data. On a 12Mbyte partition, that shouldn't get us into trouble AFAIK.
Quoted 5 lines
Quoted 3 lines
waiting for GC. I have debugged that problem a little bit, and definitely, the FLASH access works ok, and the chip is new. No CRC- or read-errors, but still
gc.ccrashes.Can you provide soem more information for debugging?
Unfortunately right now I don't have debug messages, because since I installed a kernel with debugging turned on in the jffs2 driver, the problem hasn't repeated. I am working on that.
What happened: System boots, all fs are mounted. The first app that writes something to the log-partition (in this case a config file that is overwritten) causes the GC thread for that partition to crash with a BUG() in line 139 of gc.c, and the application freezes forever. Since GC is dead, all further write-accesses to that partition also hang forever.
The problem seems to ocurr after a few times power-cycling the board. We never intended it to shut-down nicely, if it is at all ever shut-down, so it must be able to survive quite a few power-cycles without breaking.
After a few more power-cycles, the problem is gone again. Each time GC kicks in, it does something, but it crashes before finishing the job, so each time the numbers reported by the printk() in line 138 change, and eventually it work again.
My big question: Is it at all possible that gc.c comes to that BUG() in line 139 because of anything other than a bug in jffs2-code?
I mean, if hardware really was a problem, then I should also get at least CRC-errors from jffs2, shouldn't I? IMHO at least, jffs2 should be robust enough to not crash on flash-errors, shouldn't it?
Also, I am pretty certain that the hardware is good.... but you never know...
Quoted 7 lines
Quoted 4 lines
The version of mtd/jffs2 drivers in that kernel seem to be from march/2005 cvs code, but when I read the following, I get even more scared:
http://www.linux-mtd.infradead.org/source.html#kernelversionsDon't worry. We backported the MTD / JFFS2 code. See the history of changes on our CVS or git server.
I am having trouble finding the right history, but that could be due to the fact that I am not very good at CVS (we use subversion which is slightly different) ;-)
The logs of almost all files in fs/jffs2/ which I have say that the actual version corresponds to the CVS-snapshot of March 13, 2005, and that the previous version of April 2004 is broken.
Which files were modified _after_ March 13, 2005?
(A hint to what command options or tools to use to browse cvs-logs more easily at this point is appreciated... I am using cervisia).
Quoted 6 lines
Quoted 2 lines
This must be a very common task (to store logfiles in flash), but I just can't seem to find the right way to do it.
Note that log files may cause a lot of trouble when using a JFFS2 file system. Youmay want to addd a buffering layer, like pramfs in a dedicated RAM area (SRAM ideally).
I know about the problems jffs2 has with logfiles and alikes. I am still thinking about what would be the most robust way of coping with this, and until now, oversized partitions with log-rotation on size seems to do the trick. I don't want to loose log-data on power-loss so I don't feel so comfortable with buffering much of it in RAM.
Best Regards,
Signature · 2 lines
David Jander Protonic Holland.
Quoted 1 line
Quoted 1 line
This must be a very common task (to store logfiles in flash), but I jus=
t can't
Quoted 5 lines
Quoted 1 line
seem to find the right way to do it.
=20
Note that log files may cause a lot of trouble when using a JFFS2 file system. Youmay want to addd a buffering layer, like pramfs in a dedicated RAM area (SRAM ideally).
What's the trouble caused by log files when using a JFFS2? I'm not aware of that. Any pointers to where I should look into are much appreciated.
Best regards,
-Shawn.
Quoted 11 lines · Shawn Jin
Quoted 7 lines
Quoted 3 lines
This must be a very common task (to store logfiles in flash), but I just can't seem to find the right way to do it.
Note that log files may cause a lot of trouble when using a JFFS2 file system. Youmay want to addd a buffering layer, like pramfs in a dedicated RAM area (SRAM ideally).
What's the trouble caused by log files when using a JFFS2? I'm not aware of that. Any pointers to where I should look into are much appreciated.
I guess this should become a FAQ item.
JFFS2 creates one or more nodes whenever sys_write is called. Unbuffered log entries are usually quite small, so a single node is written. Let's assume the worst case, just for fun, writes of a single by.
Now, each node is prepended by a struct jffs2_raw_inode of 64 bytes. So you're causing the first problem:
1. Up to 65x the raw file data is written to flash.
Which means you waste bus bandwidth, was flash space and waste flash lifetime. After GC, most of those nodes should get combined to 4k nodes (plus 64 bytes for the header). Now, JFFS2 also requires an in-memory structure per node, the struct jffs2_raw_node_ref, weighing in at 16 or 24 bytes, if you have a 32bit or 64bit arch. Those will cost you precious memory:
2. Up to 24x the raw file data is required in DRAM.
Next problem is with GC accounting. JFFS2 only differentiates between valid and obsolete data. After writing a huge logfile, all of its nodes are still valid. Therefore GC will never try to GC such nodes, unless they happen to sit in an erase block with a lot of obsolete data. And even then, they could get copied as-is, with no combining.
3. JFFS2 GC is too stupid to detect miniature nodes and combine them.
So, your problem 1 and 2 will not go away if you wait long enough. Renaming the log file also won't help. The only cure would be to *copy* it to the new location and delete the original file afterwards. Or - alternatively - to fix JFFS2 GC and send a patch.
Or - as already proposed - by writing in larger chunks in the first place.
If you decide to fix JFFS2 GC, I'd be happy to review the patches and merge them if deemed worthy.
Jörn
Signature · 4 lines
My second remark is that our intellectual powers are rather geared to master static relations and that our powers to visualize processes evolving in time are relatively poorly developed. -- Edsger W. Dijkstra
Quoted 6 lines · In message <[email protected]> you wrote:
What happened: System boots, all fs are mounted. The first app that writes something to the log-partition (in this case a config file that is overwritten) causes the GC thread for that partition to crash with a
BUG()in line 139 ofgc.c, and the application freezes forever. Since GC is dead, all further write-accesses to that partition also hang forever.
Are you 100% sure your system is stable and wihout any memory errors? Never seen any other erros or crashes?
Quoted 2 lines
My big question: Is it at all possible that
gc.ccomes to thatBUG()in line 139 because of anything other than a bug in jffs2-code?
Yes, for example when your SDRAM initialization is broken and/or other memory corruption happens.
Quoted 3 lines
I mean, if hardware really was a problem, then I should also get at least CRC-errors from jffs2, shouldn't I? IMHO at least, jffs2 should be robust enough to not crash on flash-errors, shouldn't it?
I don't think it's a flash error. If there is data corruption, then it's more likely the SDRAM.
Quoted 6 lines
The logs of almost all files in
fs/jffs2/which I have say that the actual version corresponds to the CVS-snapshot of March 13, 2005, and that the previous version of April 2004 is broken.
Which files were modified _after_ March 13, 2005?
(A hint to what command options or tools to use to browse cvs-logs more easily at this point is appreciated... I am using cervisia).
cvsps is really helpful, see http://www.cobite.com/cvsps/cvsps-2.1.tar.gz
Also there are web interfaces to our kernel tree;
for CVS see
http://81.169.171.120/cgi-bin/cvsweb/ for git see http://81.169.171.120/cgi-bin/gitweb.cgi
Make sure to use at least the version tagged as LABEL_2005_05_09_1245 or later.
Quoted 5 lines
I know about the problems jffs2 has with logfiles and alikes. I am still thinking about what would be the most robust way of coping with this, and until now, oversized partitions with log-rotation on size seems to do the trick. I don't want to loose log-data on power-loss so I don't feel so comfortable with buffering much of it in RAM.
The problem with your approach is the number of erase cycles which will cause the flash to die sooner than you may want.
Best regards,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected] A dog always bit deepest on the veterinary hand. - Terry Pratchett, _Wyrd Sisters_
Quoted 4 lines · In message <[email protected]> you wrote:
What's the trouble caused by log files when using a JFFS2? I'm not aware of that. Any pointers to where I should look into are much appreciated.
Please see the linux-mtd web site and/or MTD mailing list archives for details. JFFS2 works excellent with files that are written once (or with only a few write() calls. Logfiles typically grow forever, by many, many small chunks of data appended in many write() operations - this is kind of killer application for JFFS2.
Best regards,
Wolfgang Denk
Signature · 5 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected] "I find this a nice feature but it is not according to the documen- tation. Or is it a BUG?" "Let's call it an accidental feature. :-)" - Larry Wall in <[email protected]>
Hi again,
Quoted 3 lines · Wolfgang Denk
[...]
Are you 100% sure your system is stable and wihout any memory errors? Never seen any other erros or crashes?
It has been running for several weeks without reboot processing data, and we have never had any other strange things, nor data corruption, crashes, or whatever.
Quoted 5 lines
Quoted 2 lines
My big question: Is it at all possible that
gc.ccomes to thatBUG()in line 139 because of anything other than a bug in jffs2-code?Yes, for example when your SDRAM initialization is broken and/or other memory corruption happens.
Then you would expect to have other symptoms too, don't you? Well, we don't have any other symptoms of SDRAM errors. Although, I have seen PC's with faulty SDRAM that behave as if the HD was broken, but the fine tool "memtest86" finally revealed the truth ;-)
Is there something like memtest86 for linux-ppc (i.e. written in portable C)?
Quoted 3 lines
[...]
I don't think it's a flash error. If there is data corruption, then it's more likely the SDRAM.
Hmm, but.... there is no data corruption. I have not seen one file on flash that had other data than intended, and that inspite of the GC freaking out.
Quoted 7 lines
Quoted 6 lines
The logs of almost all files in
fs/jffs2/which I have say that the actual version corresponds to the CVS-snapshot of March 13, 2005, and that the previous version of April 2004 is broken.
Which files were modified _after_ March 13, 2005?
(A hint to what command options or tools to use to browse cvs-logs more easily at this point is appreciated... I am using cervisia).
Quoted 7 lines
cvsps is really helpful, see http://www.cobite.com/cvsps/cvsps-2.1.tar.gz
Also there are web interfaces to our kernel tree;
for CVS seehttp://81.169.171.120/cgi-bin/cvsweb/ for git see http://81.169.171.120/cgi-bin/gitweb.cgi
Thanks for the tips. The gitweb interface looked quite impressive!
Quoted 2 lines
Make sure to use at least the version tagged as
LABEL_2005_05_09_1245or later.
We have that version. I have been trying to figure out what changed up until that label, but the only thing I found that looked relevant was:
"Re-implement PatchSets 260, 263 and 303"
That commit only changed 3 files, non of them directly related to jffs2 code, and only seemed to add support for FUJITSU flash chips. What am I missing? MTD developers say that cvs from march-2005 _is_ broken, so there must be some evident bug-fixes in your tree since then.... otherwise it is still broken (whatever it was).
Of course, maybe I'm just blind ;-)
Quoted 8 lines
Quoted 5 lines
I know about the problems jffs2 has with logfiles and alikes. I am still thinking about what would be the most robust way of coping with this, and until now, oversized partitions with log-rotation on size seems to do the trick. I don't want to loose log-data on power-loss so I don't feel so comfortable with buffering much of it in RAM.
The problem with your approach is the number of erase cycles which will cause the flash to die sooner than you may want.
That's true, but under normal use, you'll have maybe 5..10 lines a day added to a given logfile, maybe even less, and since the partition is relatively huge, wear-levelling in the jffs2 driver should do the obvious I believe. It's not optimal, but it should work reliably AFAICT.
Regards,
Signature · 2 lines
David Jander Protonic Holland.
Quoted 2 lines · In message <[email protected]> you wrote:
Is there something like memtest86 for linux-ppc (i.e. written in portable C)?
Yes, there is. Run the system with root file system mounted over NFS, and then put some load on the system, like by compiling the linux kernel on the target. Anything else which adds DMA load does not hurt, either. In such a situation, with a lots of context switches, stress on the memory management system and having a lots of DMA traffic going on you may see some memory problems. Unfortunately none of the standard memory tests will catch thse, as the tests usually provide only plain read / write accesses, while the problems show up only in burst mode, i. e. when filling the caches and/or doing DMA.
There is an attempt of a burst mode memory test in the U-Boot code, but I have to admit that I didn't work to show the exact problem on the system it was written for.
Quoted 2 lines
Hmm, but.... there is no data corruption. I have not seen one file on flash that had other data than intended, and that inspite of the GC freaking out.
Maybe there is no corruption of the data in flash. But are you sure that correct data are loaded to and read from RAM? We had a similar problem on a board where data got corrupted only when doing a lot of transfers flash->RAM.
Quoted 1 line
That commit only changed 3 files, non of them directly related to jffs2 code,
This is correct.
Quoted 2 lines
and only seemed to add support for FUJITSU flash chips. What am I missing? MTD developers say that cvs from march-2005 _is_ broken, so there must be some
Yes, of course it's broken. Like all computer code. There are a couple of known issues (especially with NAND flash), but I don't think they could explain the type of problems you are seeing.
Best regards,
Wolfgang Denk
Signature · 5 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected] Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer. - Fred Brooks, Jr.
Hi, just catching up on this problem as I have another unit that showed the same symptom.
My system looks like this
MPC852T
128Mbytes SDRAM
64Mbytes Flash
Flash partitions
2*1.25Mbytes partitions for Kernel 61.5Mbytes for rootfs and applications. Remaining 1Mbyte for U-boot, u-boot env and spare.
I get that same problem as well. kernel BUG at gc.c: 139
I have compiled Perl, Openssl, Openssh, etc running NFS so SDRAM is definitely not the issue.
David: have you gotten any new insights since?
Regards,
David Ho
Quoted 3 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:
Is there something like memtest86 for linux-ppc (i.e. written in portab=
le C)?
Quoted 11 lines
Yes, there is. Run the system with root file system mounted over NFS, and then put some load on the system, like by compiling the linux kernel on the target. Anything else which adds DMA load does not hurt, either. In such a situation, with a lots of context switches, stress on the memory management system and having a lots of DMA traffic going on you may see some memory problems. Unfortunately none of the standard memory tests will catch thse, as the tests usually provide only plain read / write accesses, while the problems show up only in burst mode, i. e. when filling the caches and/or doing DMA.
Quoted 5 lines
There is an attempt of a burst mode memory test in the U-Boot code, but I have to admit that I didn't work to show the exact problem on the system it was written for.
Quoted 1 line
Hmm, but.... there is no data corruption. I have not seen one file on f=
lash
Quoted 1 line
Quoted 1 line
that had other data than intended, and that inspite of the GC freaking =
out.
Quoted 7 lines
Maybe there is no corruption of the data in flash. But are you sure that correct data are loaded to and read from RAM? We had a similar problem on a board where data got corrupted only when doing a lot of transfers
flash->RAM.Quoted 1 line
That commit only changed 3 files, non of them directly related to jffs2=
code,
Quoted 4 lines
This is correct.
Quoted 1 line
and only seemed to add support for FUJITSU flash chips. What am I missi=
ng?
Quoted 1 line
Quoted 1 line
MTD developers say that cvs from march-2005 _is_ broken, so there must =
be some
Quoted 20 lines
Yes, of course it's broken. Like all computer code. There are a couple of known issues (especially with NAND flash), but I don't think they could explain the type of problems you are seeing.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected] Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts
the software engineer. - Fred Brooks, Jr.
_______________________________________________
Linuxppc-embedded mailing list [email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-embedded
Hi,
Quoted 13 lines · David Ho
Hi, just catching up on this problem as I have another unit that showed the same symptom.
My system looks like thisMPC852T
128Mbytes SDRAM
64Mbytes FlashFlash partitions
2*1.25Mbytes partitions for Kernel 61.5Mbytes for rootfs and applications. Remaining 1Mbyte for U-boot, u-boot env and spare.
Quoted 4 lines
I get that same problem as well. kernel BUG at
gc.c: 139I have compiled Perl, Openssl, Openssh, etc running NFS so SDRAM is definitely not the issue.
I have done almost the same (compiling Perl didn't succeed because of an out-of memory condition), and never had any other reason to suspect hardware problems.
After getting some advice from peoble at mtd-list, I switched to 2.6.14 for our new developments, and jffs2 seems a lot more stable now. I can only recommend you to consider switching. Besides consuming a little more RAM and Flash, 2.6.14 is miles ahead in terms of almost anything else, plus it's a bit faster on 8xx than 2.4.25!!
I have to warn you though, that it still seems not to be as rock-solid as one might want for an embedded system: We have a stress test running for a few weeks now simulating power-failures during writes to files on jffs2, and mtd has some occasional hick-ups. Those hick-ups seem to be far less serious than gc.c crashing, but we will have to take them into account in our application. This is the situation: Sometimes the test application crashes giving a write-error on the mtd device, preceded by an error message from the mtd-driver (and jffs2, but the problem seems to come from mtd). The error message is like "MTD do_write_buffer(): software timeout", which normally means a flash programming error, most probably due to sector beeing worn out, but I don't think that is the case, since those problems began appearing quite early and went away all by them selves. Flash doesn't magically "fix" itself over time, does it?
Maybe it's a problem in the AMD flash driver (our device is a Spansion Mirror-bit S29GL256M11)
Quoted 1 line
David: have you gotten any new insights since?
Yes, see above.
Please keep me informed if you get to know something more about the problem ;-)
If you want more detail about what tests we are doing, and the problems we had so far, feel free to ask, or read my posts to the MTD list. Right now its 46268 power-cycles and counting.
Greetings,
Signature · 2 lines
David Jander Protonic Holland.