Patchwork [U-Boot,BUG] cfi_flash can't work correctly on latest uboot

login
register
mail settings
Submitter Bob Liu
Date Nov. 2, 2011, 7:20 a.m.
Message ID <CAA_GA1fYWd22aoXNjj5MzrDbfT9UUFURtt0ur_pwB+je9QUjdA@mail.gmail.com>
Download mbox | patch
Permalink /patch/123234/
State RFC
Headers show

Comments

Bob Liu - Nov. 2, 2011, 7:20 a.m.
Hi, folks

I think this patch make cfi_flash can't work correctly.
http://git.denx.de/?p=u-boot.git;a=commitdiff;h=df4e813b72bf07d9026b00455f5e7dffd694ae48


U-Boot 2011.09-svn2735 (ADI-2012R1-pre) (Nov 02 2011 - 15:05:23)

CPU:   ADSP bf526-0.0 (Detected Rev: 0.2) (parallel flash boot)
Board: ADI BF526 EZ-Board board
       Support: http://blackfin.uclinux.org/
Clock: VCO: 400 MHz, Core: 400 MHz, System: 80 MHz
RAM:   64 MiB
Flash: Flash protect timeout at address 20004000 data 1520ff01
Flash protect error at address 20004000
Vpp Low Error.
4 MiB
Flash protect timeout at address 20000000 data 1520ff01
Flash protect error at address 20000000
Flash protect timeout at address 20002000 data 1520ff01
Flash protect error at address 20002000
Block locked.
Vpp Low Error.
Flash protect timeout at address 20004000 data 1520ff01
Flash protect error at address 20004000
Vpp Low Error.
Flash protect timeout at address 20006000 data 1520ff01
Flash protect error at address 20006000
Flash protect timeout at address 20008000 data 1520ff01
Flash protect error at address 20008000
Block locked.
Vpp Low Error.
Flash protect timeout at address 2000a000 data 1520ff01
Flash protect error at address 2000a000
Block locked.
Vpp Low Error.
Flash protect timeout at address 2000c000 data 1520ff01
Flash protect error at address 2000c000
Vpp Low Error.
Flash protect timeout at address 2000e000 data 1520ff01
Flash protect error at address 2000e000
Block Erase Error.

--------------------------------------

        if ((retcode =
             flash_full_status_check (info, sector, info->erase_blk_tout,
                                      prot ? "protect" : "unprotect")) == 0) {
@@ -1975,6 +1980,13 @@ ulong flash_get_size (phys_addr_t base, int banknum)
                                case CFI_CMDSET_INTEL_PROG_REGIONS:
                                case CFI_CMDSET_INTEL_EXTENDED:
                                case CFI_CMDSET_INTEL_STANDARD:
+                                       /*
+                                        * Set flash to read-id mode. Otherwise
+                                        * reading protected status is not
+                                        * guaranteed.
+                                        */
+                                       flash_write_cmd(info, sect_cnt, 0,
+                                                       FLASH_CMD_READ_ID);
----------------------------------------------------------------------------
But with this two lines. flash ops are not correct.

I used old uboot version to read out data from flash.
Then tftpboot and run with latest uboot version, you can see that the read out
data from flash is different.
And without set flash to read-id mode here, it works fine.

U-Boot 2010.06 (ADI-2010R1-RC2) (Oct 20 2010 - 04:37:34)

CPU:   ADSP bf526-0.0 (Detected Rev: 0.2) (parallel flash boot)
Board: ADI BF526 EZ-Board board
       Support: http://blackfin.uclinux.org/
Clock: VCO: 400 MHz, Core: 400 MHz, System: 80 MHz
RAM:   64 MiB
Flash: 4 MiB
In:    serial
Out:   serial
Err:   serial
KGDB:  [on serial] ready
Net:   bfin_mac
Hit any key to stop autoboot:  0
bfin>
bfin> md 0x20100000
20100000: 56190527 0b223987 d60baf4e 2e871c00    '..V.9".N.......
20100010: 00100000 c42c1c00 a86adb94 01021005    ......,...j.....
20100020: 32356662 2e302d36 2e332d30 2d382e30    bf526-0.0-3.0.8-
20100030: 2d494441 31313032 702d3152 732d6572    ADI-2011R1-pre-s
20100040: 00088b1f 00000000 fdc40302 4514780b    .............x.E
20100050: 570e38d6 3d33264f 24f48743 0649d303    .8.WO&3=C..$..I.
20100060: 93080932 834e9970 0931141a 648443a0    2...p.N...1..C.d
20100070: e0804212 12048762 56501a34 086bb2f1    .B..b...4.PV..k.
20100080: 66e0888a d9782808 d165049d 75049945    ...f.(x...e.E..u
20100090: 31415041 ba02cba2 aebbb2ae 8093d34b    APA1........K...
201000a0: 682f1a8a 9cffceb8 105ceeea 7f7df77d    ../h......\.}.}.
201000b0: 3c7cf3df 3aea984f 9d554ea7 4e753aaa    ..|<O..:.NU..:uN
201000c0: b1a94e5d b13ae91e cc436dbe 749b42c2    ]N....:..mC..B.t
201000d0: fa449283 2aa2ec29 a82e0846 b7089ae5    ..D.)..*F.......
201000e0: cc1f9dc4 a9920651 113e5122 b1122213    ....Q..."Q>.."..
201000f0: 308f15a9 b6496a6a 12562598 49a8c8af    ...0jjI..%V....I

