[PATCH 04/10] spl: fit: support for booting a GZIP-compressed U-boot raw binary

Manoj Sai abbaraju.manojsai at amarulasolutions.com
Fri Jun 30 14:11:40 CEST 2023


If GZIP Compression support is enabled, GZIP compressed U-Boot raw binary will
be at a specified RAM location which is defined at
UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR  and will be assign it as
the source address.

gunzip function in spl_load_fit_image ,will decompress the GZIP compressed
U-Boot raw binary which is placed at source address to the default
CONFIG_SYS_TEXT_BASE location.

spl_load_fit_image function will load the decompressed U-Boot
raw binary, which is placed at the CONFIG_SYS_TEXT_BASE location.

Signed-off-by: Manoj Sai <abbaraju.manojsai at amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil at amarulasolutions.com>
---
 common/spl/spl_fit.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 730639f756..e2101099ef 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -281,7 +281,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return 0;
 		}
 
-		src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
+		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
+			src_ptr = map_sysmem(ALIGN(CONFIG_VAL(UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR),
+						ARCH_DMA_MINALIGN), len);
+		} else {
+			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
+		}
 		length = len;
 
 		overhead = get_aligned_image_overhead(info, offset);
@@ -319,11 +324,14 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 		board_fit_image_post_process(fit, node, &src, &length);
 
 	load_ptr = map_sysmem(load_addr, length);
-	if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) {
-		size = length;
-		if (gunzip(load_ptr, CONFIG_SYS_BOOTM_LEN, src, &size)) {
-			puts("Uncompressing error\n");
-			return -EIO;
+
+	if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
+		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
+			size = length;
+			if (gunzip(load_ptr, CONFIG_SYS_BOOTM_LEN, src, &size)) {
+				puts("Uncompressing error\n");
+				return -EIO;
+			}
 		}
 		length = size;
 	} else {
-- 
2.25.1



More information about the U-Boot mailing list