[PATCH v4 10/10] env: ubi: add support to create environment volume if it does not exist

Simon Glass sjg at chromium.org
Fri May 15 14:59:28 CEST 2026


Hi Weijie,

On 2026-05-13T08:02:45, Weijie Gao <weijie.gao at mediatek.com> wrote:
> env: ubi: add support to create environment volume if it does not exist
>
> When U-Boot is booting from a fresh device, the environment volume may not
> exist in the factory UBI image. This is a common case where factory UBI
> image contains only volumes with valid data.
>
> With the current design, even if the volume is created manually, the
> environment will still be unusable (e.g., saveenv) before a reboot.
>
> This patch adds support to automatically create missing volumes before
> loading environment. This will make environment available at first boot.
>
> There are two options:
> CONFIG_ENV_UBI_VOLUME_CREATE: whether to enable volume creation
> CONFIG_ENV_UBI_VOLUME_STATIC: create static volume (default is dynamic)
>
> Signed-off-by: Weijie Gao <weijie.gao at mediatek.com>
>
> env/Kconfig | 20 +++++++++++++++++++
>  env/ubi.c   | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++-----------
>  2 files changed, 74 insertions(+), 11 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>

> diff --git a/env/Kconfig b/env/Kconfig
> @@ -716,6 +716,26 @@ config ENV_UBI_VOLUME_REDUND
> +config ENV_UBI_VOLUME_CREATE
> +     bool "Create UBI volume if it does not exist"
> +     depends on ENV_IS_IN_UBI
> +     help
> +       This option is useful if U-Boot will be booted from a fresh device
> +       where the environment volume has not been created.
> +       This is a common case where factory UBI image contains only volumes
> +       with valid data.
> +       By enabling this option, any missing environment volumes will be
> +       created before loading.
> +       If CONFIG_ENV_UBI_VOLUME_REDUND is also enabled, both volumes will be
> +       created,

Trailing comma should be a full stop. Also drop the CONFIG_ prefix -
the Kconfig convention is to refer to the symbol as
ENV_UBI_VOLUME_REDUND.

Regards,
Simon


More information about the U-Boot mailing list