bfin> tftpboot 0x1000 u-boot.bin
Using bfin_mac device
TFTP from server 10.100.4.174; our IP address is 10.100.4.50
Filename 'u-boot.bin'.
Load address: 0x1000
Loading: ###############
done
Bytes transferred = 213828 (34344 hex)
bfin> go 0x1000
## Starting application at 0x00001000 ...


U-Boot 2011.09-svn2735 (ADI-2012R1-pre) (Nov 02 2011 - 15:15:05)

CPU:   ADSP bf526-0.0 (Detected Rev: 0.2) (parallel flash boot)
Board: ADI BF526 EZ-Board board
       Support: http://blackfin.uclinux.org/
Clock: VCO: 400 MHz, Core: 400 MHz, System: 80 MHz
RAM:   64 MiB
Flash: 4 MiB
In:    serial
Out:   serial
Err:   serial
KGDB:  [on serial] ready
Net:   bfin_mac
Hit any key to stop autoboot:  0
bfin> md 0x20100000
20100000: 88150020 ffff0001 bfcfffff ffffffff     ...............
20100010: ffffffff ffffffff ffffffff ffffffff    ................
20100020: 00520051 00030059 00390000 00000000    Q.R.Y.....9.....
20100030: 00000000 00170000 00850020 00040095    ........ .......
20100040: 000a0000 00030000 00020000 00160000    ................
20100050: 00000001 00000000 00070002 00200000    .............. .
20100060: 003e0000 00000000 ffff0001 ffffffff    ..>.............
20100070: 0050ffff 00490052 00330031 000300e6    ..P.R.I.1.3.....
20100080: 00000000 00030001 00180000 00010090    ................
20100090: 00000080 00040003 00040003 00020001    ................
201000a0: 00070003 00010002 00110000 00000000    ................
201000b0: 00070002 00200000 00640000 00010000    ...... ...d.....
201000c0: 00060003 00000000 00640001 00010000    ..........d.....
201000d0: 00070003 00110000 00000000 00070001    ................
201000e0: 00000000 00640001 00010000 ffff0003    ......d.........
201000f0: ffffffff ffffffff ffffffff ffffffff    ................
bfin> flinfo

