From 829ceb28215a1b6178bf690182def5ad56842f49 Mon Sep 17 00:00:00 2001 From: Eugeniu Rosca Date: Mon, 8 Apr 2019 17:35:27 +0200 Subject: image: android: allow booting lz4-compressed kernels According to Android image format [1], kernel image resides at 1 page offset from the boot image address. Grab the magic number from there and allow U-Boot to handle LZ4-compressed KNL binaries instead of hardcoding compression type to IH_COMP_NONE. Other compression types, if needed, can be added later. Tested on H3ULCB-KF using the image detailed in [2]. [1] Excerpt from include/android_image.h +-----------------+ | boot header | 1 page +-----------------+ | kernel | n pages +-----------------+ | ramdisk | m pages +-----------------+ | second stage | o pages +-----------------+ [2] => iminfo 4c000000 ## Checking Image at 4c000000 ... Android image found kernel size: 85b9d1 kernel address: 48080000 ramdisk size: 54ddbc ramdisk addrress: 4a180000 second size: 0 second address: 48000800 tags address: 48000100 page size: 800 os_version: 1200012a (ver: 0.9.0, level: 2018.10) name: cmdline: buildvariant=userdebug Signed-off-by: Eugeniu Rosca --- common/image-android.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'common/image-android.c') diff --git a/common/image-android.c b/common/image-android.c index 2f38c191e9..c31dcd4465 100644 --- a/common/image-android.c +++ b/common/image-android.c @@ -8,6 +8,7 @@ #include #include #include +#include #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000 @@ -126,6 +127,16 @@ ulong android_image_get_kload(const struct andr_img_hdr *hdr) return android_image_get_kernel_addr(hdr); } +ulong android_image_get_kcomp(const struct andr_img_hdr *hdr) +{ + const void *p = (void *)((uintptr_t)hdr + hdr->page_size); + + if (get_unaligned_le32(p) == LZ4F_MAGIC) + return IH_COMP_LZ4; + else + return IH_COMP_NONE; +} + int android_image_get_ramdisk(const struct andr_img_hdr *hdr, ulong *rd_data, ulong *rd_len) { -- cgit From 74a7e0018a97a0e7318c4c7a3b473fd9ebbb5ad1 Mon Sep 17 00:00:00 2001 From: Eugeniu Rosca Date: Mon, 8 Apr 2019 17:35:28 +0200 Subject: image: android: fix 'iminfo' typo Fix below CP warning triggered by the 'iminfo' output in another patch: WARNING: 'addrress' may be misspelled - perhaps 'address'? Fixes: 4f1318b29c7a20 ("common: image: minimal android image iminfo support") Signed-off-by: Eugeniu Rosca Acked-by: Marek Vasut --- common/image-android.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/image-android.c') diff --git a/common/image-android.c b/common/image-android.c index c31dcd4465..8b0f6b3b8b 100644 --- a/common/image-android.c +++ b/common/image-android.c @@ -197,7 +197,7 @@ void android_print_contents(const struct andr_img_hdr *hdr) printf("%skernel size: %x\n", p, hdr->kernel_size); printf("%skernel address: %x\n", p, hdr->kernel_addr); printf("%sramdisk size: %x\n", p, hdr->ramdisk_size); - printf("%sramdisk addrress: %x\n", p, hdr->ramdisk_addr); + printf("%sramdisk address: %x\n", p, hdr->ramdisk_addr); printf("%ssecond size: %x\n", p, hdr->second_size); printf("%ssecond address: %x\n", p, hdr->second_addr); printf("%stags address: %x\n", p, hdr->tags_addr); -- cgit