[PATCH 7/9] firmware: Add fwobj_uncompress() for decompressing firmware in PBL

Sascha Hauer s.hauer at pengutronix.de
Mon Mar 16 10:21:20 PDT 2026


From: Sascha Hauer <sascha at saschahauer.de>

Add fwobj_uncompress() which decompresses a firmware object into a
destination buffer. This pairs with get_builtin_firmware_compressed()
to provide a simple API for loading compressed firmware in PBL context.

Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 include/firmware.h | 2 ++
 pbl/decomp.c       | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/include/firmware.h b/include/firmware.h
index 2f75ded82b..07651f1a93 100644
--- a/include/firmware.h
+++ b/include/firmware.h
@@ -121,6 +121,8 @@ struct fwobj {
 #define get_builtin_firmware_ext(name, base, fwobj)			\
 	__get_builtin_firmware(name, (long)base - (long)_text, fwobj)
 
+int fwobj_uncompress(struct fwobj *fwobj, void *dest);
+
 #define get_builtin_firmware_compressed(name, fwobj)			\
 	do {								\
 		extern char _fw_z_##name##_start[];			\
diff --git a/pbl/decomp.c b/pbl/decomp.c
index 532e9d460f..1539a6b67e 100644
--- a/pbl/decomp.c
+++ b/pbl/decomp.c
@@ -9,6 +9,7 @@
 #include <crypto/sha.h>
 #include <crypto/pbl-sha.h>
 #include <digest.h>
+#include <firmware.h>
 #include <asm/sections.h>
 #include <pbl.h>
 #include <debug_ll.h>
@@ -116,3 +117,9 @@ int pbl_dtbz_uncompress(void *dest, void *compressed_start, unsigned long len)
 	return decompress(compressed_start, len, NULL, NULL, dest, NULL,
 			  errorfn);
 }
+
+int fwobj_uncompress(struct fwobj *fwobj, void *dest)
+{
+	return decompress(fwobj->data, fwobj->size, NULL, NULL, dest, NULL,
+			  errorfn);
+}

-- 
2.47.3




More information about the barebox mailing list