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

gunzip function in spl_load_fit_image ,will decompress the GZIP
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: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
common/spl/spl_fit.c
include/spl.h

index b1668c0396cdd5fccadd58ee7b1415831ce76281..0d28701a11582648e8ace768407fada8b6d5bc77 100644 (file)
@@ -240,14 +240,14 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
        bool external_data = false;
 
        if (IS_ENABLED(CONFIG_SPL_FPGA) ||
-           (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP))) {
+           (IS_ENABLED(CONFIG_SPL_OS_BOOT) && spl_decompression_enabled())) {
                if (fit_image_get_type(fit, node, &type))
                        puts("Cannot get image type.\n");
                else
                        debug("%s ", genimg_get_type_name(type));
        }
 
-       if (IS_ENABLED(CONFIG_SPL_GZIP)) {
+       if (spl_decompression_enabled()) {
                fit_image_get_comp(fit, node, &image_comp);
                debug("%s ", genimg_get_comp_name(image_comp));
        }
@@ -282,7 +282,10 @@ 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 (spl_decompression_enabled() && image_comp == IH_COMP_GZIP)
+                       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);
                length = len;
 
                overhead = get_aligned_image_overhead(info, offset);
index 0fedddd00ef412d322ccfc63b7cd0492834bc210..320ed942739a08b5ad3f22feacd399f8d88e8fef 100644 (file)
@@ -897,4 +897,14 @@ struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
 
 void board_boot_order(u32 *spl_boot_list);
 void spl_save_restore_data(void);
+
+/*
+ * spl_decompression_enabled() - check decompression support is enabled for SPL build
+ *
+ * Returns  true  if decompression support is enabled, else False
+ */
+static inline bool spl_decompression_enabled(void)
+{
+       return IS_ENABLED(CONFIG_SPL_GZIP);
+}
 #endif