From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/3] scripts: gen-dtb-s: fallback to LZ4 if lzop is unavailable
Date: Mon, 11 Jul 2022 15:15:55 +0200 [thread overview]
Message-ID: <20220711131556.2122028-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220711131556.2122028-1-a.fatoum@pengutronix.de>
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@pengutronix.de>
---
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
next prev parent 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 [PATCH 1/3] kbuild: gen-dtb-s: refactor to allow different compression methods Ahmad Fatoum
2022-07-11 13:15 ` Ahmad Fatoum [this message]
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-2-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