Bank # 1: CFI conformant flash (16 x 16)  Size: 4 MB in 71 Sectors
  Intel Standard command set, Manufacturer ID: 0x20, Device ID: 0x8815
  Erase timeout: 4096 ms, write timeout: 1 ms

  Sector Start Addresses:
  20000000   RO   20002000   RO   20004000   RO   20006000   RO   20008000   RO
  2000A000   RO   2000C000   RO   2000E000   RO   20010000   RO   20020000   RO
  20030000   RO   20040000   RO   20050000   RO   20060000   RO   20070000   RO
  20080000   RO   20090000   RO   200A0000   RO   200B0000   RO   200C0000   RO
  200D0000   RO   200E0000   RO   200F0000   RO   20100000   RO   20110000   RO
  20120000   RO   20130000   RO   20140000   RO   20150000   RO   20160000   RO
  20170000   RO   20180000   RO   20190000   RO   201A0000   RO   201B0000   RO
  201C0000   RO   201D0000   RO   201E0000   RO   201F0000   RO   20200000   RO
  20210000   RO   20220000   RO   20230000   RO   20240000   RO   20250000   RO
  20260000   RO   20270000   RO   20280000   RO   20290000   RO   202A0000   RO
  202B0000   RO   202C0000   RO   202D0000   RO   202E0000   RO   202F0000   RO
  20300000   RO   20310000   RO   20320000   RO   20330000   RO   20340000   RO
  20350000   RO   20360000   RO   20370000   RO   20380000   RO   20390000   RO
  203A0000   RO   203B0000   RO   203C0000   RO   203D0000   RO   203E0000   RO
  203F0000   RO
bfin>


----------------------------------------------------------------------------
                                        info->protect[sect_cnt] =
                                                flash_isset (info, sect_cnt,

FLASH_OFFSET_PROTECT,
Stefan Roese - March 21, 2012, 2:30 p.m.
Hi Bob,

sorry for the late reply.

On Wednesday 02 November 2011 08:20:03 Bob Liu wrote:
> Hi, folks
> 
> I think this patch make cfi_flash can't work correctly.
> http://git.denx.de/?p=u-boot.git;a=commitdiff;h=df4e813b72bf07d9026b00455f5
> e7dffd694ae48
> 
> --- a/drivers/mtd/cfi_flash.c
> +++ b/drivers/mtd/cfi_flash.c
> @@ -1426,6 +1426,11 @@ int flash_real_protect (flash_info_t * info,
> long sector, int prot)
>  #endif
>         };
> 
> +       /*
> +        * Flash needs to be in status register read mode for
> +        * flash_full_status_check() to work correctly
> +        */
> +       flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);
> 
> --------------------------------------
> without this line, flash can't be recognized. So it's correct here.
> 
> U-Boot 2011.09-svn2735 (ADI-2012R1-pre) (Nov 02 2011 - 15:05:23)

<snip>

