mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-17 12:41:32 +00:00
env/fat.c: allow loading from a FAT partition on the MMC boot device
I don't want to have to specify the device; only the partition. This allows me to use the same image on internal eMMC or SD card for Banana Pi R2, and it finds its own environment either way. Signed-off-by: David Woodhouse <dwmw2@infradead.org> [trini: Add #if/#else/#endif logic around CONFIG_SYS_MMC_ENV_DEV usage, whitespace changes] Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
ada61f1ee2
commit
6731bef696
2 changed files with 34 additions and 2 deletions
4
env/Kconfig
vendored
4
env/Kconfig
vendored
|
@ -434,6 +434,10 @@ config ENV_FAT_DEVICE_AND_PART
|
||||||
If none, first valid partition in device D. If no
|
If none, first valid partition in device D. If no
|
||||||
partition table then means device D.
|
partition table then means device D.
|
||||||
|
|
||||||
|
If ENV_FAT_INTERFACE is set to "mmc" then device 'D' can be omitted,
|
||||||
|
leaving the string starting with a colon, and the boot device will
|
||||||
|
be used.
|
||||||
|
|
||||||
config ENV_FAT_FILE
|
config ENV_FAT_FILE
|
||||||
string "Name of the FAT file to use for the environment"
|
string "Name of the FAT file to use for the environment"
|
||||||
depends on ENV_IS_IN_FAT
|
depends on ENV_IS_IN_FAT
|
||||||
|
|
32
env/fat.c
vendored
32
env/fat.c
vendored
|
@ -29,6 +29,34 @@
|
||||||
# define LOADENV
|
# define LOADENV
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
__weak int mmc_get_env_dev(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_SYS_MMC_ENV_DEV
|
||||||
|
return CONFIG_SYS_MMC_ENV_DEV;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *env_fat_device_and_part(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_MMC
|
||||||
|
static char *part_str;
|
||||||
|
|
||||||
|
if (!part_str) {
|
||||||
|
part_str = CONFIG_ENV_FAT_DEVICE_AND_PART;
|
||||||
|
if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc") && part_str[0] == ':') {
|
||||||
|
part_str = "0" CONFIG_ENV_FAT_DEVICE_AND_PART;
|
||||||
|
part_str[0] += mmc_get_env_dev();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return part_str;
|
||||||
|
#else
|
||||||
|
return CONFIG_ENV_FAT_DEVICE_AND_PART;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static int env_fat_save(void)
|
static int env_fat_save(void)
|
||||||
{
|
{
|
||||||
env_t __aligned(ARCH_DMA_MINALIGN) env_new;
|
env_t __aligned(ARCH_DMA_MINALIGN) env_new;
|
||||||
|
@ -43,7 +71,7 @@ static int env_fat_save(void)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
|
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
|
||||||
CONFIG_ENV_FAT_DEVICE_AND_PART,
|
env_fat_device_and_part(),
|
||||||
&dev_desc, &info, 1);
|
&dev_desc, &info, 1);
|
||||||
if (part < 0)
|
if (part < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -89,7 +117,7 @@ static int env_fat_load(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
|
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
|
||||||
CONFIG_ENV_FAT_DEVICE_AND_PART,
|
env_fat_device_and_part(),
|
||||||
&dev_desc, &info, 1);
|
&dev_desc, &info, 1);
|
||||||
if (part < 0)
|
if (part < 0)
|
||||||
goto err_env_relocate;
|
goto err_env_relocate;
|
||||||
|
|
Loading…
Add table
Reference in a new issue