summaryrefslogtreecommitdiff
path: root/common/image-android.c
diff options
context:
space:
mode:
authorRoman Stratiienko <roman.stratiienko@globallogic.com>2019-06-03 15:38:13 +0300
committerTom Rini <trini@konsulko.com>2019-07-24 13:16:29 -0400
commit39f790b03ace5b1b7861b154b195eabbe344cfa1 (patch)
tree3e604614875a9877c3b959685cc6d43640df929f /common/image-android.c
parentdfaad8208f069f95d35f52c4cc69b1a05cd60f75 (diff)
image: android: allow to wrap uImage into the Android boot image
This allows to use any available compression format with Android boot image Since not all available compression formats have a magic number we should explicitly specify type of compression. For this purpose using uImage format becomes very useful, as this format is well-known by the community and mkimage tool is already available. Usage example: mkimage -A ARM64 -T kernel -C lzma -d Image.lzma out/kernel At this moment only -C option is handled, but specifying -A and -T options are recommended for compatibility reasons in the future. Kernel that compressed with LZ4 can be already used without wrapping into the uImage, but I recommend wrapping it into the uImage in order to avoid situations when by some mistake legacy LZ4 is used, that is interpreted as raw Image and causes CPU to enter Exception Handler without providing any meaningful explanation to the user. Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Diffstat (limited to 'common/image-android.c')
-rw-r--r--common/image-android.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/common/image-android.c b/common/image-android.c
index 8b0f6b3b8b..6c9568a655 100644
--- a/common/image-android.c
+++ b/common/image-android.c
@@ -52,6 +52,8 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
ulong *os_data, ulong *os_len)
{
u32 kernel_addr = android_image_get_kernel_addr(hdr);
+ const struct image_header *ihdr = (const struct image_header *)
+ ((uintptr_t)hdr + hdr->page_size);
/*
* Not all Android tools use the id field for signing the image with
@@ -93,11 +95,19 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
env_set("bootargs", newbootargs);
if (os_data) {
- *os_data = (ulong)hdr;
- *os_data += hdr->page_size;
+ if (image_get_magic(ihdr) == IH_MAGIC) {
+ *os_data = image_get_data(ihdr);
+ } else {
+ *os_data = (ulong)hdr;
+ *os_data += hdr->page_size;
+ }
+ }
+ if (os_len) {
+ if (image_get_magic(ihdr) == IH_MAGIC)
+ *os_len = image_get_data_size(ihdr);
+ else
+ *os_len = hdr->kernel_size;
}
- if (os_len)
- *os_len = hdr->kernel_size;
return 0;
}
@@ -131,7 +141,9 @@ 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)
+ if (image_get_magic((image_header_t *)p) == IH_MAGIC)
+ return image_get_comp((image_header_t *)p);
+ else if (get_unaligned_le32(p) == LZ4F_MAGIC)
return IH_COMP_LZ4;
else
return IH_COMP_NONE;