From patchwork Thu Dec 19 16:52:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 1213558 X-Patchwork-Delegate: sbabic@denx.de 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rbSVvjkK"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47dycP3VyPz9sQp for ; Fri, 20 Dec 2019 03:53:06 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B2ADE814C4; Thu, 19 Dec 2019 17:52:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rbSVvjkK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 323A8814D6; Thu, 19 Dec 2019 17:52:53 +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=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 92A5C81486 for ; Thu, 19 Dec 2019 17:52:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=festevam@gmail.com Received: by mail-pl1-x642.google.com with SMTP id s21so70790plr.7 for ; Thu, 19 Dec 2019 08:52:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2DpSfGcLCPu+ZyaQIIqIfSZCPjJDJmeVVfJxR7MOMXU=; b=rbSVvjkKa3iMwkkCLvLWYOh3XUFTUgQGKQE8JcruwhJxBw8FfpTwvU7Xy/Y3USzwiS KXSsVDkPLYivjxBlLSKmnIb5dXN5KiNaalHRxWqeu5O6UVIxNKNypSTdHWjEkW7gmVBV GHW5Zc0a9w5NxzjmTTH6jNC7lFra0raThNsaRGYewgU9cwq53okwYS02PQZQs5e5t187 7cwq3IVEps9idOEf517NMRRZAFscF3lHeagbAKlfIQ8rugJPL5PrYVciHLpagXjpoqzN 84KpX3fOC0Bp9zNPt027sFnrWPBL48BZvhjhuq9f0Zm6PYQT9s979I2evVnMAPTaDe6V OEFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2DpSfGcLCPu+ZyaQIIqIfSZCPjJDJmeVVfJxR7MOMXU=; b=SgXK7pqxcHt7MY9P65XGGvaX7YTIpcPyrt2OdhC6CF560o212Cj+zEelNtqpN3cJ6Y JvAvMdYvokq8avwqWScQoe0VUZ+sBLqQqInjra4gZRycbjnDI+RLsPAYafY9sKLEdOBl RS0wEHSr6BxR8A+7F/TD1L/2kZ/wJfjq3k6ksW9TpD241NU+vH66bhyvRYGqU75kbGiG /0ZAQxggNA2CbAr7ZTlWjrZjXCDLHxtUglJBymMhr+PcjmBvrR2tseRDbG5oL5kBOHnF rjsLrQ8ZStAZcKzKqaZ7wnZyHENHninq2CP9NSF4osDPn+ehLes49DvPqeTxwFWX+O4K oJNA== X-Gm-Message-State: APjAAAVWtaXAPV6/GFcHLT2gGwD0WYL2O07TQgpCuA20vzpD+eLbVXV4 aKq1RyDbpoPd54ASXZR2mF0= X-Google-Smtp-Source: APXvYqzsjW7GSzqhbphmy40jUTCqsN0UjFR88efgRDVmzBDVU+z8Gxumxrc36M1p4WdCw0s2TvQDzw== X-Received: by 2002:a17:902:be10:: with SMTP id r16mr10119512pls.169.1576774367591; Thu, 19 Dec 2019 08:52:47 -0800 (PST) Received: from fabio-Latitude-E5450.nxp.com ([177.221.114.206]) by smtp.gmail.com with ESMTPSA id a12sm7928985pga.11.2019.12.19.08.52.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 08:52:46 -0800 (PST) From: Fabio Estevam To: sbabic@denx.de Subject: [PATCH] mx51evk: Fix U-Boot corruption after saving the environment Date: Thu, 19 Dec 2019 13:52:39 -0300 Message-Id: <20191219165239.4279-1-festevam@gmail.com> X-Mailer: git-send-email 2.17.1 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: u-boot@lists.denx.de, trini@konsulko.com Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean U-Boot binary has grown in such a way that it goes beyond the reserved area for the environment variables. Running "saveenv" followed by a "reset" causes U-Boot to hang because of this overlap. Fix this problem by increasing the CONFIG_ENV_OFFSET size. Also, in order to prevent this same problem to happen in the future, use CONFIG_BOARD_SIZE_LIMIT, which will detect the overlap in build-time. CONFIG_BOARD_SIZE_LIMIT does not accept math expressions, so declare CONFIG_ENV_OFFSET with its direct value instead. Signed-off-by: Fabio Estevam --- Tom, I cannot use the thumb trick here because of the erratum. configs/mx51evk_defconfig | 2 +- include/configs/mx51evk.h | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/configs/mx51evk_defconfig b/configs/mx51evk_defconfig index 1505459259..a2af8ae7b2 100644 --- a/configs/mx51evk_defconfig +++ b/configs/mx51evk_defconfig @@ -3,7 +3,7 @@ CONFIG_ARCH_MX5=y CONFIG_SYS_TEXT_BASE=0x97800000 CONFIG_TARGET_MX51EVK=y CONFIG_ENV_SIZE=0x2000 -CONFIG_ENV_OFFSET=0x60000 +CONFIG_ENV_OFFSET=0xC0000 CONFIG_NR_DRAM_BANKS=1 # CONFIG_CMD_BMODE is not set CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx51evk/imximage.cfg" diff --git a/include/configs/mx51evk.h b/include/configs/mx51evk.h index 71ff789381..10aa1bcd87 100644 --- a/include/configs/mx51evk.h +++ b/include/configs/mx51evk.h @@ -182,6 +182,19 @@ /*----------------------------------------------------------------------- * environment organization */ + +/* + * Environment starts at CONFIG_ENV_OFFSET=0xC0000 = 768k = 768 * 1024 = 786432 + * + * Detect overlap between U-Boot image and environment area in build-time + * + * CONFIG_BOARD_SIZE_LIMIT = CONFIG_ENV_OFFSET - u-boot.imx offset + * CONFIG_BOARD_SIZE_LIMIT = 768k - 1k = 767k = 785408 + * + * Currently CONFIG_BOARD_SIZE_LIMIT does not handle expressions, so + * write the direct value here + */ +#define CONFIG_BOARD_SIZE_LIMIT 785408 #define CONFIG_SYS_MMC_ENV_DEV 0 #endif