@@ -37,6 +37,56 @@ config BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT
public key is stored in a non-volatile place, any image can
be verified in this way.
-endif
+endif # BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT
-endif
+config BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE
+ bool "Environment image"
+ help
+ Generate a valid binary environment image from a text file
+ describing the key=value pairs of the environment.
+
+ This option can be useful to build enviornment configurations
+ as part of a Linux / rootfs only defconfig instead of using
+ post scripts. This supports a hardware use case of a single
+ bootloader only defconfig but multiple Linux / rootfs
+ defconfigs with different boot environments.
+
+ The environment image will be called uboot-env.bin.
+
+if BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE
+
+config BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SOURCE
+ string "Source files for environment"
+ help
+ Text files describing the environment. Files should have
+ lines of the form var=value, one per line. Blank lines and
+ lines starting with a # are ignored.
+
+ Multiple source files are concatenated in the order listed.
+
+ Unlike the U-Boot package, the source files must be provided
+ as there is no uboot configured to define the compiled-in env.
+
+config BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SIZE
+ string "Size of environment"
+ help
+ Size of envronment, can be prefixed with 0x for hexadecimal
+ values.
+
+config BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_REDUNDANT
+ bool "Environment has two copies"
+ help
+ Some platforms define in their U-Boot configuration that the
+ U-Boot environment should be duplicated in two locations (for
+ extra safety). Check your U-Boot configuration for the
+ CONFIG_ENV_ADDR_REDUND and CONFIG_ENV_SIZE_REDUND settings to
+ see if this is the case for your platform.
+
+ If it is the case, then you should enable this option to
+ ensure that the U-Boot environment image generated by
+ Buildroot is compatible with the "redundant environment"
+ mechanism of U-Boot.
+
+endif # BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE
+
+endif # BR2_PACKAGE_HOST_UBOOT_TOOLS
@@ -112,10 +112,23 @@ define HOST_UBOOT_TOOLS_BUILD_CMDS
$(BR2_MAKE1) -C $(@D) $(HOST_UBOOT_TOOLS_MAKE_OPTS) tools-only
endef
+ifneq ($(BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE),)
+UBOOT_TOOLS_GENERATE_ENV_FILE = $(call qstrip,$(BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SOURCE))
+define UBOOT_TOOLS_GENERATE_ENV_IMAGE
+ cat $(UBOOT_TOOLS_GENERATE_ENV_FILE) > $(@D)/buildroot-env.txt
+ $(HOST_DIR)/bin/mkenvimage -s $(BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SIZE) \
+ $(if $(BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_REDUNDANT),-r) \
+ $(if $(filter "BIG",$(BR2_ENDIAN)),-b) \
+ -o $(BINARIES_DIR)/uboot-env.bin \
+ $(@D)/buildroot-env.txt
+endef
+endif
+
define HOST_UBOOT_TOOLS_INSTALL_CMDS
$(INSTALL) -m 0755 -D $(@D)/tools/mkimage $(HOST_DIR)/bin/mkimage
$(INSTALL) -m 0755 -D $(@D)/tools/mkenvimage $(HOST_DIR)/bin/mkenvimage
$(INSTALL) -m 0755 -D $(@D)/tools/dumpimage $(HOST_DIR)/bin/dumpimage
+ $(UBOOT_TOOLS_GENERATE_ENV_IMAGE)
endef
$(eval $(generic-package))
Add an option to allow the creation of a u-boot environment binary from a set of provided source file(s) when the defconfig being built does not offer the option via the u-boot package. This feature requires environment source files unlike the u-boot package equivalent that can build the default environment based on the specific u-boot source tree and configuration. Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com> --- I did not add conditions to force the user to use the u-boot pkg option if that is available. Seemed unnecessary as this would still work in that case. --- package/uboot-tools/Config.in.host | 54 ++++++++++++++++++++++++++++-- package/uboot-tools/uboot-tools.mk | 13 +++++++ 2 files changed, 65 insertions(+), 2 deletions(-)