load_simple_fit() open-codes gzip and lzma in two places, so a FIT built with any of the other five algorithms image_decomp() implements is silently copied to its load address without decompression and jumped into, causing a hang with nothing on the console to aid debugging.
Call image_decomp() instead, which can handle all compression algorigthms enabled in the config, and will abort on an unknown one instead of trying to silently jump into it. Signed-off-by: Alexey Charkov <[email protected]> --- common/spl/spl_fit.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index e02c746af5d3..9a93487bf0b2 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -6,7 +6,6 @@ #include <errno.h> #include <fpga.h> -#include <gzip.h> #include <image.h> #include <log.h> #include <memalign.h> @@ -260,7 +259,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset, ulong load_addr; void *load_ptr; void *src; - uint8_t image_comp = -1, type = -1; + u8 image_comp = IH_COMP_NONE, type = IH_TYPE_INVALID; const void *data; const void *fit = ctx->fit; bool external_data = false; @@ -364,8 +363,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset, } read_offset = fit_offset + aligned_offset; - if (spl_decompression_enabled() && - (image_comp == IH_COMP_GZIP || image_comp == IH_COMP_LZMA)) + if (image_comp != IH_COMP_NONE) 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); @@ -429,25 +427,18 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset, if (CONFIG_IS_ENABLED(FIT_IMAGE_POST_PROCESS)) 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; - } - length = size; - } else if (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA) { - size = CONFIG_SYS_BOOTM_LEN; - ulong loadEnd; + if (image_comp != IH_COMP_NONE) { + ulong load_end; - if (image_decomp(IH_COMP_LZMA, CONFIG_SYS_LOAD_ADDR, 0, 0, - load_ptr, src, length, size, &loadEnd)) { + load_ptr = map_sysmem(load_addr, max_size); + if (image_decomp(image_comp, load_addr, (ulong)src, type, + load_ptr, src, length, max_size, &load_end)) { puts("Uncompressing error\n"); return -EIO; } - length = loadEnd - CONFIG_SYS_LOAD_ADDR; + length = load_end - load_addr; } else { + load_ptr = map_sysmem(load_addr, length); memmove(load_ptr, src, length); } -- 2.55.0
