mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again
@ 2022-07-13  9:57 Ahmad Fatoum
  2022-07-13  9:57 ` [PATCH v2 2/6] pbl: make USE_COMPRESSED_DTB a PBL-only feature Ahmad Fatoum
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2022-07-13  9:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For barebox with a prebootloader, we can compress barebox proper as a
whole and it makes no sense to compress the environment on its own
again. The choice already defaulted to this, but the user could still
override it. Ensure that this double compression can't happen.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - no change
---
 common/Kconfig | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 2292e7bcea46..6278866006b1 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -860,29 +860,30 @@ choice
 	default DEFAULT_COMPRESSION_LZ4 if LZ4_DECOMPRESS
 	default DEFAULT_COMPRESSION_BZIP2 if BZLIB
 	help
-	  Select the default compression for in-barebox binary files. Files
-	  compiled into barebox like for example the default environment will
-	  be compressed with this compression type.
+	  For barebox builds without a prebootloader, select here the default
+	  compression for in-barebox binary files. barebox itself can't be
+	  compressed without a prebootloader, but for example the default
+	  environment will be compressed with this compression type.
 
 config DEFAULT_COMPRESSION_GZIP
 	bool "gzip"
-	depends on ZLIB
+	depends on !PBL_IMAGE && ZLIB
 
 config DEFAULT_COMPRESSION_BZIP2
 	bool "bzip2"
-	depends on BZLIB
+	depends on !PBL_IMAGE && BZLIB
 
 config DEFAULT_COMPRESSION_LZO
 	bool "lzo"
-	depends on LZO_DECOMPRESS
+	depends on !PBL_IMAGE && LZO_DECOMPRESS
 
 config DEFAULT_COMPRESSION_LZ4
 	bool "lz4"
-	depends on LZ4_DECOMPRESS
+	depends on !PBL_IMAGE && LZ4_DECOMPRESS
 
 config DEFAULT_COMPRESSION_XZ
 	bool "xz"
-	depends on XZ_DECOMPRESS
+	depends on !PBL_IMAGE && XZ_DECOMPRESS
 
 config DEFAULT_COMPRESSION_NONE
 	bool "no compression"
-- 
2.30.2




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

* [PATCH v2 2/6] pbl: make USE_COMPRESSED_DTB a PBL-only feature
  2022-07-13  9:57 [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Ahmad Fatoum
@ 2022-07-13  9:57 ` Ahmad Fatoum
  2022-07-13  9:57 ` [PATCH v2 3/6] pbl: remove redundant select UNCOMRPESS Ahmad Fatoum
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2022-07-13  9:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

From: Ahmad Fatoum <ahmad@a3f.at>

All in-tree boards that reference __dtb_z_ symbols are already
multi-image capable and allow us to compress barebox proper by having
the prebootloader decompress it using the algorithm specified by the
CONFIG_IMAGE_COMPRESSION_* option.

DTB on the other hand, is handled specially and the optional compression
is always using LZO. It makes sense to use the same
CONFIG_IMAGE_COMPRESSION_* options for the DT too to make build system
integration easier.

To avoid special casing non-PBL support which lacks this options, just
drop USE_COMPRESSED_DTB there. If linking barebox for your downstream
board is broken by this:

  - If not multi-image capable, consider porting it to use
    ENTRY_FUNCTION(_WITHSTACK) instead

  - If you are using __dtb_z_* in barebox proper, use normal __dtb_
    and compress barebox as a whole instead with
    CONFIG_IMAGE_COMPRESSION_*

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - new patch
---
 common/Kconfig    | 6 ------
 pbl/Kconfig       | 6 ++++++
 scripts/gen-dtb-s | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 6278866006b1..60f52a10e11d 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -41,12 +41,6 @@ config BLOCK
 config BLOCK_WRITE
 	bool
 
-config USE_COMPRESSED_DTB
-	bool
-	depends on ARM || RISCV
-	select UNCOMPRESS
-	select LZO_DECOMPRESS
-
 config FILETYPE
 	bool
 
diff --git a/pbl/Kconfig b/pbl/Kconfig
index ce0acbb646c7..ec1886073e42 100644
--- a/pbl/Kconfig
+++ b/pbl/Kconfig
@@ -28,6 +28,12 @@ config PBL_SINGLE_IMAGE
 
 if PBL_IMAGE
 
+config USE_COMPRESSED_DTB
+	bool
+	depends on ARM || RISCV
+	select UNCOMPRESS
+	select LZO_DECOMPRESS
+
 config PBL_RELOCATABLE
 	depends on ARM || MIPS || RISCV
 	bool "relocatable pbl image"
diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
index 1027db28044f..868d434664ec 100755
--- a/scripts/gen-dtb-s
+++ b/scripts/gen-dtb-s
@@ -58,7 +58,7 @@ fi
 compressed=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $dtb.lzo)
 uncompressed=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $dtb)
 
-echo "#ifdef CONFIG_USE_COMPRESSED_DTB"
+echo "#if defined(CONFIG_USE_COMPRESSED_DTB) && defined(__PBL__)"
 echo ".section .dtbz.rodata.${name},\"a\""
 echo ".balign STRUCT_ALIGNMENT"
 echo ".global __dtb_z_${name}_start"
-- 
2.30.2




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

* [PATCH v2 3/6] pbl: remove redundant select UNCOMRPESS
  2022-07-13  9:57 [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Ahmad Fatoum
  2022-07-13  9:57 ` [PATCH v2 2/6] pbl: make USE_COMPRESSED_DTB a PBL-only feature Ahmad Fatoum
