From patchwork Mon Apr 19 03:16:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1467761 X-Patchwork-Delegate: andre.przywara@arm.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; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm2 header.b=qPAZYU+s; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=i996G0YV; dkim-atps=neutral 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 4FNsRV24P4z9vFg for ; Mon, 19 Apr 2021 13:16:38 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5C28480C58; Mon, 19 Apr 2021 05:16:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org 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=sholland.org header.i=@sholland.org header.b="qPAZYU+s"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="i996G0YV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 32F43803AB; Mon, 19 Apr 2021 05:16:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EE14B803AB for ; Mon, 19 Apr 2021 05:16:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 0128E5C04BE; Sun, 18 Apr 2021 23:16:23 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sun, 18 Apr 2021 23:16:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=T8rhJlVcIXuvHaHfc4Wphv0kv3 NDVuEFGbKEGAJiiLo=; b=qPAZYU+shXHwjHyjM+mr5s/sZ6ynGsc9jPQgwVyJ5J mqwLDsXXypzXM9pkOmqXb77a/cwcw2vIzMtBCBQeVpBjNz+RWy5PXw+x2FzQ8oPS kw9ug1EcEVa0ep0w+cu/Yo4koyhSHsyi2pArolHa2SfASC8IQRAneLNL4BpPoARq yKxmp7MRMca7nuGcQLOIUfW7UHtjcXm+At1pTcdjk21rucvhG3j0vRZHQhgMSoHX Tgq+89HAAwxmwmLOT4/Q+oKYYX4yzvOjVXrFiU1sOmjr7VnSwtkq1uDKhbzVqKAX 9VhIEy7P1NtBc5ZtzC8ZWSj+ocSntlGcTXXRUxNxPLIg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=T8rhJlVcIXuvHaHfc 4Wphv0kv3NDVuEFGbKEGAJiiLo=; b=i996G0YV2Ckmh0k8jc12Nzp06t5ddAE4k Viq5gTxfvTacDoehk01WAYonV8ywYhp5Gp+KmuhMlFJwK2ddeUvMl9t3D7RT85UR 0n1fwnyml7+hP+ZQKkhAm8YONcP6CtH1csJkEfXcYsIZs0l7NXn5IaTT0EEcEOXV nbGpupOWYvjwxpoxTRWrhBJ+rsx1XmYlh/DBSdPjACbfIA7TcNis92tp79t+jFlu xIZx6vkGKA0hX6YkioOls3YHPl2lymvIcc7yKLTCky6qcu4ttY51r7y9rCDhEbhu W9K1xEKpV8wv7d/DvgCWjgdzjkozSbtbKgwR23DO4YmvPm4vmObpQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvddtvddguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghl ucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrf grthhtvghrnhepieetkefhheduudfgledtudefjeejfeegveehkeeufffhhfejkeehieff tdevtdevnecukfhppeejtddrudefhedrudegkedrudehudenucevlhhushhtvghrufhiii gvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgrnhgu rdhorhhg X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id E0963108005F; Sun, 18 Apr 2021 23:16:21 -0400 (EDT) From: Samuel Holland To: Jagan Teki , Andre Przywara , Hans de Goede Cc: Joe Hershberger , Wolfgang Denk , u-boot@lists.denx.de, Samuel Holland Subject: [PATCH] sunxi: Select environment MMC based on boot device Date: Sun, 18 Apr 2021 22:16:21 -0500 Message-Id: <20210419031621.15587-1-samuel@sholland.org> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean Currently, the environment is always stored in eMMC if eMMC is enabled in the config. This means images written to SD and eMMC will cross- contaminate their environments unless the configuration is changed. By dropping the device number from the environment location string and implementing mmc_get_env_dev, we will always use the environment from the boot device when booting from SD/eMMC. Signed-off-by: Samuel Holland --- board/sunxi/board.c | 14 ++++++++++++++ env/Kconfig | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 718bc313ae..59f7c2c5f1 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -624,6 +624,20 @@ int board_mmc_init(struct bd_info *bis) return 0; } + +#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1 +int mmc_get_env_dev(void) +{ + switch (sunxi_get_boot_device()) { + case BOOT_DEVICE_MMC1: + return 0; + case BOOT_DEVICE_MMC2: + return 1; + default: + return CONFIG_SYS_MMC_ENV_DEV; + } +} +#endif #endif #ifdef CONFIG_SPL_BUILD diff --git a/env/Kconfig b/env/Kconfig index b473d7cfe1..d7c787ad84 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -430,10 +430,9 @@ config ENV_FAT_INTERFACE config ENV_FAT_DEVICE_AND_PART string "Device and partition for where to store the environemt in FAT" depends on ENV_IS_IN_FAT + default ":auto" if ARCH_SUNXI default "0:1" if TI_COMMON_CMD_OPTIONS default "0:auto" if ARCH_ZYNQ || ARCH_ZYNQMP - default "0:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1 - default "1:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1 default "0" if ARCH_AT91 help Define this to a string to specify the partition of the device. It can