From patchwork Thu Jul 14 13:42:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hatim Kanchwala X-Patchwork-Id: 648372 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 3rqxkZ2jdxz9sDG for ; Thu, 14 Jul 2016 23:44:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=hatimak-me.20150623.gappssmtp.com header.i=@hatimak-me.20150623.gappssmtp.com header.b=eLITbr3B; dkim-atps=neutral Received: from [127.0.0.1] (helo=ra.coresystems.de) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1bNguX-000469-Pb; Thu, 14 Jul 2016 15:42:41 +0200 Received: from mail-pf0-f196.google.com ([209.85.192.196]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_2) (envelope-from ) id 1bNguJ-00043J-1f for flashrom@flashrom.org; Thu, 14 Jul 2016 15:42:40 +0200 Received: by mail-pf0-f196.google.com with SMTP id i6so4493430pfe.0 for ; Thu, 14 Jul 2016 06:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hatimak-me.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=nK9Fy/EJc+xaiPsBbam5ggDGuI6LwZlSqUt00ur1Wdw=; b=eLITbr3B0vace+oN8iaKcxaVljyLFK4ce/6tocivQQIDpHYLuNGBPMt2h/4WK2/emp 0zNcKOlzAettp/gIlhUvwWsuRvpsNTBL1F7hdyOrPze1cH0UY8g93zHZkTDpJDKVyFHj +Nd1p9318+3dA5NF02d6FJtwWNt2azX4kr3r9PpLK9Xu4VPhCQj5q47DDll6cOB6ZBAA l6DUtx9/EuNDH6FzDwDyvpNQkgF53HBi7+oPpM2o0bOVSMZjpvbV4bZD6GBNcoExdrcE LZvSJBBVMCgsZVZ2Fi+l/gho/3RUiGf1k7OzD+66TabEne0gHJadfD9sXIi9a82hpjAs gOKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nK9Fy/EJc+xaiPsBbam5ggDGuI6LwZlSqUt00ur1Wdw=; b=Zie2pkcqDjDuwO4d1xXaMyyuT88XdtkrKMk3/C6+GFGZNOfU+CDPXVAQL4WYhBI0xz 01kgEkdWuqm3ooWwz6c5niUYUnMRHc2BhJ4WLqh/WamQWhoTWzVDGwMpHZNwZ5JzLnzo tOjPi8hY6F8ce+qVW8DZ1EA6Wn59P6+n/NLOO/yKp6t5gnYf44OIaNdu9nnjqGLCurX1 j/YjwYAZ98BTMh45dbGJfQeuyHZ9NIRC8iAUkdcLClZIXJcR5GV9O6ADvHTM1KYkDsja Gq5KgUb7WqH0Fhpfu8pQzwhppp0uOIpahnxrMox/uBf8+gRcJSG2BlZaBoBZNIY5qfIK DoGg== X-Gm-Message-State: ALyK8tLFko0nTtDdIimh0xAH9catOlsNO+HJr9g4/VHGR5Ybam+YngpDHIK9b3KO20qPPg== X-Received: by 10.98.41.198 with SMTP id p189mr12562327pfp.18.1468503744388; Thu, 14 Jul 2016 06:42:24 -0700 (PDT) Received: from ubuntu-lenovo-z580.domain.name ([150.242.66.203]) by smtp.gmail.com with ESMTPSA id p129sm3258077pfb.73.2016.07.14.06.42.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jul 2016 06:42:24 -0700 (PDT) From: Hatim Kanchwala To: aykut.avci@barco.com Date: Thu, 14 Jul 2016 19:12:14 +0530 Message-Id: <1468503734-4248-1-git-send-email-hatim@hatimak.me> X-Mailer: git-send-email 2.7.4 X-Spam-Score: -1.2 (-) Subject: [flashrom] [PATCH] Print lock register configuration for N25Q128 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@flashrom.org MIME-Version: 1.0 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 Hi, As discussed over IRC, please apply this patch over the latest stable branch of flashrom from https://github.com/flashrom/flashrom. This is a "hacked" solution and is certainly not merge-worthy in its current state. Patch description - When prettyprinting status register byte 1 of N25Q128 chip, also print least two significant bits of lock register for each 64 kB sector. Thanks, Hatim Signed-off-by: Hatim Kanchwala --- spi25_statusreg.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/spi25_statusreg.c b/spi25_statusreg.c index 266e7a9..b050ae1 100644 --- a/spi25_statusreg.c +++ b/spi25_statusreg.c @@ -454,58 +454,65 @@ 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) + if (flash->chip->model_id == ST_N25Q128__3E) { int address, i, count, result; - unsigned char read_result, lockdown_status_sector[32], cmd[5]; - cmd[0] = (unsigned char)0x35; - cmd[4] = (unsigned char)0x00; + uint8_t read_result, lockdown_status_sector[flash->chip->total_size / 64], cmd[4]; + cmd[0] = (uint8_t)0xE8; - for (address = 0x000000, i = 0, count = 0; address < 0x200000; address += 0x010000, i++) + msg_cdbg("Additional information regarding block locks for %s\n", flash->chip->name); + for (address = 0x000000, i = 0, count = 0; + address < flash->chip->total_size * 1024; + 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); + result = spi_send_command(flash, sizeof(cmd), sizeof(uint8_t), cmd, &read_result); if (result) { - msg_cerr("%s failed during command execution (ATMEL_AT25DF161)\n", __func__); + msg_cerr("%s failed during command execution (ST_N25Q128__3E)\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) + msg_cdbg(" [%s,%s]%s", + (read_result & 0x02) ? "1" : "0", + (read_result & 0x01) ? "1" : "0", + (i + 1) % 8 == 0 ? "\n": ""); + lockdown_status_sector[address / 0x010000] = read_result & 0x03; + if (read_result & 0x01) count++; } - msg_cdbg("%d sector%s locked down permanently%s", count, (count == 1) ? "" : "s", (count == 0) ? "." : " :"); + msg_cdbg("%d sector%s locked down%s", count, (count == 1) ? "" : "s", + (count == 0) ? "." : " :"); if (count) - for (i = 0; i < 32; i++) + for (i = 0; i < ARRAY_SIZE(lockdown_status_sector); i++) if (lockdown_status_sector[i]) msg_cdbg(" %2d", i); msg_cdbg("\n"); + msg_cdbg("You _may_ be able to unlock the sector%s\n", (count == 1) ? "" : "s"); } 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); }