@ 2022-07-13  9:57 ` Ahmad Fatoum
  2022-07-13  9:57 ` [PATCH v2 4/6] kbuild: gen-dtb-s: use Makefile.lib instead of duplicating cmd_lzo Ahmad Fatoum
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2022-07-13  9:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

LZO_DECOMPRESS as well as all other decompress options already select
UNCOMPRESS, so selecting it again is unnecessary.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - new patch
---
 pbl/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pbl/Kconfig b/pbl/Kconfig
index ec1886073e42..4dfa9553f786 100644
--- a/pbl/Kconfig
+++ b/pbl/Kconfig
@@ -31,7 +31,6 @@ if PBL_IMAGE
 config USE_COMPRESSED_DTB
 	bool
 	depends on ARM || RISCV
-	select UNCOMPRESS
 	select LZO_DECOMPRESS
 
 config PBL_RELOCATABLE
-- 
2.30.2




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

* [PATCH v2 4/6] kbuild: gen-dtb-s: use Makefile.lib instead of duplicating cmd_lzo
  2022-07-13  9:57 [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Ahmad Fatoum
  2022-07-13  9:57 ` [PATCH v2 2/6] pbl: make USE_COMPRESSED_DTB a PBL-only feature Ahmad Fatoum
  2022-07-13  9:57 ` [PATCH v2 3/6] pbl: remove redundant select UNCOMRPESS Ahmad Fatoum
@ 2022-07-13  9:57 ` Ahmad Fatoum
  2022-07-13  9:57 ` [PATCH v2 5/6] pbl: compressed-dtb: use flexible array member to access data Ahmad Fatoum
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2022-07-13  9:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

From: Ahmad Fatoum <ahmad@a3f.at>

We call lzop in two places: in gen-dtb-s to generate a compressed device
tree symbol and in Makefile.lib, which is used everywhere else.
Replace the duplication in gen-dtb-s by compressing the DT outside with
the existing cmd_lzo command. This will come in handy later when
extending gen-dtb-s to support multiple compression formats.

No functional change intended.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - new patch
---
 arch/arm/dts/Makefile  | 2 +-
 arch/mips/dts/Makefile | 2 +-
 scripts/Makefile.build | 4 ++--
 scripts/Makefile.lib   | 5 ++++-
 scripts/gen-dtb-s      | 8 ++------
 5 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 34192641dd1f..4e935a763260 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -199,4 +199,4 @@ lwl-$(CONFIG_MACH_TQMLS1046A) += fsl-tqmls1046a-mbls10xxa.dtb.o
 lwl-$(CONFIG_MACH_ZEDBOARD) += zynq-zed.dtb.o
 lwl-$(CONFIG_MACH_MNT_REFORM) += imx8mq-mnt-reform2.dtb.o
 
-clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.lzo
+clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.z
diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile
index e4cc3b44a53e..d99c4c63584d 100644
--- a/arch/mips/dts/Makefile
+++ b/arch/mips/dts/Makefile
@@ -18,4 +18,4 @@ pbl-$(CONFIG_BOARD_RZX50) += rzx50.dtb.o
 pbl-$(CONFIG_BOARD_TPLINK_MR3020) += ar9331_tl_mr3020.dtb.o
 pbl-$(CONFIG_BOARD_TPLINK_WDR4300) += ar9344-tl-wdr4300-v1.7.dtb.o
 
-clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.lzo
+clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.z
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 1614a1ac58f8..216f03677bd1 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -262,8 +262,8 @@ intermediate_targets = $(foreach sfx, $(2), \
 # %.lex.o <- %.lex.c <- %.l
 # %.tab.o <- %.tab.[ch] <- %.y
 targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \
-	   $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \
-	   $(call intermediate_targets, .dtb.pbl.o, .dtb.S .dtb) \
+	   $(call intermediate_targets, .dtb.o, .dtb.S .dtb.z .dtb) \
+	   $(call intermediate_targets, .dtb.pbl.o, .dtb.S .dtb.z .dtb) \
 	   $(call intermediate_targets, .lex.o, .lex.c) \
 	   $(call intermediate_targets, .tab.o, .tab.c .tab.h)
 
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a830364a8bab..c2301b5370da 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -333,9 +333,12 @@ 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) > $@
-$(obj)/%.dtb.S: $(obj)/%.dtb $(srctree)/scripts/gen-dtb-s FORCE
+$(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)
+
 dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS))
 quiet_cmd_dtc = DTC     $@
 # For compatibility between make 4.2 and 4.3
diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
index 868d434664ec..eadf4d76f313 100755
--- a/scripts/gen-dtb-s
+++ b/scripts/gen-dtb-s
@@ -51,11 +51,7 @@ echo "__dtb_${name}_end:"
 echo ".global __dtb_${name}_end"
 echo ".balign STRUCT_ALIGNMENT"
 
-lzop -f -9 $dtb -o $dtb.lzo
-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.z)
 uncompressed=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $dtb)
 
 echo "#if defined(CONFIG_USE_COMPRESSED_DTB) && defined(__PBL__)"
@@ -66,7 +62,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.z\""
 echo "__dtb_z_${name}_end:"
 echo ".global __dtb_z_${name}_end"
 echo ".balign STRUCT_ALIGNMENT"
-- 
2.30.2




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

* [PATCH v2 5/6] pbl: compressed-dtb: use flexible array member to access data
  2022-07-13  9:57 [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2022-07-13  9:57 ` [PATCH v2 4/6] kbuild: gen-dtb-s: use Makefile.lib instead of duplicating cmd_lzo Ahmad Fatoum
@ 2022-07-13  9:57 ` Ahmad Fatoum
  2022-07-13  9:57 ` [PATCH v2 6/6] kbuild: pbl: use same compression algo for both barebox and DTB Ahmad Fatoum
  2022-07-14  8:08 ` [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Sascha Hauer
  5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2022-07-13  9:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

While data = compressed_dtb + 1 has the equivalent effect of skipping
over the struct barebox_boarddata_compressed_dtb header, using a
flexible array member aids code readability, so use that instead.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - new patch
---
 arch/arm/cpu/start.c     | 7 ++-----
 arch/riscv/boot/start.c  | 6 ++----
 include/compressed-dtb.h | 1 +
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 14cc310312ab..755d48851956 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -52,7 +52,6 @@ u32 barebox_arm_machine(void)
 void *barebox_arm_boot_dtb(void)
 {
 	void *dtb;
-	void *data;
 	int ret;
 	struct barebox_boarddata_compressed_dtb *compressed_dtb;
 	static void *boot_dtb;
@@ -76,10 +75,8 @@ void *barebox_arm_boot_dtb(void)
 	if (!dtb)
 		return NULL;
 
-	data = compressed_dtb + 1;
-
-	ret = uncompress(data, compressed_dtb->datalen, NULL, NULL,
-			dtb, NULL, NULL);
+	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/arch/riscv/boot/start.c b/arch/riscv/boot/start.c
index 72ab93cb7691..8b4c8bb2f019 100644
--- a/arch/riscv/boot/start.c
+++ b/arch/riscv/boot/start.c
@@ -32,7 +32,6 @@ unsigned barebox_riscv_pbl_flags;
 void *barebox_riscv_boot_dtb(void)
 {
 	void *dtb;
-	void *data;
 	int ret;
 	struct barebox_boarddata_compressed_dtb *compressed_dtb;
 	static void *boot_dtb;
@@ -56,9 +55,8 @@ void *barebox_riscv_boot_dtb(void)
 	if (!dtb)
 		return NULL;
 
-	data = compressed_dtb + 1;
-
-	ret = uncompress(data, compressed_dtb->datalen, NULL, NULL, dtb, NULL, NULL);
+	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/include/compressed-dtb.h b/include/compressed-dtb.h
index 1ba98a7e2b92..3359d1ee115d 100644
--- a/include/compressed-dtb.h
+++ b/include/compressed-dtb.h
@@ -10,6 +10,7 @@ struct barebox_boarddata_compressed_dtb {
 	u32 magic;
 	u32 datalen;
 	u32 datalen_uncompressed;
+	u8 data[];
 };
 
 static inline bool blob_is_compressed_fdt(const void *blob)
-- 
2.30.2




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

* [PATCH v2 6/6] kbuild: pbl: use same compression algo for both barebox and DTB
  2022-07-13  9:57 [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Ahmad Fatoum
                   ` (3 preceding siblings ...)
  2022-07-13  9:57 ` [PATCH v2 5/6] pbl: compressed-dtb: use flexible array member to access data Ahmad Fatoum
@ 2022-07-13  9:57 ` Ahmad Fatoum
  2022-07-15 10:53   ` Sascha Hauer
  2022-07-14  8:08 ` [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Sascha Hauer
  5 siblings, 1 reply; 9+ messages in thread
From: Ahmad Fatoum @ 2022-07-13  9:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

From: Ahmad Fatoum <ahmad@a3f.at>

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@pengutronix.de>
---
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




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

* Re: [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again
  2022-07-13  9:57 [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Ahmad Fatoum
                   ` (4 preceding siblings ...)
  2022-07-13  9:57 ` [PATCH v2 6/6] kbuild: pbl: use same compression algo for both barebox and DTB Ahmad Fatoum
@ 2022-07-14  8:08 ` Sascha Hauer
  5 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2022-07-14  8:08 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Wed, Jul 13, 2022 at 11:57:25AM +0200, Ahmad Fatoum wrote:
> For barebox with a prebootloader, we can compress barebox proper as a
> whole and it makes no sense to compress the environment on its own
> again. The choice already defaulted to this, but the user could still
> override it. Ensure that this double compression can't happen.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> v1 -> v2:
>   - no change
> ---
>  common/Kconfig | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/common/Kconfig b/common/Kconfig
> index 2292e7bcea46..6278866006b1 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -860,29 +860,30 @@ choice
>  	default DEFAULT_COMPRESSION_LZ4 if LZ4_DECOMPRESS
>  	default DEFAULT_COMPRESSION_BZIP2 if BZLIB
>  	help
> -	  Select the default compression for in-barebox binary files. Files
> -	  compiled into barebox like for example the default environment will
> -	  be compressed with this compression type.
> +	  For barebox builds without a prebootloader, select here the default
> +	  compression for in-barebox binary files. barebox itself can't be
> +	  compressed without a prebootloader, but for example the default
> +	  environment will be compressed with this compression type.
>  
>  config DEFAULT_COMPRESSION_GZIP
>  	bool "gzip"
> -	depends on ZLIB
> +	depends on !PBL_IMAGE && ZLIB
>  
>  config DEFAULT_COMPRESSION_BZIP2
>  	bool "bzip2"
> -	depends on BZLIB
> +	depends on !PBL_IMAGE && BZLIB
>  
>  config DEFAULT_COMPRESSION_LZO
>  	bool "lzo"
> -	depends on LZO_DECOMPRESS
> +	depends on !PBL_IMAGE && LZO_DECOMPRESS
>  
>  config DEFAULT_COMPRESSION_LZ4
>  	bool "lz4"
> -	depends on LZ4_DECOMPRESS
> +	depends on !PBL_IMAGE && LZ4_DECOMPRESS
>  
>  config DEFAULT_COMPRESSION_XZ
>  	bool "xz"
> -	depends on XZ_DECOMPRESS
> +	depends on !PBL_IMAGE && XZ_DECOMPRESS
>  
>  config DEFAULT_COMPRESSION_NONE
>  	bool "no compression"
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH v2 6/6] kbuild: pbl: use same compression algo for both barebox and DTB
  2022-07-13  9:57 ` [PATCH v2 6/6] kbuild: pbl: use same compression algo for both barebox and DTB Ahmad Fatoum
@ 2022-07-15 10:53   ` Sascha Hauer
  2022-07-15 15:57     ` [PATCH] fixup! " Ahmad Fatoum
  0 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2022-07-15 10:53 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

Hi Ahmad,

On Wed, Jul 13, 2022 at 11:57:30AM +0200, Ahmad Fatoum wrote:
> From: Ahmad Fatoum <ahmad@a3f.at>
> 
> 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@pengutronix.de>
> ---
> 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(-)

This patch breaks compilation of virt2real_defconfig:

/bin/sh: 1: Syntax error: ";" unexpected
make[1]: *** [scripts/Makefile.lib:349: arch/arm/dts/virt2real.dtb.z] Error 2
make: *** [Makefile:953: arch/arm/dts] Error 2
make: *** Waiting for unfinished jobs....

I haven't looked into it yet.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* [PATCH] fixup! kbuild: pbl: use same compression algo for both barebox and DTB
  2022-07-15 10:53   ` Sascha Hauer
@ 2022-07-15 15:57     ` Ahmad Fatoum
  0 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2022-07-15 15:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

scripts: Makefile.lib: fix build for non-PBL DT-enabled boards

CONFIG_IMAGE_COMPRESSION_NONE is unset for non-PBL builds, leading to a
build failure for non-PBL boards that reference device trees.
Fix this by having comp_copy as default.

Reported-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 scripts/Makefile.lib | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a648835b1bfb..9295f22e9fef 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -275,6 +275,7 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
 # Decompressor for barebox proper binary when using PBL
 # ---------------------------------------------------------------------------
 
+suffix_y = comp_copy
 suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip
 suffix_$(CONFIG_IMAGE_COMPRESSION_LZO)  = lzo
 suffix_$(CONFIG_IMAGE_COMPRESSION_LZ4)	= lz4
-- 
2.30.2




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

end of thread, other threads:[~2022-07-15 15:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13  9:57 [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Ahmad Fatoum
2022-07-13  9:57 ` [PATCH v2 2/6] pbl: make USE_COMPRESSED_DTB a PBL-only feature Ahmad Fatoum
2022-07-13  9:57 ` [PATCH v2 3/6] pbl: remove redundant select UNCOMRPESS Ahmad Fatoum
2022-07-13  9:57 ` [PATCH v2 4/6] kbuild: gen-dtb-s: use Makefile.lib instead of duplicating cmd_lzo Ahmad Fatoum
2022-07-13  9:57 ` [PATCH v2 5/6] pbl: compressed-dtb: use flexible array member to access data Ahmad Fatoum
2022-07-13  9:57 ` [PATCH v2 6/6] kbuild: pbl: use same compression algo for both barebox and DTB Ahmad Fatoum
2022-07-15 10:53   ` Sascha Hauer
2022-07-15 15:57     ` [PATCH] fixup! " Ahmad Fatoum
2022-07-14  8:08 ` [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Sascha Hauer

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