[PATCH] decompress: xz: enable armthumb BCJ filter for Thumb-2 barebox

Ahmad Fatoum a.fatoum at pengutronix.de
Fri Oct 20 11:09:12 PDT 2023


The XZ decompressor in barebox has BCJ filter support for THUMB, but
like Linux, it's unused and instead the ARM BCJ filter is used.

Fixing that lets us save a few kilobytes, which is especially useful for
legacy configuration that fit a whole barebox into limited on-chip SRAM
(and not only the prebootloader). For example, with this patch applied
barebox-am33xx-beaglebone-mlo.img is shrinked 3K from 109236 to 106028 bytes.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 lib/decompress_unxz.c | 2 ++
 scripts/xz_wrap.sh    | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
index 132ab4a239b3..ad6a5f20ba28 100644
--- a/lib/decompress_unxz.c
+++ b/lib/decompress_unxz.c
@@ -133,6 +133,8 @@
 #ifdef CONFIG_ARM
 #	ifdef CONFIG_CPU_64
 #		define XZ_DEC_ARM64
+#	elif defined CONFIG_THUMB2_BAREBOX
+#		define XZ_DEC_ARMTHUMB
 #	else
 #		define XZ_DEC_ARM
 #	endif
diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh
index 5b5f3adcff6d..a6373a748168 100755
--- a/scripts/xz_wrap.sh
+++ b/scripts/xz_wrap.sh
@@ -20,6 +20,10 @@ case $SRCARCH in
 	sparc)          BCJ=--sparc ;;
 esac
 
+if grep -q '^CONFIG_THUMB2_BAREBOX=y$' include/config/auto.conf; then
+	BCJ=--armthumb
+fi
+
 # clear BCJ filter if unsupported
 xz -H | grep -q -- $BCJ || BCJ=
 
-- 
2.39.2




More information about the barebox mailing list