diff --git a/boot/uboot/Config.in b/boot/uboot/Config.in index 626585b378..57aac06e20 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_DEFAULT_ENV_FILE + string "Text file with default environment" + select BR2_TARGET_UBOOT_NEEDS_XXD + help + Text file containing the variables to be used as the default + environment in U-Boot. + + If empty, let U-Boot generate the default enviromnent from the + source code and other U-Boot configuration values, which is + the default behaviour. + + If set to the path to a file, instructs U-Boot to define the + entire U-Boot default environment from the provided file, + disabling all the default behaviour. + + 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. + + Based on the USE_DEFAULT_ENV_FILE and DEFAULT_ENV_FILE U-Boot + configuration variables. + + For more info see: + https://docs.u-boot.org/en/latest/usage/environment.html#external-environment-file + + Requires U-Boot >= v2018.05. + 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 19f4cdb557..6cc87b35d3 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="" + +UBOOT_DEFAULT_ENV_FILE = $(call qstrip,$(BR2_TARGET_UBOOT_DEFAULT_ENV_FILE)) +ifneq ($(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)