mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/3] kbuild: gen-dtb-s: refactor to allow different compression methods
Date: Mon, 11 Jul 2022 15:15:54 +0200	[thread overview]
Message-ID: <20220711131556.2122028-1-a.fatoum@pengutronix.de> (raw)

We unconditonally use LZO for __dtb_z symbols when
CONFIG_USE_COMPRESSED_DTB=y. Refactor the code to allow different
compression methods. The immediate benefit is allowing LZ4 as an
alternative, as lzop is dormant and in future, we may want to reuse the
same compression method used for barebox proper for the device tree as
well.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/Kconfig       |  6 +++++-
 scripts/Makefile.lib |  2 +-
 scripts/gen-dtb-s    | 18 +++++++++++++++---
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index f7a6a96e877c..076fe455f8ac 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -45,7 +45,11 @@ config USE_COMPRESSED_DTB
 	bool
 	depends on ARM || RISCV
 	select UNCOMPRESS
-	select LZO_DECOMPRESS
+	select LZO_DECOMPRESS if DTB_COMPRESSION = "lzo"
+
+config DTB_COMPRESSION
+	string
+	default "lzo"
 
 config FILETYPE
 	bool
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a830364a8bab..18abeebdc0a9 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -332,7 +332,7 @@ endif
 
 # Generate an assembly file to wrap the output of the device tree compiler
 quiet_cmd_dt_S_dtb = DTB     $@
-cmd_dt_S_dtb = $(srctree)/scripts/gen-dtb-s $(subst -,_,$(*F)) $< $(CONFIG_IMD) > $@
+cmd_dt_S_dtb = $(srctree)/scripts/gen-dtb-s $(subst -,_,$(*F)) $< $(CONFIG_IMD) $(CONFIG_DTB_COMPRESSION) > $@
 $(obj)/%.dtb.S: $(obj)/%.dtb $(srctree)/scripts/gen-dtb-s FORCE
 	$(call if_changed,dt_S_dtb)
 
diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
index 1027db28044f..da0b593da4eb 100755
--- a/scripts/gen-dtb-s
+++ b/scripts/gen-dtb-s
@@ -3,6 +3,7 @@
 name=$1
 dtb=$2
 imd=$3
+compression=$4
 
 echo "#include <asm-generic/barebox.lds.h>"
 
@@ -51,11 +52,22 @@ echo "__dtb_${name}_end:"
 echo ".global __dtb_${name}_end"
 echo ".balign STRUCT_ALIGNMENT"
 
-lzop -f -9 $dtb -o $dtb.lzo
+case $compression in
+	none)
+		exit 0
+		;;
+	lzo)
+		lzop -f -9 $dtb -o $dtb.$compression
+		;;
+	*)
+		echo Unsupported compression algorithm: $compression >&2
+		exit 1
+		;;
+esac
 if [ $? != 0 ]; then
 	exit 1
 fi
-compressed=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $dtb.lzo)
+compressed=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $dtb.$compression)
 uncompressed=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $dtb)
 
 echo "#ifdef CONFIG_USE_COMPRESSED_DTB"
@@ -66,7 +78,7 @@ echo "__dtb_z_${name}_start:"
 printf ".int 0x%08x\n"  0x7b66bcbd
 printf ".int 0x%08x\n"  $compressed
 printf ".int 0x%08x\n"  $uncompressed
-echo ".incbin \"$dtb.lzo\""
+echo ".incbin \"$dtb.$compression\""
 echo "__dtb_z_${name}_end:"
 echo ".global __dtb_z_${name}_end"
 echo ".balign STRUCT_ALIGNMENT"
-- 
2.30.2




             reply	other threads:[~2022-07-11 13:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-11 13:15 Ahmad Fatoum [this message]
2022-07-11 13:15 ` [PATCH 2/3] scripts: gen-dtb-s: fallback to LZ4 if lzop is unavailable Ahmad Fatoum
2022-07-11 13:15 ` [PATCH 3/3] common: don't allow compressing in-barebox binaries again Ahmad Fatoum

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=20220711131556.2122028-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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