Wrong interleave identification

Korolev, Alexey alexey.korolev at intel.com
Tue Dec 6 06:50:20 EST 2005


Hi all,
 
It looks there is bug in CFI interleave identification algorithm. 

Current interleave identification algorithm one after another checks
interleave 1, interleave 2 , etc.
MTD probe code send 0x98 command to one flash chip and tries to read
"QRY" from flash.

Let consider two examples. For both of them we have flash with two
16bits chips in interleave. 
Example 1. If flash is filled by random data, at CFI info request
addresses.

Mtd reads: 
    0xDF34 0x0051 0x3F1A 0x0052 0x18B2 0x0059
    First assumption of MTD that flash has Interleave 1 and bandwidth 32
bits.
    In 32 bits representations symbol Q is equals 0x0000 0x0051.
    0xDF34 0x0051 is not equals Q in 32 bits representation. 
    So MTD assumption that flash has Interleave 1 and bandwidth 32 is
fail.

   Next assumption that chip has interleave 2 and bandwidth 16 will pass
because Q in 16 bits
    representation is 0x0051.
    It will be equal to information read from flash. MTD correctly
identifies interleave 2.

Example 2. If flash near "QRY" fields is filled by zeroes, 

Mtd reads :
    0x0000 0x0051 0x0000 0x0052 0x0000 0x0059
    These values are equal to "QRY" in 32 bits representation.
    So MTD assumption that flash has Interleave 1 and bandwidth 32 is
pass. 
    After that all arithmetic's will go wrong. Chip size, chip bufsize,
etc will be wrong. 

I was able to reproduce the issue on the following configuration: 
Platform Mainstone II, 2 interleaved 2x16 P30 chips.

Writing zeros at the beginning of the second interleaved chip caused
terrific consequences: after rebooting one chip in interleave was
unavailable at all from Linux.  

I made very simple workaround I just avoided assumption that chip has
interleave 1. It improved situation but it is not a fix. 

May be it worth of trying to send the following sequence of commands in
interleave identification code.
1. Send read query command 0x98989898 (len depends on bank width ) -
then estimate interleave_1
2. Send read status command 0x70707070   - then estimate interleve_2
3. Correct interleave value will be minimum of interleave_1and
interleave_2

Another one way is defining interleave from config file as a property of
current mapping (like bandwidth). Actually it will be correct, because
interleave is a property of the current h/w configuration . 

Thanks,
Alexey





More information about the linux-mtd mailing list