@@ -607,6 +607,16 @@ config BR2_TARGET_UBOOT_CUSTOM_DTS_PATH
endif
+config BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_FILE
+ string "Custom environment file"
+ help
+ Provide a custom u-boot environment file. This will be
+ copied to the U-Boot source directory in the corresponding
+ boardspecific folder and enabled via the U-Boot config
+ option CONFIG_ENV_SOURCE_FILE. The target path will be
+ determined based on the U-Boot configuration using
+ CONFIG_SYS_VENDOR and CONFIG_SYS_BOARD.
+
config BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS
string "Custom make options"
help
@@ -181,6 +181,24 @@ UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_ATF_FIRMWARE
endif
endif
+#
+# Prepare for custom environment
+#
+UBOOT_CUSTOM_ENVIRONMENT_FILE = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_FILE))
+UBOOT_ENV_FILE_NAME=$(patsubst %.env,%,$(notdir $(UBOOT_CUSTOM_ENVIRONMENT_FILE)))
+ifneq ($(UBOOT_CUSTOM_ENVIRONMENT_FILE),)
+define UBOOT_COPY_CUSTOM_ENVIRONMENT_FILE
+ sys_vendor=$(shell BR2_PREFIX= utils/config --file $(@D)/.config -s CONFIG_SYS_VENDOR); \
+ sys_board=$(shell BR2_PREFIX= utils/config --file $(@D)/.config -s CONFIG_SYS_BOARD); \
+ cp -f $(UBOOT_CUSTOM_ENVIRONMENT_FILE) $(@D)/board/$${sys_vendor}/$${sys_board}
+endef
+UBOOT_POST_CONFIGURE_HOOKS += UBOOT_COPY_CUSTOM_ENVIRONMENT_FILE
+
+define UBOOT_KCONFIG_CUSTOM_ENV_SOURCE
+ $(call KCONFIG_SET_OPT,CONFIG_ENV_SOURCE_FILE,"$(UBOOT_ENV_FILE_NAME)")
+endef
+endif # UBOOT_CUSTOM_ENVIRONMENT_FILE != ""
+
ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE),y)
UBOOT_DEPENDENCIES += optee-os
UBOOT_MAKE_OPTS += TEE=$(BINARIES_DIR)/tee.elf
@@ -497,6 +515,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 value of CONFIG_ENV_SOURCE_FILE must only contain the filename without the '.env' suffix. Thus the buildroot option BR2_TARGET_UBOOT_CUSTOM_ENVIRONMENT_FILE is added that needs the information about the target of the file in the buildroot environment. Since the environment file must be located in the U-Boot board source directory <SRC>/board/<VENDOR>/<BOARDNAME>. These information about vendor name and board name are available in the U-Boot .config file and can be extracted from there to determine the destination directoy. Cc: Michael Walle <michael@walle.cc> Cc: Yann E. MORIN <yann.morin.1998@free.fr> Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com> --- boot/uboot/Config.in | 10 ++++++++++ boot/uboot/uboot.mk | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+)