All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Holland <samuel@sholland.org>
To: u-boot@lists.denx.de
Subject: [PATCH] sunxi: Select environment MMC based on boot device
Date: Sun, 18 Apr 2021 22:16:21 -0500	[thread overview]
Message-ID: <20210419031621.15587-1-samuel@sholland.org> (raw)

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 <samuel@sholland.org>
---
 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
-- 
2.26.3

             reply	other threads:[~2021-04-19  3:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19  3:16 Samuel Holland [this message]
2021-04-19 15:35 ` [PATCH] sunxi: Select environment MMC based on boot device Andre Przywara
2021-04-26  8:28   ` Maxime Ripard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210419031621.15587-1-samuel@sholland.org \
    --to=samuel@sholland.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.