* [Buildroot] [PATCH] uboot: allow taking the entire default environment from a text file
@ 2024-06-17 16:00 Luca Ceresoli via buildroot
2024-06-28 13:20 ` Kory Maincent via buildroot
2024-07-12 9:23 ` Arnout Vandecappelle via buildroot
0 siblings, 2 replies; 6+ messages in thread
From: Luca Ceresoli via buildroot @ 2024-06-17 16:00 UTC (permalink / raw)
To: buildroot; +Cc: Köry Maincent, Luca Ceresoli, Thomas Petazzoni
By default U-Boot builds a default environment from its own configuration
and a board-specific set of variables. However it also allows to bypass
this entirely and define the entire default environment from a text file.
Expose this feature to Buildroot. This allows to have a file e.g. in
board/.../uboot.env which contains an easy to maintain text file with the
wanted default environment, without patching the U-Boot source code.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
boot/uboot/Config.in | 29 +++++++++++++++++++++++++++++
boot/uboot/uboot.mk | 9 +++++++++
2 files changed, 38 insertions(+)
diff --git a/boot/uboot/Config.in b/boot/uboot/Config.in
index f37040a28a97..a3bf3e009c52 100644
--- a/boot/uboot/Config.in
+++ b/boot/uboot/Config.in
@@ -136,6 +136,35 @@ config BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES
that will be merged to the main U-Boot configuration file.
endif
+config BR2_TARGET_UBOOT_USE_DEFAULT_ENV_FILE
+ bool "Generate default environment from text file"
+ select BR2_TARGET_UBOOT_NEEDS_XXD
+ help
+ Define the entire U-Boot default environment from a file,
+ disabling all the logic to generate it from the U-Boot source
+ code and other configuration values.
+
+ Based on the USE_DEFAULT_ENV_FILE and DEFAULT_ENV_FILE U-Boot
+ configuration variables.
+
+ Requires U-Boot >= v2018.05.
+
+config BR2_TARGET_UBOOT_DEFAULT_ENV_FILE
+ string "Text file with default environment"
+ depends on BR2_TARGET_UBOOT_USE_DEFAULT_ENV_FILE
+ help
+ Text file containing the variables to be used as the default
+ environment in U-Boot.
+
+ From the U-Boot documentation:
+
+ The format is the same as accepted by the mkenvimage tool, with
+ lines containing key=value pairs. Blank lines and lines
+ beginning with '#' are ignored.
+
+ For more info see:
+ https://docs.u-boot.org/en/latest/usage/environment.html#external-environment-file
+
config BR2_TARGET_UBOOT_NEEDS_DTC
bool "U-Boot needs dtc"
select BR2_PACKAGE_HOST_DTC
diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
index 19f4cdb557e6..3b3d3a13e711 100644
--- a/boot/uboot/uboot.mk
+++ b/boot/uboot/uboot.mk
@@ -390,6 +390,14 @@ UBOOT_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
# override again. In addition, host-ccache is not ready at kconfig
# time, so use HOSTCC_NOCCACHE.
UBOOT_KCONFIG_OPTS = $(UBOOT_MAKE_OPTS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTLDFLAGS=""
+
+ifeq ($(BR2_TARGET_UBOOT_USE_DEFAULT_ENV_FILE),y)
+UBOOT_DEFAULT_ENV_FILE = $(call qstrip,$(BR2_TARGET_UBOOT_DEFAULT_ENV_FILE))
+define UBOOT_KCONFIG_DEFAULT_ENV_FILE
+ $(call KCONFIG_SET_OPT,CONFIG_USE_DEFAULT_ENV_FILE,y)
+ $(call KCONFIG_SET_OPT,CONFIG_DEFAULT_ENV_FILE,"$(shell readlink -f $(UBOOT_DEFAULT_ENV_FILE))")
+endef
+endif
endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
UBOOT_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_DTS_PATH))
@@ -530,6 +538,7 @@ define UBOOT_KCONFIG_FIXUP_CMDS
$(UBOOT_ZYNQMP_KCONFIG_PMUFW)
$(UBOOT_ZYNQMP_KCONFIG_PM_CFG)
$(UBOOT_ZYNQMP_KCONFIG_PSU_INIT)
+ $(UBOOT_KCONFIG_DEFAULT_ENV_FILE)
endef
ifeq ($(BR2_TARGET_UBOOT)$(BR_BUILDING),yy)
---
base-commit: 7bfea9372f1842279a8f57b5fc4428bbae822e91
change-id: 20240617-uboot-default-env-46688521fbae
Best regards,
--
Luca Ceresoli <luca.ceresoli@bootlin.com>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] uboot: allow taking the entire default environment from a text file
2024-06-17 16:00 [Buildroot] [PATCH] uboot: allow taking the entire default environment from a text file Luca Ceresoli via buildroot
@ 2024-06-28 13:20 ` Kory Maincent via buildroot
2024-07-12 9:23 ` Arnout Vandecappelle via buildroot
1 sibling, 0 replies; 6+ messages in thread
From: Kory Maincent via buildroot @ 2024-06-28 13:20 UTC (permalink / raw)
To: Luca Ceresoli; +Cc: Thomas Petazzoni, buildroot
Hello Luca,
On Mon, 17 Jun 2024 18:00:50 +0200
Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
> By default U-Boot builds a default environment from its own configuration
> and a board-specific set of variables. However it also allows to bypass
> this entirely and define the entire default environment from a text file.
>
> Expose this feature to Buildroot. This allows to have a file e.g. in
> board/.../uboot.env which contains an easy to maintain text file with the
> wanted default environment, without patching the U-Boot source code.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> boot/uboot/Config.in | 29 +++++++++++++++++++++++++++++
> boot/uboot/uboot.mk | 9 +++++++++
> 2 files changed, 38 insertions(+)
>
> diff --git a/boot/uboot/Config.in b/boot/uboot/Config.in
> index f37040a28a97..a3bf3e009c52 100644
> --- a/boot/uboot/Config.in
> +++ b/boot/uboot/Config.in
> @@ -136,6 +136,35 @@ config BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES
> that will be merged to the main U-Boot configuration file.
> endif
>
> +config BR2_TARGET_UBOOT_USE_DEFAULT_ENV_FILE
> + bool "Generate default environment from text file"
> + select BR2_TARGET_UBOOT_NEEDS_XXD
> + help
> + Define the entire U-Boot default environmen/*t from a file,
> + disabling all the logic to generate it from the U-Boot source
> + code and other configuration values.
> +
> + Based on the USE_DEFAULT_ENV_FILE and DEFAULT_ENV_FILE U-Boot
> + configuration variables.
> +
> + Requires U-Boot >= v2018.05.
> +
> +config BR2_TARGET_UBOOT_DEFAULT_ENV_FILE
> + string "Text file with default environment"
> + depends on BR2_TARGET_UBOOT_USE_DEFAULT_ENV_FILE
> + help
> + Text file containing the variables to be used as the default
> + environment in U-Boot.
> +
> + From the U-Boot documentation:
> +
> + The format is the same as accepted by the mkenvimage tool, with
Line exceed 62 characters.
Please use check-package tool:
./utils/check-package boot/uboot/*
boot/uboot/Config.in:161: help text: <tab><2 spaces><62 chars>
(https://nightly.buildroot.org/#writing-rules-config-in)
Except for that fix:
Acked-by: Kory Maincent <Kory.maincent@bootlin.com>
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] uboot: allow taking the entire default environment from a text file
2024-06-17 16:00 [Buildroot] [PATCH] uboot: allow taking the entire default environment from a text file Luca Ceresoli via buildroot
2024-06-28 13:20 ` Kory Maincent via buildroot
@ 2024-07-12 9:23 ` Arnout Vandecappelle via buildroot
2024-07-15 13:51 ` Luca Ceresoli via buildroot
1 sibling, 1 reply; 6+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2024-07-12 9:23 UTC (permalink / raw)
To: Luca Ceresoli, buildroot
Cc: Köry Maincent, Heiko Thiery, Thomas Petazzoni
Hi Luca,
On 17/06/2024 18:00, Luca Ceresoli via buildroot wrote:
> By default U-Boot builds a default environment from its own configuration
> and a board-specific set of variables. However it also allows to bypass
> this entirely and define the entire default environment from a text file.
>
> Expose this feature to Buildroot. This allows to have a file e.g. in
> board/.../uboot.env which contains an easy to maintain text file with the
> wanted default environment, without patching the U-Boot source code.
Earlier, Heiko sent a similar patch but using a different U-Boot config option
[1]. We're going to merge only one of them :-)
This one is a bit more elegant I think because it doesn't require discovering
the vendor directory.
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> boot/uboot/Config.in | 29 +++++++++++++++++++++++++++++
> boot/uboot/uboot.mk | 9 +++++++++
> 2 files changed, 38 insertions(+)
>
> diff --git a/boot/uboot/Config.in b/boot/uboot/Config.in
> index f37040a28a97..a3bf3e009c52 100644
> --- a/boot/uboot/Config.in
> +++ b/boot/uboot/Config.in
> @@ -136,6 +136,35 @@ config BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES
> that will be merged to the main U-Boot configuration file.
> endif
>
> +config BR2_TARGET_UBOOT_USE_DEFAULT_ENV_FILE
> + bool "Generate default environment from text file"
I think that rather than two options, we want just one string option. If it's
empty, it is disabled.
> + select BR2_TARGET_UBOOT_NEEDS_XXD
> + help
> + Define the entire U-Boot default environment from a file,
> + disabling all the logic to generate it from the U-Boot source
> + code and other configuration values.
> +
> + Based on the USE_DEFAULT_ENV_FILE and DEFAULT_ENV_FILE U-Boot
> + configuration variables.
> +
> + Requires U-Boot >= v2018.05.
> +
> +config BR2_TARGET_UBOOT_DEFAULT_ENV_FILE
> + string "Text file with default environment"
> + depends on BR2_TARGET_UBOOT_USE_DEFAULT_ENV_FILE
> + help
> + Text file containing the variables to be used as the default
> + environment in U-Boot.
> +
> + From the U-Boot documentation:
> +
> + The format is the same as accepted by the mkenvimage tool, with
> + lines containing key=value pairs. Blank lines and lines
> + beginning with '#' are ignored.
> +
> + For more info see:
> + https://docs.u-boot.org/en/latest/usage/environment.html#external-environment-file
Excellent help text!
> +
> config BR2_TARGET_UBOOT_NEEDS_DTC
> bool "U-Boot needs dtc"
> select BR2_PACKAGE_HOST_DTC
> diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
> index 19f4cdb557e6..3b3d3a13e711 100644
> --- a/boot/uboot/uboot.mk
> +++ b/boot/uboot/uboot.mk
> @@ -390,6 +390,14 @@ UBOOT_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
> # override again. In addition, host-ccache is not ready at kconfig
> # time, so use HOSTCC_NOCCACHE.
> UBOOT_KCONFIG_OPTS = $(UBOOT_MAKE_OPTS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTLDFLAGS=""
> +
> +ifeq ($(BR2_TARGET_UBOOT_USE_DEFAULT_ENV_FILE),y)
> +UBOOT_DEFAULT_ENV_FILE = $(call qstrip,$(BR2_TARGET_UBOOT_DEFAULT_ENV_FILE))
> +define UBOOT_KCONFIG_DEFAULT_ENV_FILE
> + $(call KCONFIG_SET_OPT,CONFIG_USE_DEFAULT_ENV_FILE,y)
> + $(call KCONFIG_SET_OPT,CONFIG_DEFAULT_ENV_FILE,"$(shell readlink -f $(UBOOT_DEFAULT_ENV_FILE))")
I think we mostly use `` rather than $(shell ...) - with the backticks, it's
much easier to understand when it's going to be evaluated.
Regards,
Arnout
[1]
https://patchwork.ozlabs.org/project/buildroot/patch/20240617-uboot-default-env-v1-1-9ac88f0e1789@bootlin.com/
> +endef
> +endif
> endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
>
> UBOOT_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_DTS_PATH))
> @@ -530,6 +538,7 @@ define UBOOT_KCONFIG_FIXUP_CMDS
> $(UBOOT_ZYNQMP_KCONFIG_PMUFW)
> $(UBOOT_ZYNQMP_KCONFIG_PM_CFG)
> $(UBOOT_ZYNQMP_KCONFIG_PSU_INIT)
> + $(UBOOT_KCONFIG_DEFAULT_ENV_FILE)
> endef
>
> ifeq ($(BR2_TARGET_UBOOT)$(BR_BUILDING),yy)
>
> ---
> base-commit: 7bfea9372f1842279a8f57b5fc4428bbae822e91
> change-id: 20240617-uboot-default-env-46688521fbae
>
> Best regards,
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] uboot: allow taking the entire default environment from a text file
2024-07-12 9:23 ` Arnout Vandecappelle via buildroot
@ 2024-07-15 13:51 ` Luca Ceresoli via buildroot
2024-07-15 14:49 ` Arnout Vandecappelle via buildroot
0 siblings, 1 reply; 6+ messages in thread
From: Luca Ceresoli via buildroot @ 2024-07-15 13:51 UTC (permalink / raw)
To: Arnout Vandecappelle
Cc: Köry Maincent, Heiko Thiery, Thomas Petazzoni, buildroot
Hi Arnout,
On Fri, 12 Jul 2024 11:23:12 +0200
Arnout Vandecappelle <arnout@mind.be> wrote:
> Hi Luca,
>
> On 17/06/2024 18:00, Luca Ceresoli via buildroot wrote:
> > By default U-Boot builds a default environment from its own configuration
> > and a board-specific set of variables. However it also allows to bypass
> > this entirely and define the entire default environment from a text file.
> >
> > Expose this feature to Buildroot. This allows to have a file e.g. in
> > board/.../uboot.env which contains an easy to maintain text file with the
> > wanted default environment, without patching the U-Boot source code.
>
> Earlier, Heiko sent a similar patch but using a different U-Boot config option
> [1]. We're going to merge only one of them :-)
Wrong URL (below). i think you refer to this, dating almost a year ago
so congratulations for your memory:
https://lore.kernel.org/all/20230804085118.315117-1-heiko.thiery@gmail.com/
Thanks for letting me know about this.
> This one is a bit more elegant I think because it doesn't require discovering
> the vendor directory.
Ok, good to know, so let me refine it and send a v2.
> > --- a/boot/uboot/Config.in
> > +++ b/boot/uboot/Config.in
> > @@ -136,6 +136,35 @@ config BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES
> > that will be merged to the main U-Boot configuration file.
> > endif
> >
> > +config BR2_TARGET_UBOOT_USE_DEFAULT_ENV_FILE
> > + bool "Generate default environment from text file"
>
> I think that rather than two options, we want just one string option. If it's
> empty, it is disabled.
OK.
> > + select BR2_TARGET_UBOOT_NEEDS_XXD
> > + help
> > + Define the entire U-Boot default environment from a file,
> > + disabling all the logic to generate it from the U-Boot source
> > + code and other configuration values.
> > +
> > + Based on the USE_DEFAULT_ENV_FILE and DEFAULT_ENV_FILE U-Boot
> > + configuration variables.
> > +
> > + Requires U-Boot >= v2018.05.
> > +
> > +config BR2_TARGET_UBOOT_DEFAULT_ENV_FILE
> > + string "Text file with default environment"
> > + depends on BR2_TARGET_UBOOT_USE_DEFAULT_ENV_FILE
> > + help
> > + Text file containing the variables to be used as the default
> > + environment in U-Boot.
> > +
> > + From the U-Boot documentation:
> > +
> > + The format is the same as accepted by the mkenvimage tool, with
> > + lines containing key=value pairs. Blank lines and lines
> > + beginning with '#' are ignored.
> > +
> > + For more info see:
> > + https://docs.u-boot.org/en/latest/usage/environment.html#external-environment-file
>
> Excellent help text!
Thanks!
[that's because I'm lazy: finding the info was painful, I don't want to
do that again so let's write it down, upstream it and let the Internet
make it available to the future myself :) ]
> > --- a/boot/uboot/uboot.mk
> > +++ b/boot/uboot/uboot.mk
> > @@ -390,6 +390,14 @@ UBOOT_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
> > # override again. In addition, host-ccache is not ready at kconfig
> > # time, so use HOSTCC_NOCCACHE.
> > UBOOT_KCONFIG_OPTS = $(UBOOT_MAKE_OPTS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTLDFLAGS=""
> > +
> > +ifeq ($(BR2_TARGET_UBOOT_USE_DEFAULT_ENV_FILE),y)
> > +UBOOT_DEFAULT_ENV_FILE = $(call qstrip,$(BR2_TARGET_UBOOT_DEFAULT_ENV_FILE))
> > +define UBOOT_KCONFIG_DEFAULT_ENV_FILE
> > + $(call KCONFIG_SET_OPT,CONFIG_USE_DEFAULT_ENV_FILE,y)
> > + $(call KCONFIG_SET_OPT,CONFIG_DEFAULT_ENV_FILE,"$(shell readlink -f $(UBOOT_DEFAULT_ENV_FILE))")
>
> I think we mostly use `` rather than $(shell ...) - with the backticks, it's
> much easier to understand when it's going to be evaluated.
I did some quick tests with the backticks and wasn't able to make it
work, but if you have a suggestion to make it work I'll be glad to try
that.
So I'm sending v2 still using $(shell ...) for the time being.
About which is the "common habit", I found very few cases with both, so
no obvious winner apparently. However in this same file
(boot/uboot/uboot.mk) there are two readlink usages already, both using
the $(shell ...) pattern. Disclaimer: both have been added by me :)
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] uboot: allow taking the entire default environment from a text file
2024-07-15 13:51 ` Luca Ceresoli via buildroot
@ 2024-07-15 14:49 ` Arnout Vandecappelle via buildroot
2024-07-16 12:40 ` Luca Ceresoli via buildroot
0 siblings, 1 reply; 6+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2024-07-15 14:49 UTC (permalink / raw)
To: Luca Ceresoli
Cc: Köry Maincent, Heiko Thiery, Thomas Petazzoni, buildroot
On 15/07/2024 15:51, Luca Ceresoli wrote:
> Hi Arnout,
>
> On Fri, 12 Jul 2024 11:23:12 +0200
> Arnout Vandecappelle <arnout@mind.be> wrote:
[snip]
>> I think we mostly use `` rather than $(shell ...) - with the backticks, it's
>> much easier to understand when it's going to be evaluated.
>
> I did some quick tests with the backticks and wasn't able to make it
> work, but if you have a suggestion to make it work I'll be glad to try
> that.
KCONFIG_SET_OPT adds double quotes around its argument, so backticks will
indeed not work!
Regards,
Arnout
>
> So I'm sending v2 still using $(shell ...) for the time being.
>
> About which is the "common habit", I found very few cases with both, so
> no obvious winner apparently. However in this same file
> (boot/uboot/uboot.mk) there are two readlink usages already, both using
> the $(shell ...) pattern. Disclaimer: both have been added by me :)
>
> Luca
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] uboot: allow taking the entire default environment from a text file
2024-07-15 14:49 ` Arnout Vandecappelle via buildroot
@ 2024-07-16 12:40 ` Luca Ceresoli via buildroot
0 siblings, 0 replies; 6+ messages in thread
From: Luca Ceresoli via buildroot @ 2024-07-16 12:40 UTC (permalink / raw)
To: Arnout Vandecappelle
Cc: Köry Maincent, Heiko Thiery, Thomas Petazzoni, buildroot
Hi Arnout,
On Mon, 15 Jul 2024 16:49:38 +0200
Arnout Vandecappelle <arnout@mind.be> wrote:
> On 15/07/2024 15:51, Luca Ceresoli wrote:
> > Hi Arnout,
> >
> > On Fri, 12 Jul 2024 11:23:12 +0200
> > Arnout Vandecappelle <arnout@mind.be> wrote:
>
> [snip]
> >> I think we mostly use `` rather than $(shell ...) - with the backticks, it's
> >> much easier to understand when it's going to be evaluated.
> >
> > I did some quick tests with the backticks and wasn't able to make it
> > work, but if you have a suggestion to make it work I'll be glad to try
> > that.
>
> KCONFIG_SET_OPT adds double quotes around its argument, so backticks will
> indeed not work!
Thanks for the explanation!
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-07-16 12:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-17 16:00 [Buildroot] [PATCH] uboot: allow taking the entire default environment from a text file Luca Ceresoli via buildroot
2024-06-28 13:20 ` Kory Maincent via buildroot
2024-07-12 9:23 ` Arnout Vandecappelle via buildroot
2024-07-15 13:51 ` Luca Ceresoli via buildroot
2024-07-15 14:49 ` Arnout Vandecappelle via buildroot
2024-07-16 12:40 ` Luca Ceresoli via buildroot
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.