mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/4] RISC-V: fix crash on start if CONFIG_IMAGE_COMPRESSION_NONE=y
Date: Fri,  7 Jun 2024 03:12:57 +0300	[thread overview]
Message-ID: <20240607001259.107805-3-antonynpavlov@gmail.com> (raw)
In-Reply-To: <20240607001259.107805-1-antonynpavlov@gmail.com>

Use the same approach as ARM barebox uses.

See also 6c03bdf8f99 ("kbuild: pbl: use same compression algo for both
barebox and DTB").

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/riscv/boot/start.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/boot/start.c b/arch/riscv/boot/start.c
index 2e18105bbfb..ab9bb6f320f 100644
--- a/arch/riscv/boot/start.c
+++ b/arch/riscv/boot/start.c
@@ -35,7 +35,7 @@ static unsigned long barebox_boarddata_size;
 void *barebox_riscv_boot_dtb(void)
 {
 	void *dtb;
-	int ret;
+	int ret = 0;
 	struct barebox_boarddata_compressed_dtb *compressed_dtb;
 	static void *boot_dtb;
 
@@ -58,8 +58,13 @@ void *barebox_riscv_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);
-- 
2.39.0




  parent reply	other threads:[~2024-06-07  0:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07  0:12 [PATCH 0/4] pbl and debug_ll fixes Antony Pavlov
2024-06-07  0:12 ` [PATCH 1/4] pbl: enable image verification for MIPS and RISC-V too Antony Pavlov
2024-06-07  0:12 ` Antony Pavlov [this message]
2024-06-07  0:12 ` [PATCH 3/4] ARM: bcm283x: fix compilation with debug_ll enabled Antony Pavlov
2024-06-07  0:12 ` [PATCH 4/4] ARM: vexpress: make debug_ll work Antony Pavlov
2024-06-07  6:24   ` Antony Pavlov
2024-06-10 12:28     ` Sascha Hauer
2024-06-10 12:25 ` [PATCH 0/4] pbl and debug_ll fixes Sascha Hauer

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=20240607001259.107805-3-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=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