]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spl: fit: support for booting a LZMA-compressed U-boot binary
authorManoj Sai <abbaraju.manojsai@amarulasolutions.com>
Sun, 17 Sep 2023 19:26:26 +0000 (00:56 +0530)
committerKever Yang <kever.yang@rock-chips.com>
Sat, 7 Oct 2023 08:49:41 +0000 (16:49 +0800)
If LZMA Compression support is enabled, LZMA compressed U-Boot
binary will be placed at a specified RAM location which is
defined at CONFIG_SYS_LOAD_ADDR and will be assigned  as the
source address.

image_decomp() function, will decompress the LZMA compressed
U-Boot binary which is placed at source address(CONFIG_SYS_LOAD_ADDR)
to the default CONFIG_SYS_TEXT_BASE location.

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

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
common/spl/spl_fit.c
include/spl.h

index 0d28701a11582648e8ace768407fada8b6d5bc77..e567fe268f35b73fd39c74370c8f23acf19863ed 100644 (file)
@@ -282,7 +282,8 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
                        return 0;
                }
 
-               if (spl_decompression_enabled() && image_comp == IH_COMP_GZIP)
+               if (spl_decompression_enabled() &&
+                   (image_comp == IH_COMP_GZIP || image_comp == IH_COMP_LZMA))
                        src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
                else
                        src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
@@ -330,6 +331,16 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
                        return -EIO;
                }
                length = size;
+       } else if (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA) {
+               size = CONFIG_SYS_BOOTM_LEN;
+               ulong loadEnd;
+
+               if (image_decomp(IH_COMP_LZMA, CONFIG_SYS_LOAD_ADDR, 0, 0,
+                                load_ptr, src, length, size, &loadEnd)) {
+                       puts("Uncompressing error\n");
+                       return -EIO;
+               }
+               length = loadEnd - CONFIG_SYS_LOAD_ADDR;
        } else {
                memcpy(load_ptr, src, length);
        }
index 320ed942739a08b5ad3f22feacd399f8d88e8fef..f62f385afaf611e5a21e099a5627e8740bc92bbb 100644 (file)
@@ -905,6 +905,6 @@ void spl_save_restore_data(void);
  */
 static inline bool spl_decompression_enabled(void)
 {
-       return IS_ENABLED(CONFIG_SPL_GZIP);
+       return IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA);
 }
 #endif