From: Bruno Thomsen <bruno.thomsen@gmail.com>
To: ptxdist@pengutronix.de
Cc: ada@thorsis.com, denis.osterland@diehl.com,
m.olbrich@pengutronix.de, Bruno Thomsen <bruno.thomsen@gmail.com>,
bth@kamstrup.com
Subject: [ptxdist] [PATCH v2] u-boot: generate environment image
Date: Wed, 13 Nov 2019 18:05:59 +0100 [thread overview]
Message-ID: <20191113170559.15307-1-bruno.thomsen@gmail.com> (raw)
Add possiblity to generate both a default and/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.
Both outputs has configurable image names so it's
easier to see specific use-case.
Examples:
u-boot-demo-env.img
u-boot-development-env.img
u-boot-manufacturing-env.img
u-boot-default-env.img
Signed-off-by: Bruno Thomsen <bruno.thomsen@gmail.com>
Tested-by: Alexander Dahl <ada@thorsis.com>
---
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 | 64 +++++++++++++++++++++++++++++++++++++++++++++
rules/u-boot.make | 22 ++++++++++++++++
2 files changed, 86 insertions(+)
diff --git a/platforms/u-boot.in b/platforms/u-boot.in
index 9bac4a758..629fc9482 100644
--- a/platforms/u-boot.in
+++ b/platforms/u-boot.in
@@ -71,6 +71,70 @@ config U_BOOT_CONFIG
endif
+menuconfig U_BOOT_GENERATE_ENV_IMAGE
+ bool
+ prompt "Generate environment image "
+
+if U_BOOT_GENERATE_ENV_IMAGE
+
+config U_BOOT_DEFAULT_ENV_IMAGE
+ prompt "Generate default environment image"
+ 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_DEFAULT_ENV_IMAGE_FILE
+ prompt "Default environment image filename"
+ string
+ default "u-boot-env.img"
+ help
+ Change default environment output image name.
+
+config U_BOOT_CUSTOM_ENV_IMAGE
+ prompt "Generate custom environment image"
+ 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.
+
+config U_BOOT_CUSTOM_ENV_IMAGE_SOURCE
+ prompt "Custom environment source"
+ string
+ default "custom_env.config"
+ 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.
+
+config U_BOOT_CUSTOM_ENV_IMAGE_FILE
+ prompt "Custom environment image filename"
+ string
+ default "u-boot-custom-env.img"
+ help
+ Change custom environment output image name.
+
+comment "common options ---"
+
+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 8f9290ea7..c3c426d6d 100644
--- a/rules/u-boot.make
+++ b/rules/u-boot.make
@@ -94,6 +94,20 @@ ifdef PTXCONF_U_BOOT_BOOT_SCRIPT
@$(U_BOOT_DIR)/tools/mkimage -T script -C none \
-d $(U_BOOT_BOOT_SCRIPT_TXT) \
$(U_BOOT_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_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_DIR)/$(PTXCONF_U_BOOT_DEFAULT_ENV_IMAGE_FILE) -
+endif
+ifdef PTXCONF_U_BOOT_CUSTOM_ENV_IMAGE
+ $(U_BOOT_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_DIR)/$(PTXCONF_U_BOOT_CUSTOM_ENV_IMAGE_FILE) \
+ $(PTXDIST_WORKSPACE)/$(PTXCONF_U_BOOT_CUSTOM_ENV_IMAGE_SOURCE)
endif
@$(call touch)
@@ -141,6 +155,14 @@ ifdef PTXCONF_U_BOOT_INSTALL_U_BOOT_WITH_SPL_PBL
@install -v -D -m644 $(U_BOOT_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_DIR)/$(PTXCONF_U_BOOT_DEFAULT_ENV_IMAGE_FILE) \
+ $(IMAGEDIR)/$(PTXCONF_U_BOOT_DEFAULT_ENV_IMAGE_FILE)
+endif
+ifdef PTXCONF_U_BOOT_CUSTOM_ENV_IMAGE
+ @install -v -D -m644 $(U_BOOT_DIR)/$(PTXCONF_U_BOOT_CUSTOM_ENV_IMAGE_FILE) \
+ $(IMAGEDIR)/$(PTXCONF_U_BOOT_CUSTOM_ENV_IMAGE_FILE)
+endif
ifdef PTXCONF_U_BOOT_BOOT_SCRIPT
@$(call install_init, u-boot)
--
2.23.0
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
next reply other threads:[~2019-11-13 17:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-13 17:05 Bruno Thomsen [this message]
2019-11-13 19:02 ` Alexander Dahl
2019-11-15 13:59 ` Michael Olbrich
2019-11-18 8:43 ` Denis OSTERLAND
2019-11-18 12:25 ` Bruno Thomsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191113170559.15307-1-bruno.thomsen@gmail.com \
--to=bruno.thomsen@gmail.com \
--cc=ada@thorsis.com \
--cc=bth@kamstrup.com \
--cc=denis.osterland@diehl.com \
--cc=m.olbrich@pengutronix.de \
--cc=ptxdist@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox