1 From fb2810b2c7209d4ed690e48e5bffa52d1af2eda3 Mon Sep 17 00:00:00 2001
2 From: David Woodhouse <dwmw2@infradead.org>
3 Date: Fri, 19 Jun 2020 22:57:04 +0100
4 Subject: [PATCH] env/fat.c: allow loading from a FAT partition on the MMC boot
7 I don't want to have to specify the device; only the partition.
9 Signed-off-by: David Woodhouse <dwmw2@infradead.org>
12 env/fat.c | 31 +++++++++++++++++++++++++++++--
13 2 files changed, 33 insertions(+), 2 deletions(-)
15 diff --git a/env/Kconfig b/env/Kconfig
16 index 0d6f559b39..a2020a8661 100644
19 @@ -432,6 +432,10 @@ config ENV_FAT_DEVICE_AND_PART
20 If none, first valid partition in device D. If no
21 partition table then means device D.
23 + If ENV_FAT_INTERFACE is set to "mmc" then device 'D' can be omitted,
24 + leaving the string starting with a colon, and the boot device will
28 string "Name of the FAT file to use for the environment"
29 depends on ENV_IS_IN_FAT
30 diff --git a/env/fat.c b/env/fat.c
31 index 1836556f36..1c32d17bd5 100644
38 +#if defined(CMD_SAVEENV) || defined(CMD_LOADENV)
39 +__weak int mmc_get_env_dev(void)
41 + return CONFIG_SYS_MMC_ENV_DEV;
44 +static char *env_fat_device_and_part(void)
47 + static char *part_str;
50 + part_str = CONFIG_ENV_FAT_DEVICE_AND_PART;
51 + if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc")
52 + && part_str[0] == ':') {
53 + part_str = "0" CONFIG_ENV_FAT_DEVICE_AND_PART;
54 + part_str[0] += mmc_get_env_dev();
60 + return CONFIG_ENV_FAT_DEVICE_AND_PART;
66 static int env_fat_save(void)
68 @@ -46,7 +73,7 @@ static int env_fat_save(void)
71 part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
72 - CONFIG_ENV_FAT_DEVICE_AND_PART,
73 + env_fat_device_and_part(),
77 @@ -93,7 +120,7 @@ static int env_fat_load(void)
80 part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
81 - CONFIG_ENV_FAT_DEVICE_AND_PART,
82 + env_fat_device_and_part(),
85 goto err_env_relocate;