[U-Boot] [PATCH] env: Add CONFIG_ENV_SUPPORT

Lukasz Majewski lukma at denx.de
Wed Sep 4 08:51:41 UTC 2019


Hi Patrick,

> Add a new flag CONFIG_ENV_SUPPORT to compile all
> the environment features in U-Boot (attributes, callbacks
> and flags). It is the equivalent of the 2 existing flags
> - CONFIG_SPL_ENV_SUPPORT for SPL
> - CONFIG_TPL_ENV_SUPPORT for TPL

Shouldn't it be the "supplement" ?

I guess that it is possible to define 

CONFIG_SPL_ENV_SUPPORT to have ENV support in SPL

CONFIG_TPL_ENV_SUPPORT to have ENV support in TPL

and there is a third flag - CONFIG_ENV_SUPPORT to enable envs support
in U-Boot proper?

In that way one can enable ENV support only in SPL (via SPL_ENV_SUPPORT)
and disable envs in U-Boot proper (by NOT defining ENV_SUPPORT) and use
build in envs (in the binary).

> 
> This new configuration allows to use the macro
> CONFIG_IS_ENABLED(ENV_SUPPORT) in the code without
> issue and solves the regression introduced by
> commit 7d4776545b0f ("env: solve compilation error
> in SPL"); change_ok was always NULL in U-Boot.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
> ---
> 
>  cmd/Kconfig            |  2 ++
>  env/Kconfig            |  7 +++++++
>  env/Makefile           | 11 ++++-------
>  include/env_callback.h |  4 ++++
>  include/env_flags.h    |  4 ++++
>  5 files changed, 21 insertions(+), 7 deletions(-)
> 
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 05872fa..f7a1b1f 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -465,6 +465,7 @@ config CMD_ENV_EXISTS
>  
>  config CMD_ENV_CALLBACK
>  	bool "env callbacks - print callbacks and their associated
> variables"
> +	depends on ENV_SUPPORT
>  	help
>  	  Some environment variable have callbacks defined by
>  	  U_BOOT_ENV_CALLBACK. These are called when the variable
> changes. @@ -473,6 +474,7 @@ config CMD_ENV_CALLBACK
>  
>  config CMD_ENV_FLAGS
>  	bool "env flags -print variables that have non-default flags"
> +	depends on ENV_SUPPORT
>  	help
>  	  Some environment variables have special flags that control
> their behaviour. For example, serial# can only be written once and
> cannot diff --git a/env/Kconfig b/env/Kconfig
> index 74db2f3..f0c5a7a 100644
> --- a/env/Kconfig
> +++ b/env/Kconfig
> @@ -1,5 +1,12 @@
>  menu "Environment"
>  
> +config ENV_SUPPORT
> +	bool "Support all environment features"
> +	default y
> +	help
> +	  Enable full environment support in U-Boot,
> +	  including attributes, callbacks and flags.
> +
>  config ENV_IS_NOWHERE
>  	bool "Environment is not stored"
>  	default y if !ENV_IS_IN_EEPROM && !ENV_IS_IN_EXT4 && \
> diff --git a/env/Makefile b/env/Makefile
> index 90144d6..2a468ac 100644
> --- a/env/Makefile
> +++ b/env/Makefile
> @@ -5,10 +5,11 @@
>  
>  obj-y += common.o env.o
>  
> +obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += attr.o
> +obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += flags.o
> +obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += callback.o
> +
>  ifndef CONFIG_SPL_BUILD
> -obj-y += attr.o
> -obj-y += callback.o
> -obj-y += flags.o
>  obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o
>  extra-$(CONFIG_ENV_IS_EMBEDDED) += embedded.o
>  obj-$(CONFIG_ENV_IS_IN_EEPROM) += embedded.o
> @@ -19,10 +20,6 @@ obj-$(CONFIG_ENV_IS_IN_ONENAND) += onenand.o
>  obj-$(CONFIG_ENV_IS_IN_SATA) += sata.o
>  obj-$(CONFIG_ENV_IS_IN_REMOTE) += remote.o
>  obj-$(CONFIG_ENV_IS_IN_UBI) += ubi.o
> -else
> -obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += attr.o
> -obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += flags.o
> -obj-$(CONFIG_$(SPL_TPL_)ENV_SUPPORT) += callback.o
>  endif
>  
>  obj-$(CONFIG_$(SPL_TPL_)ENV_IS_NOWHERE) += nowhere.o
> diff --git a/include/env_callback.h b/include/env_callback.h
> index 982c078..a757fe6 100644
> --- a/include/env_callback.h
> +++ b/include/env_callback.h
> @@ -72,6 +72,10 @@
>  	"serial#:serialno," \
>  	CONFIG_ENV_CALLBACK_LIST_STATIC
>  
> +#if CONFIG_IS_ENABLED(ENV_SUPPORT)
>  void env_callback_init(struct env_entry *var_entry);
> +#else
> +static inline void env_callback_init(struct env_entry *var_entry) { }
> +#endif
>  
>  #endif /* __ENV_CALLBACK_H__ */
> diff --git a/include/env_flags.h b/include/env_flags.h
> index e5380f2..ec480e3 100644
> --- a/include/env_flags.h
> +++ b/include/env_flags.h
> @@ -153,7 +153,11 @@ int env_flags_validate_env_set_params(char
> *name, char *const val[], int count);
>   * When adding a variable to the environment, initialize the flags
> for that
>   * variable.
>   */
> +#if CONFIG_IS_ENABLED(ENV_SUPPORT)
>  void env_flags_init(struct env_entry *var_entry);
> +#else
> +static inline void env_flags_init(struct env_entry *var_entry) { }
> +#endif
>  
>  /*
>   * Validate the newval for to conform with the requirements defined
> by its flags



Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190904/aad48e6f/attachment.sig>


More information about the U-Boot mailing list