summaryrefslogtreecommitdiff
path: root/common/spl
diff options
context:
space:
mode:
authorYork Sun <york.sun@nxp.com>2017-08-15 11:14:43 -0700
committerYork Sun <york.sun@nxp.com>2017-09-11 07:55:36 -0700
commit7264f2928b46c5f5685e39ed607652c8991e47b6 (patch)
treec60c73a6fb0c33399fbdb25c31e4f08741bef71a /common/spl
parentd1f2ee7021dc4a89f43e25f289747a27da0e930f (diff)
spl: fit: Eanble GZIP support for image decompression
Add Kconfig option SPL_GZIP and SPL_ZLIB to enable gunzip support for SPL boot, eg. falcon boot compressed kernel image. Signed-off-by: York Sun <york.sun@nxp.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/spl')
-rw-r--r--common/spl/spl_fit.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index d2a352ecbe..fe41ce02d2 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -11,6 +11,10 @@
#include <libfdt.h>
#include <spl.h>
+#ifndef CONFIG_SYS_BOOTM_LEN
+#define CONFIG_SYS_BOOTM_LEN (64 << 20)
+#endif
+
/**
* spl_fit_get_image_node(): By using the matching configuration subnode,
* retrieve the name of an image, specified by a property name and an index
@@ -135,6 +139,19 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
ulong overhead;
int nr_sectors;
int align_len = ARCH_DMA_MINALIGN - 1;
+ uint8_t image_comp = -1, type = -1;
+
+ if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) {
+ if (fit_image_get_comp(fit, node, &image_comp))
+ puts("Cannot get image compression format.\n");
+ else
+ debug("%s ", genimg_get_comp_name(image_comp));
+
+ if (fit_image_get_type(fit, node, &type))
+ puts("Cannot get image type.\n");
+ else
+ debug("%s ", genimg_get_type_name(type));
+ }
offset = fdt_getprop_u32(fit, node, "data-offset");
if (offset == FDT_ERROR)
@@ -154,7 +171,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
if (info->read(info, sector + get_aligned_image_offset(info, offset),
nr_sectors, (void*)load_ptr) != nr_sectors)
return -EIO;
- debug("image: dst=%lx, offset=%lx, size=%lx\n", load_ptr, offset,
+ debug("image dst=%lx, offset=%lx, size=%lx\n", load_ptr, offset,
(unsigned long)length);
src = (void *)load_ptr + overhead;
@@ -162,7 +179,18 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
board_fit_image_post_process(&src, &length);
#endif
- memcpy((void*)load_addr, src, length);
+ if (IS_ENABLED(CONFIG_SPL_OS_BOOT) &&
+ IS_ENABLED(CONFIG_SPL_GZIP) &&
+ image_comp == IH_COMP_GZIP &&
+ type == IH_TYPE_KERNEL) {
+ if (gunzip((void *)load_addr, CONFIG_SYS_BOOTM_LEN,
+ src, &length)) {
+ puts("Uncompressing error\n");
+ return -EIO;
+ }
+ } else {
+ memcpy((void *)load_addr, src, length);
+ }
if (image_info) {
image_info->load_addr = load_addr;