* [PATCH v1 1/1] env: fat: Allow overriding interface, device and partition
@ 2021-12-30 14:50 hyyxohk
2022-01-27 15:05 ` Simon Glass
0 siblings, 1 reply; 5+ messages in thread
From: hyyxohk @ 2021-12-30 14:50 UTC (permalink / raw)
To: u-boot, joe.hershberger; +Cc: wd
For platform which can boot on different device, this allows
to override interface, device and partition from board code.
Signed-off-by: hyyxohk <hyyoxhk@163.com>
---
env/fat.c | 30 +++++++++++++++++-------------
include/env_internal.h | 20 ++++++++++++++++++++
2 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/env/fat.c b/env/fat.c
index 9d37d26f9e..fdd875034b 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -32,7 +32,12 @@
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
static char *part_str;
@@ -60,13 +65,14 @@ static int env_fat_save(void)
int dev, part;
int err;
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);
if (err)
return err;
- part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
- env_fat_device_and_part(),
+ part = blk_get_device_part_str(ifname, dev_and_part,
&dev_desc, &info, 1);
if (part < 0)
return 1;
@@ -77,8 +83,7 @@ static int env_fat_save(void)
* This printf is embedded in the messages from env_save that
* will calling it. The missing \n is intentional.
*/
- printf("Unable to use %s %d:%d... ",
- CONFIG_ENV_FAT_INTERFACE, dev, part);
+ printf("Unable to use %s %d:%d... ", ifname, dev, part);
return 1;
}
@@ -93,8 +98,7 @@ static int env_fat_save(void)
* This printf is embedded in the messages from env_save that
* will calling it. The missing \n is intentional.
*/
- printf("Unable to write \"%s\" from %s%d:%d... ",
- file, CONFIG_ENV_FAT_INTERFACE, dev, part);
+ printf("Unable to write \"%s\" from %s%d:%d... ", file, ifname, dev, part);
return 1;
}
@@ -117,14 +121,15 @@ static int env_fat_load(void)
struct disk_partition info;
int dev, part;
int err1;
+ const char *ifname = env_fat_get_intf();
+ const char *dev_and_part = env_fat_get_dev_part();
#ifdef CONFIG_MMC
- if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc"))
+ if (!strcmp(ifname, "mmc"))
mmc_initialize(NULL);
#endif
- part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
- env_fat_device_and_part(),
+ part = blk_get_device_part_str(ifname, dev_and_part,
&dev_desc, &info, 1);
if (part < 0)
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
* will calling it. The missing \n is intentional.
*/
- printf("Unable to use %s %d:%d... ",
- CONFIG_ENV_FAT_INTERFACE, dev, part);
+ printf("Unable to use %s %d:%d... ", ifname, dev, part);
goto err_env_relocate;
}
@@ -154,7 +158,7 @@ static int env_fat_load(void)
* will calling it. The missing \n is intentional.
*/
printf("Unable to read \"%s\" from %s%d:%d... ",
- CONFIG_ENV_FAT_FILE, CONFIG_ENV_FAT_INTERFACE, dev, part);
+ CONFIG_ENV_FAT_FILE, ifname, dev, part);
goto err_env_relocate;
}
diff --git a/include/env_internal.h b/include/env_internal.h
index 174c3b1a79..e42ae826ef 100644
--- a/include/env_internal.h
+++ b/include/env_internal.h
@@ -245,6 +245,26 @@ const char *env_ext4_get_dev_part(void);
* @return an enum env_location value on success, or -ve error code.
*/
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 /* _ENV_INTERNAL_H_ */
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] env: fat: Allow overriding interface, device and partition
2021-12-30 14:50 [PATCH v1 1/1] env: fat: Allow overriding interface, device and partition hyyxohk
@ 2022-01-27 15:05 ` Simon Glass
2022-01-29 8:26 ` 何勇
0 siblings, 1 reply; 5+ messages in thread
From: Simon Glass @ 2022-01-27 15:05 UTC (permalink / raw)
To: hyyxohk; +Cc: U-Boot Mailing List, Joe Hershberger, Wolfgang Denk
Hi,
On Thu, 30 Dec 2021 at 07:50, hyyxohk <hyyoxhk@163.com> wrote:
>
> For platform which can boot on different device, this allows
> to override interface, device and partition from board code.
>
> Signed-off-by: hyyxohk <hyyoxhk@163.com>
> ---
> env/fat.c | 30 +++++++++++++++++-------------
> include/env_internal.h | 20 ++++++++++++++++++++
> 2 files changed, 37 insertions(+), 13 deletions(-)
>
What is this feature used for?
Regards,
Simon
[..]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re:Re: [PATCH v1 1/1] env: fat: Allow overriding interface, device and partition
2022-01-27 15:05 ` Simon Glass
@ 2022-01-29 8:26 ` 何勇
2022-02-11 15:05 ` Simon Glass
0 siblings, 1 reply; 5+ messages in thread
From: 何勇 @ 2022-01-29 8:26 UTC (permalink / raw)
To: Simon Glass; +Cc: U-Boot Mailing List, Joe Hershberger, Wolfgang Denk
Hi:
Override the env_fat_get_dev_part function in the board file, you can
load env from sdcard or emmc without modifying any configuration
of u-boot, it is very useful for building wic firmware by yocto.
it has been done under env/ext4.c
At 2022-01-27 23:05:57, "Simon Glass" <sjg@chromium.org> wrote:
>Hi,
>
>On Thu, 30 Dec 2021 at 07:50, hyyxohk <hyyoxhk@163.com> wrote:
>>
>> For platform which can boot on different device, this allows
>> to override interface, device and partition from board code.
>>
>> Signed-off-by: hyyxohk <hyyoxhk@163.com>
>> ---
>> env/fat.c | 30 +++++++++++++++++-------------
>> include/env_internal.h | 20 ++++++++++++++++++++
>> 2 files changed, 37 insertions(+), 13 deletions(-)
>>
>
>What is this feature used for?
>
>Regards,
>Simon
>[..]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH v1 1/1] env: fat: Allow overriding interface, device and partition
2022-01-29 8:26 ` 何勇
@ 2022-02-11 15:05 ` Simon Glass
2022-02-17 15:16 ` hyyoxhk
0 siblings, 1 reply; 5+ messages in thread
From: Simon Glass @ 2022-02-11 15:05 UTC (permalink / raw)
To: 何勇; +Cc: U-Boot Mailing List, Joe Hershberger, Wolfgang Denk
Hi,
On Sat, 29 Jan 2022 at 01:26, 何勇 <hyyoxhk@163.com> wrote:
>
> Hi:
> Override the env_fat_get_dev_part function in the board file, you can
> load env from sdcard or emmc without modifying any configuration
> of u-boot, it is very useful for building wic firmware by yocto.
>
> it has been done under env/ext4.c
I cannot see it. Can you please point me to the line number in that file?
Do you have an English-text name you could use for the patch?
Regards,
Simon
>
>
>
>
>
>
>
> At 2022-01-27 23:05:57, "Simon Glass" <sjg@chromium.org> wrote:
> >Hi,
> >
> >On Thu, 30 Dec 2021 at 07:50, hyyxohk <hyyoxhk@163.com> wrote:
> >>
> >> For platform which can boot on different device, this allows
> >> to override interface, device and partition from board code.
> >>
> >> Signed-off-by: hyyxohk <hyyoxhk@163.com>
> >> ---
> >> env/fat.c | 30 +++++++++++++++++-------------
> >> include/env_internal.h | 20 ++++++++++++++++++++
> >> 2 files changed, 37 insertions(+), 13 deletions(-)
> >>
> >
> >What is this feature used for?
> >
> >Regards,
> >Simon
> >[..]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re:Re: Re: [PATCH v1 1/1] env: fat: Allow overriding interface, device and partition
2022-02-11 15:05 ` Simon Glass
@ 2022-02-17 15:16 ` hyyoxhk
0 siblings, 0 replies; 5+ messages in thread
From: hyyoxhk @ 2022-02-17 15:16 UTC (permalink / raw)
To: Simon Glass; +Cc: U-Boot Mailing List, Joe Hershberger, Wolfgang Denk
sorry i just saw the email
I have reworked the patch for v3 based on u-boot mainline
At 2022-02-11 23:05:47, "Simon Glass" <sjg@chromium.org> wrote:
>Hi,
>
>On Sat, 29 Jan 2022 at 01:26, 何勇 <hyyoxhk@163.com> wrote:
>>
>> Hi:
>> Override the env_fat_get_dev_part function in the board file, you can
>> load env from sdcard or emmc without modifying any configuration
>> of u-boot, it is very useful for building wic firmware by yocto.
>>
>> it has been done under env/ext4.c
>
>I cannot see it. Can you please point me to the line number in that file?
>
>Do you have an English-text name you could use for the patch?
>
>Regards,
>Simon
>
>
>>
>>
>>
>>
>>
>>
>>
>> At 2022-01-27 23:05:57, "Simon Glass" <sjg@chromium.org> wrote:
>> >Hi,
>> >
>> >On Thu, 30 Dec 2021 at 07:50, hyyxohk <hyyoxhk@163.com> wrote:
>> >>
>> >> For platform which can boot on different device, this allows
>> >> to override interface, device and partition from board code.
>> >>
>> >> Signed-off-by: hyyxohk <hyyoxhk@163.com>
>> >> ---
>> >> env/fat.c | 30 +++++++++++++++++-------------
>> >> include/env_internal.h | 20 ++++++++++++++++++++
>> >> 2 files changed, 37 insertions(+), 13 deletions(-)
>> >>
>> >
>> >What is this feature used for?
>> >
>> >Regards,
>> >Simon
>> >[..]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-17 15:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-30 14:50 [PATCH v1 1/1] env: fat: Allow overriding interface, device and partition hyyxohk
2022-01-27 15:05 ` Simon Glass
2022-01-29 8:26 ` 何勇
2022-02-11 15:05 ` Simon Glass
2022-02-17 15:16 ` hyyoxhk
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.