[PATCH 2/3] scripts: gen-dtb-s: fallback to LZ4 if lzop is unavailable

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

 



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

As a fallback, use LZ4 as compression if lzop is not available.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 common/Kconfig    | 7 ++++++-
 scripts/gen-dtb-s | 6 ++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index 076fe455f8ac..f1f0b4fab91c 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+source "scripts/Kconfig.include"
 source "common/boards/Kconfig"
 
 config GREGORIAN_CALENDER
@@ -46,10 +47,14 @@ config USE_COMPRESSED_DTB
 	depends on ARM || RISCV
 	select UNCOMPRESS
 	select LZO_DECOMPRESS if DTB_COMPRESSION = "lzo"
+	select LZ4_DECOMPRESS if DTB_COMPRESSION = "lz4"
 
 config DTB_COMPRESSION
 	string
-	default "lzo"
+	default "none" if !USE_COMPRESSED_DTB
+	default "lzo" if $(success,lzop -V)
+	default "lz4" if $(success,lz4c -V)
+	default "none"
 
 config FILETYPE
 	bool
diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
index da0b593da4eb..1d70f260f677 100755
--- a/scripts/gen-dtb-s
+++ b/scripts/gen-dtb-s
@@ -59,6 +59,12 @@ case $compression in
 	lzo)
 		lzop -f -9 $dtb -o $dtb.$compression
 		;;
+	lz4)
+		lz4c -fql $dtb $dtb.$compression
+		# LZ4 decompressor strips away last 4 bytes, but doesn't
+		# consume them, so increase size accordingly
+		printf '\0\0\0\0' >>$dtb.$compression
+		;;
 	*)
 		echo Unsupported compression algorithm: $compression >&2
 		exit 1
-- 
2.30.2





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

  Powered by Linux