mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-29 17:55:48 +00:00
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>
This commit is contained in:
parent
d1f2ee7021
commit
7264f2928b
3 changed files with 45 additions and 4 deletions
|
@ -11,6 +11,10 @@
|
||||||
#include <libfdt.h>
|
#include <libfdt.h>
|
||||||
#include <spl.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,
|
* 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
|
* 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;
|
ulong overhead;
|
||||||
int nr_sectors;
|
int nr_sectors;
|
||||||
int align_len = ARCH_DMA_MINALIGN - 1;
|
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");
|
offset = fdt_getprop_u32(fit, node, "data-offset");
|
||||||
if (offset == FDT_ERROR)
|
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),
|
if (info->read(info, sector + get_aligned_image_offset(info, offset),
|
||||||
nr_sectors, (void*)load_ptr) != nr_sectors)
|
nr_sectors, (void*)load_ptr) != nr_sectors)
|
||||||
return -EIO;
|
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);
|
(unsigned long)length);
|
||||||
|
|
||||||
src = (void *)load_ptr + overhead;
|
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);
|
board_fit_image_post_process(&src, &length);
|
||||||
#endif
|
#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) {
|
if (image_info) {
|
||||||
image_info->load_addr = load_addr;
|
image_info->load_addr = load_addr;
|
||||||
|
|
12
lib/Kconfig
12
lib/Kconfig
|
@ -176,6 +176,18 @@ config LZO
|
||||||
bool "Enable LZO decompression support"
|
bool "Enable LZO decompression support"
|
||||||
help
|
help
|
||||||
This enables support for LZO compression algorithm.r
|
This enables support for LZO compression algorithm.r
|
||||||
|
|
||||||
|
config SPL_GZIP
|
||||||
|
bool "Enable gzip decompression support for SPL build"
|
||||||
|
select SPL_ZLIB
|
||||||
|
help
|
||||||
|
This enables support for GZIP compression altorithm for SPL boot.
|
||||||
|
|
||||||
|
config SPL_ZLIB
|
||||||
|
bool
|
||||||
|
help
|
||||||
|
This enables compression lib for SPL boot.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
config ERRNO_STR
|
config ERRNO_STR
|
||||||
|
|
|
@ -11,7 +11,6 @@ obj-$(CONFIG_EFI) += efi/
|
||||||
obj-$(CONFIG_EFI_LOADER) += efi_loader/
|
obj-$(CONFIG_EFI_LOADER) += efi_loader/
|
||||||
obj-$(CONFIG_LZMA) += lzma/
|
obj-$(CONFIG_LZMA) += lzma/
|
||||||
obj-$(CONFIG_LZO) += lzo/
|
obj-$(CONFIG_LZO) += lzo/
|
||||||
obj-$(CONFIG_ZLIB) += zlib/
|
|
||||||
obj-$(CONFIG_BZIP2) += bzip2/
|
obj-$(CONFIG_BZIP2) += bzip2/
|
||||||
obj-$(CONFIG_TIZEN) += tizen/
|
obj-$(CONFIG_TIZEN) += tizen/
|
||||||
obj-$(CONFIG_FIT) += libfdt/
|
obj-$(CONFIG_FIT) += libfdt/
|
||||||
|
@ -26,7 +25,6 @@ obj-y += crc16.o
|
||||||
obj-$(CONFIG_ERRNO_STR) += errno_str.o
|
obj-$(CONFIG_ERRNO_STR) += errno_str.o
|
||||||
obj-$(CONFIG_FIT) += fdtdec_common.o
|
obj-$(CONFIG_FIT) += fdtdec_common.o
|
||||||
obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
|
obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
|
||||||
obj-$(CONFIG_GZIP) += gunzip.o
|
|
||||||
obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
|
obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
|
||||||
obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
|
obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
|
||||||
obj-y += initcall.o
|
obj-y += initcall.o
|
||||||
|
@ -49,6 +47,9 @@ obj-$(CONFIG_RSA) += rsa/
|
||||||
obj-$(CONFIG_SHA1) += sha1.o
|
obj-$(CONFIG_SHA1) += sha1.o
|
||||||
obj-$(CONFIG_SHA256) += sha256.o
|
obj-$(CONFIG_SHA256) += sha256.o
|
||||||
|
|
||||||
|
obj-$(CONFIG_$(SPL_)ZLIB) += zlib/
|
||||||
|
obj-$(CONFIG_$(SPL_)GZIP) += gunzip.o
|
||||||
|
|
||||||
obj-$(CONFIG_$(SPL_TPL_)SAVEENV) += qsort.o
|
obj-$(CONFIG_$(SPL_TPL_)SAVEENV) += qsort.o
|
||||||
obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += libfdt/
|
obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += libfdt/
|
||||||
ifneq ($(CONFIG_$(SPL_TPL_)BUILD)$(CONFIG_$(SPL_TPL_)OF_PLATDATA),yy)
|
ifneq ($(CONFIG_$(SPL_TPL_)BUILD)$(CONFIG_$(SPL_TPL_)OF_PLATDATA),yy)
|
||||||
|
|
Loading…
Add table
Reference in a new issue