mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] images: Add automatic image crc generation for imd
@ 2020-12-04 10:04 Yunus Bas
  2020-12-07  9:28 ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Yunus Bas @ 2020-12-04 10:04 UTC (permalink / raw)
  To: barebox

Since commit 9d12256bfcc6, the barebox IMD-header has an additional
register space for CRC32 checksum. This is an important feature, since
it allows us to verify the barebox image after flashing to the hardware.

This patch adds an optional feature for automatically generating the CRC32
checksum and writing it into IMD-section for all generated image-files.
Additionally, the file 'barebox-imd-crc', containing the list of IMD
outputs including the CRC32-value, will be generated under the images
directory.

Signed-off-by: Yunus Bas <y.bas@phytec.de>
---
 common/Kconfig  | 11 +++++++++++
 images/Makefile | 16 ++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 9b73aa845..a278cdbef 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -697,6 +697,17 @@ config IMD
 	select CRC32
 	bool "barebox metadata support"
 
+config IMD_CRC_IMAGE
+	bool "crc32 checksum generation for IMD-header"
+	depends on IMD
+	help
+	  Enable this option for automatic generation and addition of the
+	  crc checksum to the Barebox ImageMetaData (IMD). Once enabled,
+	  this option uses the bareboximd-tool under the scripts directory
+	  to generate and set the crc checksums for all generated img-files.
+	  In addition, the file 'barebox-imd-crc' with a list of IMD's
+	  from the generated images will be created in the images-directory.
+
 config IMD_TARGET
 	bool "build bareboximd target tool"
 	depends on IMD
diff --git a/images/Makefile b/images/Makefile
index b8899dcd2..f5a320bf6 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -196,7 +196,12 @@ flash-link := $(obj)/../barebox-flash-image
 link-dest := $(if $(filter 1,$(words $(image-y))),$(image-y-path),multi-image-build)
 multi-image-build:
 
-images: $(image-y-path) $(flash-link) $(flash-list) FORCE
+# List of IMD's, including the filled crc reg, from the generated images
+ifdef CONFIG_IMD_CRC_IMAGE
+crc-gen := $(obj)/barebox-imd-crc
+endif
+
+images: $(image-y-path) $(flash-link) $(flash-list) $(crc-gen) FORCE
 	@echo "images built:"
 	@for i in $(image-y); do echo $$i; done
 
@@ -206,8 +211,15 @@ $(flash-link): $(link-dest) FORCE
 $(flash-list): $(image-y-path)
 	@for i in $^; do echo $$i; done > $@
 
+$(crc-gen): $(image-y-path)
+	@echo "generating and adding crc checksum to barebox images:"
+	@for i in $^; do \
+		echo "$$i:"; \
+		scripts/bareboximd -c $$i; \
+	done > $@
+
 clean-files := *.pbl *.pblb *.map start_*.imximg *.img barebox.z start_*.kwbimg \
 	start_*.kwbuartimg *.socfpgaimg *.mlo *.t20img *.t20img.cfg *.t30img \
 	*.t30img.cfg *.t124img *.t124img.cfg *.mlospi *.mlo *.mxsbs *.mxssd \
 	start_*.simximg start_*.usimximg *.zynqimg *.image
-clean-files += pbl.lds
+clean-files += pbl.lds barebox-imd-crc
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-12-08  8:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04 10:04 [PATCH] images: Add automatic image crc generation for imd Yunus Bas
2020-12-07  9:28 ` Sascha Hauer
2020-12-07  9:29   ` [PATCH 1/3] imd command: specify outfile for crc tag generation Sascha Hauer
2020-12-07  9:29     ` [PATCH 2/3] kbuild: Add command to generate the crc for the IMD crc tag Sascha Hauer
2020-12-07  9:29     ` [PATCH 3/3] images: i.MX: fill in crc in IMD crc tags Sascha Hauer
2020-12-08  8:09   ` [PATCH] images: Add automatic image crc generation for imd Yunus Bas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox