2009-01-13 09:23:26     Error when writing into flash

Document created by Aaronwu Employee on Sep 18, 2013
Version 1Show Document
  • View in full screen mode

2009-01-13 09:23:26     Error when writing into flash

Sajith T S (INDIA)

Message: 67880   

 

(Apologies if I'm asking in the wrong place.  Can't think of any other place to ask this...)

 

I'm trying install a kernel into flash.  There are errors.

 

bf537> protect off 0x20040000 0x2016ffff

Un-Protected 19 sectors

 

 

bf537> erase 0x20040000 0x2016ffff

 

.... done

 

.. done

Erased 19 sectors

 

bf537> tftp 0xb00000 vmImage

Using MAC Address 00:AA:AA:BB:BB:DD

TFTP from server 192.168.50.79; our IP address is 192.168.50.80

Filename 'vmImage'.

Load address: 0xb00000

Loading: #################################################################

         #################################################################

         ##########################################

done

Bytes transferred = 877363 (d6333 hex)

 

bf537> cp.b 0xb00000 0x20040000 $(filesize)

Copy to Flash... done

 

bf537> cmp.b 0xb00000 0x20040000 $(filesize)

byte at 0x00bc0000 (0x1b) != byte at 0x20040000 (0xff)

Total of 786432 bytes were the same

 

 

bf537> bootm 0x20040000

## Booting image at 20040000 ...

   Verifying Checksum ... OK

   Uncompressing Kernel Image ...

    LoadAddr:00001000,  unc_len:4000000,        data:20040040   len:d62f3

Error: Bad gzipped data

GUNZIP ERROR - must RESET board to recover

U-Boot-1.1.3-ADI-2006R1 (May 25 2007 - 15:14:02)

 

CPU:   ADSP BF537 Rev.: 0.2

Board: ADI BF537 stamp board

       Support: http://blackfin.uclinux.org/

Clock: VCO: 500 MHz, Core: 500 MHz, System: 100 MHz

SDRAM: 32 MB

 

[...]

 

 

(Thought I will try booting anyway, even though cmp.b reported mismatch.)

 

It's pretty much the same if I try to the same thing from linux also.

 

root:/> cat /proc/mtd

dev:    size   erasesize  name

mtd0: 00040000 00010000 "Bootloader"

mtd1: 000e0000 00010000 "Kernel"

mtd2: 002d0000 00010000 "RootFS"

mtd3: 00010000 00010000 "MAC Address"

root:/> eraseall /dev/mtd1

Erasing 64 Kibyte @ c0000 -- 85 % complete.

eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ d0000 -- 92 % complete.

eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erased 896 Kibyte @ 0 -- 100% complete.     

root:/>

 

.. and there's a big load of I/O error messages if I try to copy something there.

 

To validate my understanding, this means that parts of flash has gone bad, true?  Or am I doing, or have done, something wrong here?  I am told that it is unlikely that NOR flash will fail this way, so I would suspect what I'd been doing was wrong at some point.

 

Thanks,

 

Sajith.

QuoteReplyEditDelete

 

 

2009-01-13 09:37:07     Re: Error when writing into flash

Robin Getz (UNITED STATES)

Message: 67881   

 

Lets see...

 

You erased 0x12FFFF (1245183 bytes), and then your kernel size is 0xd6333 (877,363 bytes) - so that looks OK.

 

you should visually inspect memory (and flash) to see if the copy worked or not.

 

md.b 0xb00000 0x100 (dump the first 256 bytes of the kernel you tftped in)

 

md.b 0x20040000 0x100 (dump the first 256 bytes of the kernel you copied to flash).

 

If the copy it not working - there is something wrong with your flash driver.

 

What does flinfo show?

 

-Robin

QuoteReplyEditDelete

 

 

2009-01-13 09:58:50     Re: Error when writing into flash

Sajith T S (INDIA)

Message: 67882   

 

I will try that, thank you.  u-boot flash driver was patched to handle an 8M chip.  Do you think that both kernel and u-boot flash handling could be wrong?  (When uClinux "standard" (2008R1.5-RC3) kernel is booted without any modifications, it just "sees" the 4M.    Says:

 

NOR chip too large to fit in mapping. Attempting to cope...

Amd/Fujitsu Extended Query Table at 0x0040

number of CFI chips: 1

cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.

Reducing visibility of 8192KiB chip to 4096KiB

 

 

As mentioned above, trying to erase portions within 4M did not work.

 

Ok, flinfo:

 

bf537> flinfo

 

Bank # 1: AMD TC58FVM6B2A (64Mbit,bottom bootblock)

  Size: 1 MB in 23 Sectors

  Sector Start Addresses:

    20000000  (RO)  20002000  (RO)  20004000  (RO)  20006000  (RO)  20008000  (RO)

    2000a000  (RO)  2000c000  (RO)  2000e000  (RO)  20010000  (RO)  20020000   

    20030000      20040000      20050000      20060000      20070000   

    20080000      20090000      200a0000      200b0000      200c0000   

    200d0000      200e0000      200f0000   

 

Bank # 2: AMD TC58FVM6B2A (64Mbit,bottom bootblock)

  Size: 3 MB in 48 Sectors

  Sector Start Addresses:

    20100000      20110000      20120000      20130000      20140000   

    20150000      20160000      20170000      20180000      20190000   

    201a0000      201b0000      201c0000      201d0000      201e0000   

    201f0000      20200000      20210000      20220000      20230000   

    20240000      20250000      20260000      20270000      20280000   

    20290000      202a0000      202b0000      202c0000      202d0000   

    202e0000      202f0000      20300000      20310000      20320000   

    20330000      20340000      20350000      20360000      20370000   

    20380000      20390000      203a0000      203b0000      203c0000   

    203d0000      203e0000      203f0000   

 

Bank # 3: AMD TC58FVM6B2A (64Mbit,bottom bootblock)

  Size: 3 MB in 48 Sectors

  Sector Start Addresses:

    20400000      20410000      20420000      20430000      20440000   

    20450000      20460000      20470000      20480000      20490000   

    204a0000      204b0000      204c0000      204d0000      204e0000   

    204f0000      20500000      20510000      20520000      20530000   

    20540000      20550000      20560000      20570000      20580000   

    20590000      205a0000      205b0000      205c0000      205d0000   

    205e0000      205f0000      20600000      20610000      20620000   

    20630000      20640000      20650000      20660000      20670000   

    20680000      20690000      206a0000      206b0000      206c0000   

    206d0000      206e0000      206f0000   

 

Bank # 4: AMD TC58FVM6B2A (64Mbit,bottom bootblock)

  Size: 1 MB in 16 Sectors

  Sector Start Addresses:

    20700000      20710000      20720000      20730000      20740000   

    20750000      20760000      20770000      20780000      20790000   

    207a0000      207b0000      207c0000      207d0000      207e0000   

    207f0000   

 

 

QuoteReplyEditDelete

 

 

2009-01-13 10:05:18     Re: Error when writing into flash

Mike Frysinger (UNITED STATES)

Message: 67883   

 

how exactly are you hooking it up ?  with gpios are the additional address lines ?  if so, you need to make sure the banks are properly selected in u-boot before accessing the memory.

 

as for the linux kernel, there is a driver in trunk to handle gpio assisted flashes, but not 2008R1.5

QuoteReplyEditDelete

 

 

2009-01-13 10:08:25     Re: Error when writing into flash

Sajith T S (INDIA)

Message: 67885   

 

Visually inspecting is tedious... :-)

 

I'll assume that modified u-boot flash driver did not handle writes properly.  But, shouldn't the kernel driver have handled it, at least in theory?

QuoteReplyEditDelete

 

 

2009-01-13 10:15:28     Re: Error when writing into flash

Sajith T S (INDIA)

Message: 67886   

 

Yes, using GPIO pin.  But it is not enabled for this address range, so shouldn't it have written without any special handling?  I know I should rather fix the driver than debating it, still...

 

Turns out that it was not fully written to flash.

 

bf537> md.b 0xbc0000 0x20

00bc0000: 1b a2 13 59 db b2 2e 42 35 af 56 47 39 aa f4 f5    ...Y...B5.VG9...

00bc0010: 7d 8f 56 bf 7a a4 c4 3a 0e 02 4d de 2b 2d a0 8d    }.V.z..:..M.+-..

bf537> md.b 0x20100000 0x20

20100000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

20100010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

 

I will look up the trunk kernel and post the results, thanks a lot.

QuoteReplyEditDelete

 

 

2009-01-13 10:35:07     Re: Error when writing into flash

Mike Frysinger (UNITED STATES)

Message: 67888   

 

if you tell the kernel there is only 4 megs but the chip tells the kernel it's actually 8, you're of course going to get a warning about it.  but the kernel should be able to work with that lower 4 megs just fine assuming you dont go wiggling the gpio behind its back.

 

as for u-boot, the situation is messy and largely a problem for the flash driver.

QuoteReplyEditDelete

 

 

2009-01-13 10:35:27     Re: Error when writing into flash

Sajith T S (INDIA)

Message: 67889   

 

Actually, this explains in loud detail what went wrong - 0x20100000 onwards gpio trick should kick in.  (Shame on me for not seeing that early on.) Thanks for all the help.

QuoteReplyEditDelete

 

 

2009-01-13 10:52:49     Re: Error when writing into flash

Robin Getz (UNITED STATES)

Message: 67891   

 

Sajith

 

Visual inspection told you exactly where the problem was. - tedious or not - it is sometimes necessary.

 

Glad things are working for you.

Attachments

    Outcomes