[U-Boot] [PATCH 3/5] env: allow runtime determination of FAT environment partition
Andre Przywara
andre.przywara at arm.com
Sat Jun 8 01:26:56 UTC 2019
Currently the FAT device and partition which contains the environment
must be configured at compile time. This creates problems for boards
which have multiple bootable devices (like SD card and eMMC).
Similar to what we do for raw MMC environments, introduce a weak function
to allow boards to override this static configuration. Right now we just
return the Kconfig variable.
Signed-off-by: Andre Przywara <andre.przywara at arm.com>
---
env/fat.c | 13 +++++++++----
include/environment.h | 4 ++++
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/env/fat.c b/env/fat.c
index 7f74c64dfe..320f73b6d3 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -30,6 +30,11 @@
# endif
#endif
+__weak char *fat_get_env_dev_part(void)
+{
+ return CONFIG_ENV_FAT_DEVICE_AND_PART;
+}
+
#ifdef CMD_SAVEENV
static int env_fat_save(void)
{
@@ -45,8 +50,8 @@ static int env_fat_save(void)
return err;
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
- CONFIG_ENV_FAT_DEVICE_AND_PART,
- &dev_desc, &info, 1);
+ fat_get_env_dev_part(),
+ &dev_desc, &info, 1);
if (part < 0)
return 1;
@@ -92,8 +97,8 @@ static int env_fat_load(void)
#endif
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
- CONFIG_ENV_FAT_DEVICE_AND_PART,
- &dev_desc, &info, 1);
+ fat_get_env_dev_part(),
+ &dev_desc, &info, 1);
if (part < 0)
goto err_env_relocate;
diff --git a/include/environment.h b/include/environment.h
index cd96676141..364adc76ba 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -65,6 +65,10 @@
# endif
#endif
+#if defined(CONFIG_ENV_IS_IN_FAT)
+char *fat_get_env_dev_part(void);
+#endif
+
#if defined(CONFIG_ENV_IS_IN_NAND)
# if defined(CONFIG_ENV_OFFSET_OOB)
# ifdef CONFIG_ENV_OFFSET_REDUND
--
2.14.5
More information about the U-Boot
mailing list