Message ID | 5a760b8f30a392e82a2ea0cc4d3a158ea5880cfe.1646229716.git.jan.kiszka@siemens.com |
---|---|
State | Accepted |
Commit | f3a56dda880af44dac87b1a60c44ebb7c079c329 |
Delegated to: | Jagannadha Sutradharudu Teki |
Headers | show
Return-Path: <u-boot-bounces@lists.denx.de> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=siemens.com header.i=@siemens.com header.a=rsa-sha256 header.s=selector2 header.b=xt6uL0ds; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7wn52YSgz9sFk for <incoming@patchwork.ozlabs.org>; Thu, 3 Mar 2022 01:03:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 79E1083CAC; Wed, 2 Mar 2022 15:02:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=siemens.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=siemens.com header.i=@siemens.com header.b="xt6uL0ds"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D22FC83C93; Wed, 2 Mar 2022 15:02:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20616.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::616]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F3BE583C97 for <u-boot@lists.denx.de>; Wed, 2 Mar 2022 15:02:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=siemens.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jan.kiszka@siemens.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EFdThPBVc7y8YXv4pnJeFDJH7AeLUbjLG6wZtOYm3NnCI8W8ThYjmkioovvUjJmZP3eYejzHFlYgl9pJPBk4izvaWmkrdUun24ncDY+SLR6aTQLUq7UylCC1MJLlaQaAAOMk2AP7MGwDj45iDmx+EbR2pmhcnNrkPvenWhZYZxSuGedzy/6hbcHtZ13+7HaFGa+yMLa7wPb8qgHyYbaTOzIW9fdDHE531jr5qmzR6Ne3xlUTTI7B/+OiS83ReJgJFBPcebu1vdtqp0rJy8SNcvPomLiyrT8q46gU5RrUy4jElmyiXzqmcNlH++95m3AOllHu1m5dMpb92Q/Ss5eD2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0oLSeQ7AN5KC8wMrTgeHe175e4RnsGYXw7HhOZ/nG/M=; b=OAU69pWXTFMrlU9bhYw13Vt3/bd4lberNPRblCkB20xT+p3Jpr9RNpSozkQVRbzZD6bMk8P122IARY5v4WdgUaruF4xXMLE5tAfZJ25Nh1G8tFmGPKbBNjXEFkUgM+9BU0fGEPnLn5PsjBhIAYTcQu1lzP4/NNEDkfgxO6TEtfnYbaagklHXIA2EUOfnSTiZZtfLE8JRjAVwv0WRpcI5pUYQtIyaBec9ftlRW/OURQbEVbnzKGo+n5KRXozq5RnslD/OhsBqp4IQiI2OuLxwrzK8WCKg9H5kbDsswMPP0CpCva54tdrVVXdRrQILvCKZpH41O+pHTC9J2Fks6OtoEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.70) smtp.rcpttodomain=lists.denx.de smtp.mailfrom=siemens.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=siemens.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0oLSeQ7AN5KC8wMrTgeHe175e4RnsGYXw7HhOZ/nG/M=; b=xt6uL0dsrIt35KB0X9YQuT4hLj06XA/vd8qcY70fS5zjZHw6NR8Q2A+VWxqZBaa3GCh0HGw5lAmxuLJWrHM2mSL7GBFxtHpRqG2aJNrdq4j8suzgkmUsHZGB9iMTrh5UOVdQlJTEEyD+2tQKpjsSRYGSSOt2hDA2U3wHtkVvwhJUVI62Ku2txnXJ4VPrYNkp16a0SmhhmwDOwrrn9sFZ/FKW0qWjqCV+izn/wmI7NTArOQqFkhbIEbh9Si8AB4pEieoHY7Ty6gK7qpG5qZtYNgMk2mU9klaco7Y6Cei2VXRV3JrZSpIKx/YauWJ79rk/ciAyg455mBFegblponVQhA== Received: from DB6PR0202CA0024.eurprd02.prod.outlook.com (2603:10a6:4:29::34) by AM5PR10MB1762.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:1d::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Wed, 2 Mar 2022 14:02:28 +0000 Received: from DB5EUR01FT008.eop-EUR01.prod.protection.outlook.com (2603:10a6:4:29:cafe::a0) by DB6PR0202CA0024.outlook.office365.com (2603:10a6:4:29::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Wed, 2 Mar 2022 14:02:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.70) smtp.mailfrom=siemens.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=siemens.com; Received-SPF: Pass (protection.outlook.com: domain of siemens.com designates 194.138.21.70 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.70; helo=hybrid.siemens.com; Received: from hybrid.siemens.com (194.138.21.70) by DB5EUR01FT008.mail.protection.outlook.com (10.152.4.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Wed, 2 Mar 2022 14:02:28 +0000 Received: from DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) by DEMCHDC9SJA.ad011.siemens.net (194.138.21.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 2 Mar 2022 15:02:27 +0100 Received: from md1q0hnc.ad001.siemens.net (167.87.72.105) by DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Wed, 2 Mar 2022 15:02:27 +0100 From: Jan Kiszka <jan.kiszka@siemens.com> To: U-Boot Mailing List <u-boot@lists.denx.de>, Tom Rini <trini@konsulko.com> CC: Michael Walle <michael@walle.cc>, Jagan Teki <jagan@amarulasolutions.com>, <Tudor.Ambarus@microchip.com>, Vignesh R <vigneshr@ti.com>, <baocheng.su@siemens.com>, chao zeng <chao.zeng@siemens.com> Subject: [PATCH v6 2/2] sf: Query write-protection status before operating the flash Date: Wed, 2 Mar 2022 15:01:56 +0100 Message-ID: <5a760b8f30a392e82a2ea0cc4d3a158ea5880cfe.1646229716.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <cover.1646229716.git.jan.kiszka@siemens.com> References: <cover.1646229716.git.jan.kiszka@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [167.87.72.105] X-ClientProxiedBy: DEMCHDC8A1A.ad011.siemens.net (139.25.226.107) To DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 23f54ae9-9da4-40c1-a107-08d9fc55494a X-MS-TrafficTypeDiagnostic: AM5PR10MB1762:EE_ X-Microsoft-Antispam-PRVS: <AM5PR10MB1762D2922BD10AF1BC0022E995039@AM5PR10MB1762.EURPRD10.PROD.OUTLOOK.COM> X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N9Bf+vTy83mDLiD7e2nNW32Lgc53r8A5spQI83eWkwMu2it36eO9S4QQd10jyjYZXgNGnEVs2RFazHaZbQQWp9Z9AYxVygVVU2Zyh7Wg6T9aLc3PtEpHMBWdruvGT+frvoxSMCUg6i4x1mBOQjqtESZCzspK4R8ztDev7Y9aTI2nc3sjJ/KujhvvUrwD48z/UKXwJg+UTje37Hv/03PNqmHz9GvQX3j4mXAVGJzMJ27E+Cc83QQxBoJl2UfXEAX04e4l2FF8dtR7okUDYgBBpoyhA09feAFGoAXUGdzyHtMBQDHaTuBQFKzLOvA8ABkK4zAK13erZaUPhXatJ4IbkbT86bOFH295wje31guhjcu3o7FW6WquPD0Wj8Pr5vWkfmP6ik4rgSoDj7zHPhQxYsXflW64CDlJQDGSwJf5tpUFwFSjn8ypAAnLjOp3WPzfszFJ2/CrH432Lf7cE2iSMavqK2mLe2u0igpf7tapFvB2IbS1oga61/aHoPLEzw6Ah4M0bQNYl5VrQHjXf5qvqXoMQE8OogCKVbSjEU1KAXQF+vxp6cE2MBiGDbW64VQGdFBids9P5LqnFimSmxaSsqX+GZmFMNftO3VpkCEHsYu5r2MjArCM1ZITNz9P/wJPSFXKxnzrRcfZhhldi80RivhL0mSm5cbGyVikH21UA9vvHn8lvExOWF5L5+7Gr5rv X-Forefront-Antispam-Report: CIP:194.138.21.70; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:hybrid.siemens.com; PTR:hybrid.siemens.com; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(8676002)(70206006)(107886003)(7636003)(40460700003)(7596003)(4326008)(6666004)(356005)(82960400001)(54906003)(336012)(16526019)(26005)(956004)(2616005)(82310400004)(186003)(316002)(36860700001)(110136005)(70586007)(36756003)(86362001)(5660300002)(47076005)(508600001)(83380400001)(8936002)(2906002)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2022 14:02:28.0969 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 23f54ae9-9da4-40c1-a107-08d9fc55494a X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38ae3bcd-9579-4fd4-adda-b42e1495d55a; Ip=[194.138.21.70]; Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR01FT008.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR10MB1762 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion <u-boot.lists.denx.de> List-Unsubscribe: <https://lists.denx.de/options/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=unsubscribe> List-Archive: <https://lists.denx.de/pipermail/u-boot/> List-Post: <mailto:u-boot@lists.denx.de> List-Help: <mailto:u-boot-request@lists.denx.de?subject=help> List-Subscribe: <https://lists.denx.de/listinfo/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=subscribe> Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" <u-boot-bounces@lists.denx.de> X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean |
Series |
sf: Check protection before writing/erasing flash
|
expand
|
diff --git a/cmd/sf.c b/cmd/sf.c index 8bdebd9fd8f..c97d0e28bb8 100644 --- a/cmd/sf.c +++ b/cmd/sf.c @@ -287,6 +287,12 @@ static int do_spi_flash_read_write(int argc, char *const argv[]) return 1; } + if (strncmp(argv[0], "read", 4) != 0 && flash->flash_is_unlocked && + !flash->flash_is_unlocked(flash, offset, len)) { + printf("ERROR: flash area is locked\n"); + return 1; + } + buf = map_physmem(addr, len, MAP_WRBACK); if (!buf && addr) { puts("Failed to map physical memory\n"); @@ -343,6 +349,12 @@ static int do_spi_flash_erase(int argc, char *const argv[]) return 1; } + if (flash->flash_is_unlocked && + !flash->flash_is_unlocked(flash, offset, len)) { + printf("ERROR: flash area is locked\n"); + return 1; + } + ret = spi_flash_erase(flash, offset, size); printf("SF: %zu bytes @ %#x Erased: ", (size_t)size, (u32)offset); if (ret)