From patchwork Wed Nov 2 07:20:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Liu X-Patchwork-Id: 123234 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 35430B6F72 for ; Wed, 2 Nov 2011 18:20:15 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B20372959C; Wed, 2 Nov 2011 08:20:12 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i2hnoyvUM7mi; Wed, 2 Nov 2011 08:20:12 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D649529590; Wed, 2 Nov 2011 08:20:11 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 478F629590 for ; Wed, 2 Nov 2011 08:20:09 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qh-uBbCWU8fB for ; Wed, 2 Nov 2011 08:20:07 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-qy0-f172.google.com (mail-qy0-f172.google.com [209.85.216.172]) by theia.denx.de (Postfix) with ESMTPS id 29C342958F for ; Wed, 2 Nov 2011 08:20:05 +0100 (CET) Received: by qyk34 with SMTP id 34so5588795qyk.3 for ; Wed, 02 Nov 2011 00:20:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.92.14 with SMTP id p14mr344384qcm.158.1320218403279; Wed, 02 Nov 2011 00:20:03 -0700 (PDT) Received: by 10.229.218.9 with HTTP; Wed, 2 Nov 2011 00:20:03 -0700 (PDT) Date: Wed, 2 Nov 2011 15:20:03 +0800 Message-ID: From: Bob Liu To: u-boot@lists.denx.de, sr@denx.de, uclinux-dist-devel@blackfin.uclinux.org Subject: [U-Boot] [BUG] cfi_flash can't work correctly on latest uboot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 ..|..".. 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, --- 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.