> --------------------------------------
> 
>         if ((retcode =
>              flash_full_status_check (info, sector, info->erase_blk_tout,
>                                       prot ? "protect" : "unprotect")) ==
> 0) { @@ -1975,6 +1980,13 @@ ulong flash_get_size (phys_addr_t base, int banknum)
>                                 case CFI_CMDSET_INTEL_PROG_REGIONS:
>                                 case CFI_CMDSET_INTEL_EXTENDED:
>                                 case CFI_CMDSET_INTEL_STANDARD:
> +                                       /*
> +                                        * Set flash to read-id mode. Otherwise
> +                                        * reading protected status is not
> +                                        * guaranteed.
> +                                        */
> +                                       flash_write_cmd(info, sect_cnt, 0,
> +                                                       FLASH_CMD_READ_ID);
> ---------------------------------------------------------------------------
> - But with this two lines. flash ops are not correct.
> 
> I used old uboot version to read out data from flash.
> Then tftpboot and run with latest uboot version, you can see that the read
> out data from flash is different.
> And without set flash to read-id mode here, it works fine.
>
> U-Boot 2010.06 (ADI-2010R1-RC2) (Oct 20 2010 - 04:37:34)
> 
> CPU:   ADSP bf526-0.0 (Detected Rev: 0.2) (parallel flash boot)
> Board: ADI BF526 EZ-Board board
>        Support: http://blackfin.uclinux.org/
> Clock: VCO: 400 MHz, Core: 400 MHz, System: 80 MHz
> RAM:   64 MiB
> Flash: 4 MiB
> In:    serial
> Out:   serial
> Err:   serial
> KGDB:  [on serial] ready
> Net:   bfin_mac
> Hit any key to stop autoboot:  0
> bfin>
> bfin> md 0x20100000
> 20100000: 56190527 0b223987 d60baf4e 2e871c00    '..V.9".N.......
> 20100010: 00100000 c42c1c00 a86adb94 01021005    ......,...j.....
> 20100020: 32356662 2e302d36 2e332d30 2d382e30    bf526-0.0-3.0.8-
> 20100030: 2d494441 31313032 702d3152 732d6572    ADI-2011R1-pre-s
> 20100040: 00088b1f 00000000 fdc40302 4514780b    .............x.E
> 20100050: 570e38d6 3d33264f 24f48743 0649d303    .8.WO&3=C..$..I.
> 20100060: 93080932 834e9970 0931141a 648443a0    2...p.N...1..C.d
> 20100070: e0804212 12048762 56501a34 086bb2f1    .B..b...4.PV..k.
> 20100080: 66e0888a d9782808 d165049d 75049945    ...f.(x...e.E..u
> 20100090: 31415041 ba02cba2 aebbb2ae 8093d34b    APA1........K...
> 201000a0: 682f1a8a 9cffceb8 105ceeea 7f7df77d    ../h......\.}.}.
> 201000b0: 3c7cf3df 3aea984f 9d554ea7 4e753aaa    ..|<O..:.NU..:uN
> 201000c0: b1a94e5d b13ae91e cc436dbe 749b42c2    ]N....:..mC..B.t
> 201000d0: fa449283 2aa2ec29 a82e0846 b7089ae5    ..D.)..*F.......
> 201000e0: cc1f9dc4 a9920651 113e5122 b1122213    ....Q..."Q>.."..
> 201000f0: 308f15a9 b6496a6a 12562598 49a8c8af    ...0jjI..%V....I
> 
> bfin> tftpboot 0x1000 u-boot.bin
> Using bfin_mac device
> TFTP from server 10.100.4.174; our IP address is 10.100.4.50
> Filename 'u-boot.bin'.
> Load address: 0x1000
> Loading: ###############
> done
> Bytes transferred = 213828 (34344 hex)
> bfin> go 0x1000
> ## Starting application at 0x00001000 ...
> 
> 
> U-Boot 2011.09-svn2735 (ADI-2012R1-pre) (Nov 02 2011 - 15:15:05)
> 
> CPU:   ADSP bf526-0.0 (Detected Rev: 0.2) (parallel flash boot)
> Board: ADI BF526 EZ-Board board
>        Support: http://blackfin.uclinux.org/
> Clock: VCO: 400 MHz, Core: 400 MHz, System: 80 MHz
> RAM:   64 MiB
> Flash: 4 MiB
> In:    serial
> Out:   serial
> Err:   serial
> KGDB:  [on serial] ready
> Net:   bfin_mac
> Hit any key to stop autoboot:  0
> bfin> md 0x20100000
> 20100000: 88150020 ffff0001 bfcfffff ffffffff     ...............
> 20100010: ffffffff ffffffff ffffffff ffffffff    ................
> 20100020: 00520051 00030059 00390000 00000000    Q.R.Y.....9.....

Hmmm. Strange. Your flash still seems to be in read-id mode after
initial detection. But from looking at flash_get_size(),
the following flash reset command should bring it back to read-array
mode:

	flash_write_cmd (info, 0, 0, info->cmd_reset);

Did you check that cmd_reset is set correctly on your hardware (AMD vs.
Intel)? Which flash chip are you using?

Thanks,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de

Patch

--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1426,6 +1426,11 @@  int flash_real_protect (flash_info_t * info,
long sector, int prot)
 #endif
        };

+       /*
+        * Flash needs to be in status register read mode for
+        * flash_full_status_check() to work correctly
+        */
+       flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS);

--------------------------------------
without this line, flash can't be recognized. So it's correct here.