From patchwork Mon Jun 13 11:44:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hatim Kanchwala X-Patchwork-Id: 634588 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rSrZY1l3tz9t0H for ; Mon, 13 Jun 2016 21:45:56 +1000 (AEST) Received: from [127.0.0.1] (helo=ra.coresystems.de) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1bCQIN-00020S-9S; Mon, 13 Jun 2016 13:44:43 +0200 Received: from mta-06-3.privateemail.com ([198.54.122.46]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1bCQI6-00020I-FR for flashrom@flashrom.org; Mon, 13 Jun 2016 13:44:40 +0200 Received: from [192.168.0.10] (unknown [10.20.151.204]) by MTA-06.privateemail.com (Postfix) with ESMTPA id 86D1C6004B; Mon, 13 Jun 2016 11:44:22 +0000 (UTC) To: =?UTF-8?B?0JDQu9C10LrRgdC10Lkg0JXQu9GB0LDQutC+0LI=?= References: <156892285.20160612183407@yelsakov.ru> From: Hatim Kanchwala Message-ID: <575E9C93.70002@hatimak.me> Date: Mon, 13 Jun 2016 17:14:19 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <156892285.20160612183407@yelsakov.ru> X-Spam-Score: -2.5 (--) Subject: Re: [flashrom] AT25DF161 erase failed on ft2232_spi X-BeenThere: flashrom@flashrom.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: flashrom discussion and development mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: flashrom Errors-To: flashrom-bounces@flashrom.org Sender: "flashrom" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff On Sunday 12 June 2016 09:04 PM, Алексей Елсаков wrote: > Hello, Flashrom developers! > > I'am trying to flash Atmel AT25DF161 EEPROM with ft2232h_spi programmer. > My hardware is "FT2232H Breakout board" by DangerousPrototypes - > http://dangerousprototypes.com/docs/FT2232_breakout_board > IC is soldered to board with wires ~3cm length. > > using latest flashrom v0.9.9-r1954 form SVN, IC reads well, but erasing > failed - see logs. > after erasing fail, IC content looks like this: > > > with SST 25VF512, Winbond 25X80VSIC, Macronix MX25L8005 this flashrom > and programmer works well. > what should I do? > Hi Alexey, Based on the logs that you've sent, your chip had some write protection in place and flashrom successfully disabled it. The erase functions defined in flashrom for your chip is correct as per datasheet (https://www.adestotech.com/wp-content/uploads/doc3687.pdf). My theory as to why erase failed for your chip is that some 64kB sector(s) must be locked down, meaning that they have become permanently read-only. Attempting to program or erase such a sector is a cause of command failure. I have attached a patch that can help verify this theory. Please apply the patch locally, build, test and resend the verbose log to the mailing list. Thanks. Kind regards, Hatim > > /-- > best regards, > Alexey Elsakov /mailto:alexey@yelsakov.ru > > > _______________________________________________ > flashrom mailing list > flashrom@flashrom.org > https://www.flashrom.org/mailman/listinfo/flashrom > From 871811ebe82fb9f9be16b4102626552b9f845f42 Mon Sep 17 00:00:00 2001 In-Reply-To: <156892285.20160612183407@yelsakov.ru> References: <156892285.20160612183407@yelsakov.ru> From: Hatim Kanchwala Date: Mon, 13 Jun 2016 16:43:34 +0530 Subject: [PATCH] Print sector lockdown registers for AT25DF161 To: alexey@yelsakov.ru Cc: flashrom@flashrom.org When pretty-printing status register byte 1 of AT25DF chips, if chip is AT25DF161, also print the values of sector lockdown registers for each of the 32 64kB sectors. Signed-off-by: Hatim Kanchwala --- spi25_statusreg.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/spi25_statusreg.c b/spi25_statusreg.c index 01a6862..fb0e8a4 100644 --- a/spi25_statusreg.c +++ b/spi25_statusreg.c @@ -14,26 +14,27 @@ * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "flash.h" #include "chipdrivers.h" #include "spi.h" +#include "flashchips.h" /* === Generic functions === */ int spi_write_status_enable(struct flashctx *flash) { static const unsigned char cmd[JEDEC_EWSR_OUTSIZE] = { JEDEC_EWSR }; int result; /* Send EWSR (Enable Write Status Register). */ result = spi_send_command(flash, sizeof(cmd), JEDEC_EWSR_INSIZE, cmd, NULL); if (result) msg_cerr("%s failed\n", __func__); @@ -452,26 +453,61 @@ static void spi_prettyprint_status_register_atmel_at25_swp(uint8_t status) } } int spi_prettyprint_status_register_at25df(struct flashctx *flash) { uint8_t status = spi_read_status_register(flash); spi_prettyprint_status_register_hex(status); spi_prettyprint_status_register_atmel_at25_srpl(status); spi_prettyprint_status_register_bit(status, 6); spi_prettyprint_status_register_atmel_at25_epewpp(status); spi_prettyprint_status_register_atmel_at25_swp(status); spi_prettyprint_status_register_welwip(status); + + if (flash->chip->model_id == ATMEL_AT25DF161) + { + int address, i, count, result; + unsigned char read_result, lockdown_status_sector[64], cmd[5]; + cmd[0] = (unsigned char)0x35; + cmd[4] = (unsigned char)0x00; + + for (address = 0x000000, i = 0, count = 0; address < 0x200000; address += 0x010000, i++) + { + cmd[1] = (unsigned char)(address >> 16) & 0xff; + cmd[2] = (unsigned char)(address >> 8) & 0xff; + cmd[3] = (unsigned char)address & 0xff; + result = spi_send_command(flash, sizeof(cmd), sizeof(unsigned char), cmd, &read_result); + if (result) + { + msg_cerr("%s failed during command execution (ATMEL_AT25DF161)\n", __func__); + return result; + } + if (i % 8 == 0) + msg_cdbg("0x%02x:", i); + msg_cdbg(" %02x%s", read_result, (i + 1) % 8 == 0 ? "\n": ""); + lockdown_status_sector[address / 0x010000] = read_result; + if (read_result) + count++; + } + + msg_cdbg("%d sector%s locked down permanently%s", count, (count == 1) ? "" : "s", (count == 0) ? "." : " :"); + if (count) + for (i = 0; i < 64; i++) + if (lockdown_status_sector[i]) + msg_cdbg(" %2d", i); + msg_cdbg("\n"); + } + return 0; } int spi_prettyprint_status_register_at25df_sec(struct flashctx *flash) { /* FIXME: We should check the security lockdown. */ msg_cdbg("Ignoring security lockdown (if present)\n"); msg_cdbg("Ignoring status register byte 2\n"); return spi_prettyprint_status_register_at25df(flash); } /* used for AT25F512, AT25F1024(A), AT25F2048 */ int spi_prettyprint_status_register_at25f(struct flashctx *flash) -- http://hatimak.me