[PATCH] RE: Autodetection problems

Chris Elston chris.elston at radstone.co.uk
Mon Mar 14 04:45:08 EST 2005


Ralph Siemsen wrote:

>With mostly default options to the kernel, the MTD autodetection logic 
>performs two calls to do_cfi_probe() at offset 0x000000 and 0x2000000, 
>and then proclaims, erroneously:
>    Found 1 x32 devices at 0x0 in 32-bit bank
>Attempts to use the flash in this state fail miserably (tons of block 
>bitmap errors, cannot access beyond 32MiB, etc).
>
>Though I'd mention this in case anyone encounters similar situation. 
>I'm not sure if the autodetection code is meant to work in my
situation...

I encountered exactly the same problem last Thursday, and I managed to
track it down to drivers/mtd/chips/gen_probe.c.

The code attempts to work out how many chips are interleaved in the
bank.  It does this by assuming that we have min_chips in the bank, and
working it's way up to max_chips (i.e.: assume 1 chip and work upwards
stoping once the "cp->probe_chip" succeeds, or we reach max_chips).

In drivers/mtd/chips/cfi_probe.c, (function cfi_probe_chip) the CFI
query sequence is written to the flash to put the device into 'query'
mode.  Then a call to qry_present is made to check if the query sequence
has really appeared in Flash.  This checks for the presence of 'Q', 'R',
and 'Y' in the appropriate place in each interleaved bank. So for a 1
chip bank it looks for 0x00000051 ('Q'), 2 chip bank 0x00510051 etc...

What's been happening for me (and I suspect Ralph too) is that, when the
code tests for a single-chip bank it looks for 0x00000051 - since only
one of the 2 devices in my bank has been set into query mode, and the
other bank HAPPENS TO CONTAIN 0x0000 AS IT'S DATA - this test succeeds
and genprobe_new_chip thinks it's found a 1 x32 bank, and never goes on
to test for a 2 x16 bank.

I've managed to fix it for me by reversing the direction of the loop in
genprobe_new_chip - i.e.: assume the bank has max_chips and work down.
I think this is the safer way to do it, but I'm not sure, and I'd like
someone to look at this and confirm it for me.

Patch:
--- drivers/mtd/chips/gen_probe.orig    2005-03-14 09:28:55.587881888
+0000
+++ drivers/mtd/chips/gen_probe.c       2005-03-14 09:29:05.474378912
+0000
@@ -162,7 +162,7 @@
        int max_chips = map_bankwidth(map); /* And minimum 1 */
        int nr_chips, type;
 
-       for (nr_chips = min_chips; nr_chips <= max_chips; nr_chips <<=
1) {
+       for (nr_chips = max_chips; nr_chips >= min_chips; nr_chips >>=
1) {
 
                if (!cfi_interleave_supported(nr_chips))
                    continue;

Ralph, let me know if this fixes your case.

Thanks,

Chris.



________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________




More information about the linux-mtd mailing list