From patchwork Tue Dec 3 15:46:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 1203769 X-Patchwork-Delegate: ykai007@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com 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 ozlabs.org (Postfix) with ESMTPS id 47S6bt4pPyz9s4Y for ; Wed, 4 Dec 2019 03:18:34 +1100 (AEDT) Received: by phobos.denx.de (Postfix, from userid 109) id 8E92E81B0D; Tue, 3 Dec 2019 17:10:35 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 04096817DB; Tue, 3 Dec 2019 17:03:22 +0100 (CET) Authentication-Results: mail.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 94B9C8172D; Tue, 3 Dec 2019 16:53:26 +0100 (CET) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E838981686 for ; Tue, 3 Dec 2019 16:46:45 +0100 (CET) Authentication-Results: mail.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.denx.de; spf=pass smtp.mailfrom=paul.kocialkowski@bootlin.com X-Originating-IP: 90.76.211.102 Received: from localhost.localdomain (lfbn-1-2154-102.w90-76.abo.wanadoo.fr [90.76.211.102]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 651FB1C000B; Tue, 3 Dec 2019 15:46:44 +0000 (UTC) From: Paul Kocialkowski To: u-boot@lists.denx.de Subject: [PATCH 1/2] rockchip: misc: Only assign serial# variable if unset Date: Tue, 3 Dec 2019 16:46:31 +0100 Message-Id: <20191203154632.340463-1-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , Thomas Petazzoni , Miquel Raynal Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at mail.denx.de X-Virus-Status: Clean The serial# environment variable is a read-only special variable, that can only be set once. As a result, if the environment was saved to a persistent storage location, attempting to set it again in rockchip_cpuid_set will fail and halt the boot with the following error: Solve this by checking whether the variable is already set before. Signed-off-by: Paul Kocialkowski --- arch/arm/mach-rockchip/misc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c index bed4317f7ece..a0c6a1c0b266 100644 --- a/arch/arm/mach-rockchip/misc.c +++ b/arch/arm/mach-rockchip/misc.c @@ -108,12 +108,16 @@ int rockchip_cpuid_set(const u8 *cpuid, const u32 cpuid_length) high[i] = cpuid[i << 1]; } - serialno = crc32_no_comp(0, low, 8); - serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32; - snprintf(serialno_str, sizeof(serialno_str), "%016llx", serialno); - env_set("cpuid#", cpuid_str); - env_set("serial#", serialno_str); + + if (!env_get("serial#")) { + serialno = crc32_no_comp(0, low, 8); + serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32; + snprintf(serialno_str, sizeof(serialno_str), "%016llx", + serialno); + + env_set("serial#", serialno_str); + } return 0; }