From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iX6Xv-00007I-Fe for ptxdist@pengutronix.de; Tue, 19 Nov 2019 17:40:08 +0100 Received: by mail-wr1-x42a.google.com with SMTP id w9so24675546wrr.0 for ; Tue, 19 Nov 2019 08:40:07 -0800 (PST) From: Bruno Thomsen Date: Tue, 19 Nov 2019 17:40:02 +0100 Message-Id: <20191119164002.5288-1-bruno.thomsen@gmail.com> MIME-Version: 1.0 Subject: [ptxdist] [PATCH v3] u-boot: generate environment image List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ptxdist-bounces@pengutronix.de Sender: "ptxdist" To: ptxdist@pengutronix.de Cc: Alexander Dahl , Denis OSTERLAND , Bruno Thomsen , bth@kamstrup.com Add possiblity to generate a default or a custom environment image. Image can be used during manufacturing to avoid bootloader console usage and speed up first boot. Other image use-cases include device development edition, device demonstration mode, etc. Custom environment image is generated from an user provided config file with one 'var=value' per line format. Input config file name is configurable. Cc: Denis OSTERLAND Cc: Alexander Dahl Signed-off-by: Bruno Thomsen --- v3: - remove multiple env images support - use static image names - rebase patches on top of: u-boot: Build out-of-tree v2: - remove HOST_U_BOOT_TOOLS dependency - configurable default env image name - add custom env image generation option - move all options to sub menu platforms/u-boot.in | 57 +++++++++++++++++++++++++++++++++++++++++++++ rules/u-boot.make | 22 +++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/platforms/u-boot.in b/platforms/u-boot.in index 9bac4a758..1dfb80098 100644 --- a/platforms/u-boot.in +++ b/platforms/u-boot.in @@ -71,6 +71,63 @@ config U_BOOT_CONFIG endif +choice + prompt "Generate environment image" + default U_BOOT_NONE_ENV_IMAGE + +config U_BOOT_NONE_ENV_IMAGE + prompt "none" + bool + help + Don't generate an U-Boot environment image. + +config U_BOOT_DEFAULT_ENV_IMAGE + prompt "default" + bool + help + Use U-Boot's mkenvimage to compile a default U-Boot environment + image for use in e.g. device manufacturing or development. + +config U_BOOT_CUSTOM_ENV_IMAGE + prompt "custom" + bool + help + Use U-Boot's mkenvimage to compile a custom U-Boot environment + image based on the text file in U_BOOT_CUSTOM_ENV_IMAGE_SOURCE + for use in e.g. device manufacturing or development. + +endchoice + +config U_BOOT_CUSTOM_ENV_IMAGE_SOURCE + prompt "Custom environment source" + string + default "custom_env.config" + depends on U_BOOT_CUSTOM_ENV_IMAGE + help + Text file in PTXDIST_WORKSPACE describing the custom environment. + The file should have lines in the form var=value, one per line. + Blank lines and lines starting with a # are ignored. + +if !U_BOOT_NONE_ENV_IMAGE + +config U_BOOT_ENV_IMAGE_SIZE + prompt "Environment image size" + string + default "0x2000" + help + Enter the U-Boot environment size for generation of image. + Size can be prefixed with 0x for hexadecimal values. + Must match size defined in target config and "/etc/fw_env.config". + +config U_BOOT_ENV_IMAGE_REDUNDANT + prompt "Environment image with redundant copy" + bool + help + Use to generate a redundant environment in the image. + Must match target config and "/etc/fw_env.config". + +endif + config U_BOOT_BOOT_SCRIPT prompt "Compile U-Boot boot script" bool diff --git a/rules/u-boot.make b/rules/u-boot.make index e3c2c2389..932b4e4af 100644 --- a/rules/u-boot.make +++ b/rules/u-boot.make @@ -100,6 +100,20 @@ ifdef PTXCONF_U_BOOT_BOOT_SCRIPT @$(U_BOOT_BUILD_DIR)/tools/mkimage -T script -C none \ -d $(U_BOOT_BOOT_SCRIPT_TXT) \ $(U_BOOT_BUILD_DIR)/boot.scr.uimg +endif +ifdef PTXCONF_U_BOOT_DEFAULT_ENV_IMAGE + $(U_BOOT_MAKE_ENV) $(U_BOOT_DIR)/scripts/get_default_envs.sh $(U_BOOT_BUILD_DIR) | \ + $(U_BOOT_BUILD_DIR)/tools/mkenvimage -p 0x0 \ + $(call ptx/ifdef,PTXCONF_U_BOOT_ENV_IMAGE_REDUNDANT,-r,) \ + -s $(PTXCONF_U_BOOT_ENV_IMAGE_SIZE) \ + -o $(U_BOOT_BUILD_DIR)/u-boot-env.img - +endif +ifdef PTXCONF_U_BOOT_CUSTOM_ENV_IMAGE + $(U_BOOT_BUILD_DIR)/tools/mkenvimage -p 0x0 \ + $(call ptx/ifdef,PTXCONF_U_BOOT_ENV_IMAGE_REDUNDANT,-r,) \ + -s $(PTXCONF_U_BOOT_ENV_IMAGE_SIZE) \ + -o $(U_BOOT_BUILD_DIR)/u-boot-custom-env.img \ + $(PTXDIST_WORKSPACE)/$(PTXCONF_U_BOOT_CUSTOM_ENV_IMAGE_SOURCE) endif @$(call touch) @@ -147,6 +161,14 @@ ifdef PTXCONF_U_BOOT_INSTALL_U_BOOT_WITH_SPL_PBL @install -v -D -m644 $(U_BOOT_BUILD_DIR)/u-boot-with-spl-pbl.bin \ $(IMAGEDIR)/u-boot-with-spl-pbl.bin endif +ifdef PTXCONF_U_BOOT_DEFAULT_ENV_IMAGE + @install -v -D -m644 $(U_BOOT_BUILD_DIR)/u-boot-env.img \ + $(IMAGEDIR)/u-boot-env.img +endif +ifdef PTXCONF_U_BOOT_CUSTOM_ENV_IMAGE + @install -v -D -m644 $(U_BOOT_BUILD_DIR)/u-boot-custom-env.img \ + $(IMAGEDIR)/u-boot-custom-env.img +endif ifdef PTXCONF_U_BOOT_BOOT_SCRIPT @$(call install_init, u-boot) -- 2.23.0 _______________________________________________ ptxdist mailing list ptxdist@pengutronix.de