mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 03:15:00 +00:00
env: fat: Allow overriding interface, device and partition
For platform which can boot on different device, this allows to override interface, device and partition from board code Signed-off-by: He Yong <hyyoxhk@163.com>
This commit is contained in:
parent
ec57bd7454
commit
eb68ead2d3
2 changed files with 39 additions and 15 deletions
34
env/fat.c
vendored
34
env/fat.c
vendored
|
@ -32,7 +32,12 @@
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
static char *env_fat_device_and_part(void)
|
__weak const char *env_fat_get_intf(void)
|
||||||
|
{
|
||||||
|
return (const char *)CONFIG_ENV_FAT_INTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
__weak char *env_fat_get_dev_part(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MMC
|
#ifdef CONFIG_MMC
|
||||||
static char *part_str;
|
static char *part_str;
|
||||||
|
@ -60,14 +65,15 @@ static int env_fat_save(void)
|
||||||
int dev, part;
|
int dev, part;
|
||||||
int err;
|
int err;
|
||||||
loff_t size;
|
loff_t size;
|
||||||
|
const char *ifname = env_fat_get_intf();
|
||||||
|
const char *dev_and_part = env_fat_get_dev_part();
|
||||||
|
|
||||||
err = env_export(&env_new);
|
err = env_export(&env_new);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
|
part = blk_get_device_part_str(ifname, dev_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;
|
||||||
|
|
||||||
|
@ -77,8 +83,7 @@ static int env_fat_save(void)
|
||||||
* This printf is embedded in the messages from env_save that
|
* This printf is embedded in the messages from env_save that
|
||||||
* will calling it. The missing \n is intentional.
|
* will calling it. The missing \n is intentional.
|
||||||
*/
|
*/
|
||||||
printf("Unable to use %s %d:%d... \n",
|
printf("Unable to use %s %d:%d...\n", ifname, dev, part);
|
||||||
CONFIG_ENV_FAT_INTERFACE, dev, part);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +98,7 @@ static int env_fat_save(void)
|
||||||
* This printf is embedded in the messages from env_save that
|
* This printf is embedded in the messages from env_save that
|
||||||
* will calling it. The missing \n is intentional.
|
* will calling it. The missing \n is intentional.
|
||||||
*/
|
*/
|
||||||
printf("Unable to write \"%s\" from %s%d:%d... \n",
|
printf("Unable to write \"%s\" from %s%d:%d...\n", file, ifname, dev, part);
|
||||||
file, CONFIG_ENV_FAT_INTERFACE, dev, part);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,15 +121,16 @@ static int env_fat_load(void)
|
||||||
struct disk_partition info;
|
struct disk_partition info;
|
||||||
int dev, part;
|
int dev, part;
|
||||||
int err1;
|
int err1;
|
||||||
|
const char *ifname = env_fat_get_intf();
|
||||||
|
const char *dev_and_part = env_fat_get_dev_part();
|
||||||
|
|
||||||
#ifdef CONFIG_MMC
|
#ifdef CONFIG_MMC
|
||||||
if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc"))
|
if (!strcmp(ifname, "mmc"))
|
||||||
mmc_initialize(NULL);
|
mmc_initialize(NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
|
part = blk_get_device_part_str(ifname, dev_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;
|
||||||
|
|
||||||
|
@ -135,8 +140,7 @@ static int env_fat_load(void)
|
||||||
* This printf is embedded in the messages from env_save that
|
* This printf is embedded in the messages from env_save that
|
||||||
* will calling it. The missing \n is intentional.
|
* will calling it. The missing \n is intentional.
|
||||||
*/
|
*/
|
||||||
printf("Unable to use %s %d:%d... \n",
|
printf("Unable to use %s %d:%d...\n", ifname, dev, part);
|
||||||
CONFIG_ENV_FAT_INTERFACE, dev, part);
|
|
||||||
goto err_env_relocate;
|
goto err_env_relocate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +158,7 @@ static int env_fat_load(void)
|
||||||
* will calling it. The missing \n is intentional.
|
* will calling it. The missing \n is intentional.
|
||||||
*/
|
*/
|
||||||
printf("Unable to read \"%s\" from %s%d:%d... \n",
|
printf("Unable to read \"%s\" from %s%d:%d... \n",
|
||||||
CONFIG_ENV_FAT_FILE, CONFIG_ENV_FAT_INTERFACE, dev, part);
|
CONFIG_ENV_FAT_FILE, ifname, dev, part);
|
||||||
goto err_env_relocate;
|
goto err_env_relocate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,6 +245,26 @@ const char *env_ext4_get_dev_part(void);
|
||||||
* Return: an enum env_location value on success, or -ve error code.
|
* Return: an enum env_location value on success, or -ve error code.
|
||||||
*/
|
*/
|
||||||
enum env_location env_get_location(enum env_operation op, int prio);
|
enum env_location env_get_location(enum env_operation op, int prio);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* env_fat_get_intf() - Provide the interface for env in FAT
|
||||||
|
*
|
||||||
|
* It is a weak function allowing board to overidde the default interface for
|
||||||
|
* U-Boot env in FAT: CONFIG_ENV_FAT_INTERFACE
|
||||||
|
*
|
||||||
|
* Return: string of interface, empty if not supported
|
||||||
|
*/
|
||||||
|
const char *env_fat_get_intf(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* env_fat_get_dev_part() - Provide the device and partition for env in FAT
|
||||||
|
*
|
||||||
|
* It is a weak function allowing board to overidde the default device and
|
||||||
|
* partition used for U-Boot env in FAT: CONFIG_ENV_FAT_DEVICE_AND_PART
|
||||||
|
*
|
||||||
|
* Return: string of device and partition
|
||||||
|
*/
|
||||||
|
char *env_fat_get_dev_part(void);
|
||||||
#endif /* DO_DEPS_ONLY */
|
#endif /* DO_DEPS_ONLY */
|
||||||
|
|
||||||
#endif /* _ENV_INTERNAL_H_ */
|
#endif /* _ENV_INTERNAL_H_ */
|
||||||
|
|
Loading…
Add table
Reference in a new issue