@@ -607,6 +607,27 @@ config BR2_TARGET_UBOOT_CUSTOM_DTS_PATH
endif
+config BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT
+ bool "custom environment"
+ help
+ Provide a custom u-boot environment file. This will be copied
+ to the BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_TARGET path and
+ enable via the U-Boot config option CONFIG_ENV_SOURCE_FILE.
+
+if BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT
+config BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_SOURCE
+ string "Custom environment source file"
+ help
+ Path to U-Boot custom environment file.
+
+config BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_TARGET
+ string "Custom environment target path"
+ help
+ Path to the U-Boot target directory where the file will be
+ copied to. The path is relative to the U-Boot source directory.
+
+endif
+
config BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS
string "Custom make options"
help
@@ -181,6 +181,26 @@ UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_ATF_FIRMWARE
endif
endif
+#
+# Prepare for custom environment
+#
+ifeq ($(BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT),y)
+ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_SOURCE)),)
+$(error No custom environment source file specified, check your BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_SOURCE setting)
+endif
+ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_TARGET)),)
+$(error No custom environment target path specified, check your BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_TARGET setting)
+endif
+define UBOOT_COPY_CUSTOM_ENVIRONMENT_FILE
+ cp -f $(BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_SOURCE) $(@D)/$(BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_TARGET)/
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_CUSTOM_ENVIRONMENT_FILE
+UBOOT_ENV_FILE_NAME=$(subst .env,,$(notdir $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_SOURCE))))
+define UBOOT_KCONFIG_CUSTOM_ENV_SOURCE
+ $(call KCONFIG_SET_OPT,CONFIG_ENV_SOURCE_FILE,"$(UBOOT_ENV_FILE_NAME)")
+endef
+endif
+
ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE),y)
UBOOT_DEPENDENCIES += optee-os
UBOOT_MAKE_OPTS += TEE=$(BINARIES_DIR)/tee.elf
@@ -497,6 +517,7 @@ define UBOOT_KCONFIG_FIXUP_CMDS
$(UBOOT_ZYNQMP_KCONFIG_PMUFW)
$(UBOOT_ZYNQMP_KCONFIG_PM_CFG)
$(UBOOT_ZYNQMP_KCONFIG_PSU_INIT)
+ $(UBOOT_KCONFIG_CUSTOM_ENV_SOURCE)
endef
ifeq ($(BR2_TARGET_UBOOT)$(BR_BUILDING),yy)
U-Boot has the capability to set the environment variables via a text file. The text file has to be located in the U-Boot board source directory and selected via the CONFIG_ENV_SOURCE_FILE option. The CONFIG_ENV_SOURCE_FILE must only contain the filename without the '.env' suffix. Thus the buildroot option BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT is added that needs the information about the source of the file in the buildroot environment (BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_SOURCE) and the target directory (BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_TARGET) where to copy the file in the U-Boot source environment. Cc: Michael Walle <michael@walle.cc> Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com> --- boot/uboot/Config.in | 21 +++++++++++++++++++++ boot/uboot/uboot.mk | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+)