NAND OOB Questions...
I have 3 questions about OOB and NAND chips that I'm hoping someone can answer. Per an earlier post, I think there may be two (obscure?) bugs in nand_base.c, but there's too much I don't know about NAND (and the code) to be sure. I believe the following description applies to the most recent stable kernel source (2.6.16.19).
1) The Samsung K9F56* NAND chip allows doing more than one write to the OOB area of a page without an erase; the second write may zero bits that were set to 1 by the first write. Is the Samsung chip unusual in this, or is this normal NAND behavior? (I believe this would be normal for NOR flash).
2) In nand_base.c:nand_write_page(), OOB data is written even when NAND_ECC_NONE is set. Under what circumstances is this useful? (The issue with this is that, in conjunction with (1), this may overwrite OOB in a circumstance where you're trying to write it yourself from user space; pernaps this is something that's only relevant for diagnostics/debugging).
3) nand_prepare_oobbuf() makes a point of setting the internal oobbuf to 0xFF if it's had ECC bytes written to it (based on the this->oobdirty flag). However, the default case (which includes hardware ECC) in nand_write_page() can write the internal oobbuf without setting this->oobdirty, and thus not triggering the later reset to 0xFF. Is there a rationale for this? (The OOB issue induced by 1 & 2 would be benign if oobbuf was cleared to 0xFF).
Thanks for any info.
sf
Quoted 3 lines · Steve Finney
1) The Samsung K9F56* NAND chip allows doing more than one write to the OOB area of a page without an erase; the second write may zero bits that were set to 1 by the first write. Is the Samsung
Bits can not be set to 1 by the first write. FLASH cells are set to 1 by erasing and programming can set bits to 0.
Quoted 2 lines
chip unusual in this, or is this normal NAND behavior? (I believe this would be normal for NOR flash).
On NOR you can do this almost unlimited. NAND is much more restricted vs. write ordering.
Quoted 6 lines
2) In nand_base.c:nand_write_page(), OOB data is written even when
NAND_ECC_NONEis set. Under what circumstances is this useful? (The issue with this is that, in conjunction with (1), this may overwrite OOB in a circumstance where you're trying to write it yourself from user space; pernaps this is something that's only relevant for diagnostics/debugging).
The buffer is usually 0xff except when a caller provides content.
Quoted 7 lines
3)
nand_prepare_oobbuf()makes a point of setting the internal oobbuf to0xFFif it's had ECC bytes written to it (based on thethis->oobdirtyflag). However, the default case (which includes hardware ECC) innand_write_page()can write the internal oobbuf without settingthis->oobdirty, and thus not triggering the later reset to0xFF. Is there a rationale for this? (The OOB issue induced by 1 & 2 would be benign if oobbuf was cleared to0xFF).
Well, if you use ECC then ECC is always at the same offset in the buffer so there is no point in setting it back to 0xff all them time.
Please be aware that the NAND driver has been refactored and some of the algorithms have been changed.
See: http://git.infradead.org/?p=mtd-2.6.git;a=summary
These changes will hit mainline in the 2.6.18 merge window.
tglx
Quoted 5 lines · Thomas Gleixner
Quoted 3 lines · Steve Finney
1) The Samsung K9F56* NAND chip allows doing more than one write to the OOB area of a page without an erase; the second write may zero bits that were set to 1 by the first write. Is the Samsung
Quoted 8 lines
Bits can not be set to 1 by the first write. FLASH cells are set to 1 by erasing and programming can set bits to 0.
Quoted 2 lines
chip unusual in this, or is this normal NAND behavior? (I believe this would be normal for NOR flash).
On NOR you can do this almost unlimited. NAND is much more restricted vs. write ordering.
Just one point of clarification that tglx might not have spelled out clearly here.
In both NAND and NOR you cannot set a 0 bit back to a 1 bit by programming. You can only do this by erasing the erasable block.
Where NOR and NAND differ is that if you program a pattern into NOR that tries to set a 0 to a 1 then (in most cases) the programming operation will be aborted. However, NAND will program the zeros only and 1 bits are just "don't care".