[PATCH v2 6/6] kbuild: pbl: use same compression algo for both barebox and DTB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ahmad Fatoum <ahmad@xxxxxx>

lzop hasn't seen any activity since 2017 and has been recently removed
from OpenEmbedded, which is unfortunate as we unconditionally use LZO
for compressing device trees that are referenced via __dtb_z_.

To make barebox easier to integrate, use the same compression algorithm
for both barebox and compressed DTB.

Note that the decompressor code will be in the image twice: Once in PBL
in uncompressed form to decompress barebox proper and once in compressed
form to decompress the DTB.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
v1 -> v2:
  - drop LZO/LZ4 hardcoding with autodetection, instead use same algo for both
---
 arch/arm/cpu/start.c | 11 ++++++++---
 images/Makefile      |  6 ------
 pbl/Kconfig          |  5 ++++-
 scripts/Makefile.lib | 11 ++++++++++-
 4 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 755d48851956..5861c15d43df 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -52,7 +52,7 @@ u32 barebox_arm_machine(void)
 void *barebox_arm_boot_dtb(void)
 {
 	void *dtb;
-	int ret;
+	int ret = 0;
 	struct barebox_boarddata_compressed_dtb *compressed_dtb;
 	static void *boot_dtb;
 
@@ -75,8 +75,13 @@ void *barebox_arm_boot_dtb(void)
 	if (!dtb)
 		return NULL;
 
-	ret = uncompress(compressed_dtb->data, compressed_dtb->datalen,
-			 NULL, NULL, dtb, NULL, NULL);
+	if (IS_ENABLED(CONFIG_IMAGE_COMPRESSION_NONE))
+		memcpy(dtb, compressed_dtb->data,
+		       compressed_dtb->datalen_uncompressed);
+	else
+		ret = uncompress(compressed_dtb->data, compressed_dtb->datalen,
+				 NULL, NULL, dtb, NULL, NULL);
+
 	if (ret) {
 		pr_err("uncompressing dtb failed\n");
 		free(dtb);
diff --git a/images/Makefile b/images/Makefile
index a148cf41766b..c79f1a272e9c 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -108,12 +108,6 @@ $(obj)/%.pblb: $(obj)/%.pbl FORCE
 $(obj)/%.s: $(obj)/% FORCE
 	$(call if_changed,disasm)
 
-suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip
-suffix_$(CONFIG_IMAGE_COMPRESSION_LZO)  = lzo
-suffix_$(CONFIG_IMAGE_COMPRESSION_LZ4)	= lz4
-suffix_$(CONFIG_IMAGE_COMPRESSION_XZKERN) = xzkern
-suffix_$(CONFIG_IMAGE_COMPRESSION_NONE) = comp_copy
-
 $(obj)/piggy.o: $(obj)/barebox.z FORCE
 
 $(obj)/sha_sum.o: $(obj)/barebox.sha.bin FORCE
diff --git a/pbl/Kconfig b/pbl/Kconfig
index 4dfa9553f786..ba809af2d5b9 100644
--- a/pbl/Kconfig
+++ b/pbl/Kconfig
@@ -31,7 +31,10 @@ if PBL_IMAGE
 config USE_COMPRESSED_DTB
 	bool
 	depends on ARM || RISCV
-	select LZO_DECOMPRESS
+	select LZ4_DECOMPRESS if IMAGE_COMPRESSION_LZ4
+	select LZO_DECOMPRESS if IMAGE_COMPRESSION_LZO
+	select ZLIB if IMAGE_COMPRESSION_GZIP
+	select XZ_DECOMPRESS if IMAGE_COMPRESSION_XZKERN
 
 config PBL_RELOCATABLE
 	depends on ARM || MIPS || RISCV
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index c2301b5370da..61617bd9dcba 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -272,6 +272,15 @@ cmd_ld = $(LD) $(KBUILD_LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \
 quiet_cmd_objcopy = OBJCOPY $@
 cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
 
+# Decompressor for barebox proper binary when using PBL
+# ---------------------------------------------------------------------------
+
+suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip
+suffix_$(CONFIG_IMAGE_COMPRESSION_LZO)  = lzo
+suffix_$(CONFIG_IMAGE_COMPRESSION_LZ4)	= lz4
+suffix_$(CONFIG_IMAGE_COMPRESSION_XZKERN) = xzkern
+suffix_$(CONFIG_IMAGE_COMPRESSION_NONE) = comp_copy
+
 # Gzip
 # ---------------------------------------------------------------------------
 
@@ -337,7 +346,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb $(obj)/%.dtb.z $(srctree)/scripts/gen-dtb-s FORCE
 	$(call if_changed,dt_S_dtb)
 
 $(obj)/%.dtb.z: $(obj)/%.dtb FORCE
-	$(call if_changed,lzo)
+	$(call if_changed,$(suffix_y))
 
 dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS))
 quiet_cmd_dtc = DTC     $@
-- 
2.30.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux