summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanshan zhang <sanshan.zhang@nxp.com>2017-06-08 10:41:38 +0800
committerChen Guoyin <guoyin.chen@nxp.com>2017-07-10 15:07:56 +0800
commit893ec7807779aa34ce49866f03e49c592fff9543 (patch)
treefa657c380ae0d34b1b186dbc38ef1d4cf84ba819
parente095bd4e264aa171bb7e91196ac82a989e7b9649 (diff)
downloadu-boot-imx-893ec7807779aa34ce49866f03e49c592fff9543.zip
u-boot-imx-893ec7807779aa34ce49866f03e49c592fff9543.tar.gz
u-boot-imx-893ec7807779aa34ce49866f03e49c592fff9543.tar.bz2
MA-9702-2 [Android] Enable booti for android arm64.
boot_addr_start for booti should be the addr of Image rather than boot.img, so need read Image into hdr->kernel_addr. change the offset for bootloader. booti do not call android_image_get_kernel to init android env. booti can't load boot.img, so it can't init android env. init android env through android_image_get_kernel. Change-Id: Ifb990ee9c5710ce7bd5fa9a0d4221dcb0e52d341 Signed-off-by: sanshan zhang <sanshan.zhang@nxp.com>
-rw-r--r--common/image-android.c12
-rw-r--r--drivers/usb/gadget/f_fastboot.c38
-rw-r--r--include/android_image.h12
-rw-r--r--include/image.h1
4 files changed, 57 insertions, 6 deletions
diff --git a/common/image-android.c b/common/image-android.c
index 66f4316..d2ad997 100644
--- a/common/image-android.c
+++ b/common/image-android.c
@@ -220,3 +220,15 @@ int android_image_get_fdt(const struct andr_img_hdr *hdr,
*fdt_len = hdr->second_size;
return 0;
}
+
+#define ARM64_IMAGE_MAGIC 0x644d5241
+bool image_arm64(void *images)
+{
+ struct header_image *ih;
+
+ ih = (struct header_image *)images;
+ debug("image magic: %x\n", ih->magic);
+ if (ih->magic == le32_to_cpu(ARM64_IMAGE_MAGIC))
+ return true;
+ return false;
+}
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index fdbf2f8..33cad88 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -41,6 +41,7 @@
#include <part.h>
#include <sparse_format.h>
#include <image-sparse.h>
+#include <image.h>
#include <asm/imx-common/boot_mode.h>
#ifdef CONFIG_ANDROID_RECOVERY
#include <recovery.h>
@@ -187,7 +188,11 @@ static struct usb_gadget_strings *fastboot_strings[] = {
#define ANDROID_MBR_OFFSET 0
#define ANDROID_MBR_SIZE 0x200
+#ifdef CONFIG_BOOTLOADER_OFFSET_33K
+#define ANDROID_BOOTLOADER_OFFSET 0x8400
+#else
#define ANDROID_BOOTLOADER_OFFSET 0x400
+#endif
#define ANDROID_BOOTLOADER_SIZE 0xFFC00
#define ANDROID_KERNEL_OFFSET 0x100000
#define ANDROID_KERNEL_SIZE 0x500000
@@ -1768,6 +1773,7 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int mmcc = -1;
struct andr_img_hdr *hdr = &boothdr;
ulong image_size;
+ bool check_image_arm64;
#ifdef CONFIG_SECURE_BOOT
#define IVT_SIZE 0x20
#define CSF_PAD_SIZE CONFIG_CSF_SIZE
@@ -1883,7 +1889,7 @@ use_given_ptn:
}
/* flush cache after read */
flush_cache((ulong)load_addr, bootimg_sectors * 512); /* FIXME */
-
+ check_image_arm64 = image_arm64(load_addr + hdr->page_size);
addr = load_addr;
#ifdef CONFIG_FASTBOOT_LOCK
int verifyresult = -1;
@@ -1919,6 +1925,17 @@ use_given_ptn:
#endif
sector = pte->start + (hdr->page_size / 512);
+ if (check_image_arm64) {
+ if (mmc->block_dev.block_read(dev_desc, sector,
+ (hdr->kernel_size / 512) + 1,
+ (void *)hdr->kernel_addr) < 0) {
+ printf("boota: mmc failed to read kernel\n");
+ goto fail;
+ }
+ flush_cache((ulong)hdr->kernel_addr, hdr->kernel_size);
+ android_image_get_kernel(hdr, 0, NULL, NULL);
+ addr = hdr->kernel_addr;
+ }
sector += ALIGN(hdr->kernel_size, hdr->page_size) / 512;
if (mmc->block_dev.block_read(dev_desc, sector,
(hdr->ramdisk_size / 512) + 1,
@@ -2038,15 +2055,24 @@ use_given_ptn:
char boot_addr_start[12];
char ramdisk_addr[25];
char fdt_addr[12];
-
- char *bootm_args[] = { "bootm", boot_addr_start, ramdisk_addr, fdt_addr};
+ char *boot_args[] = { NULL, boot_addr_start, ramdisk_addr, fdt_addr};
+ if (check_image_arm64)
+ boot_args[0] = "booti";
+ else
+ boot_args[0] = "bootm";
sprintf(boot_addr_start, "0x%lx", addr);
sprintf(ramdisk_addr, "0x%x:0x%x", hdr->ramdisk_addr, hdr->ramdisk_size);
sprintf(fdt_addr, "0x%x", hdr->second_addr);
-
- do_bootm(NULL, 0, 4, bootm_args);
-
+ if (check_image_arm64) {
+#ifdef CONFIG_CMD_BOOTI
+ do_booti(NULL, 0, 4, boot_args);
+#else
+ debug("please enable CONFIG_CMD_BOOTI when kernel are Image");
+#endif
+ } else {
+ do_bootm(NULL, 0, 4, boot_args);
+ }
/* This only happens if image is somehow faulty so we start over */
do_reset(NULL, 0, 0, NULL);
diff --git a/include/android_image.h b/include/android_image.h
index 094d60a..1c70bf8 100644
--- a/include/android_image.h
+++ b/include/android_image.h
@@ -66,4 +66,16 @@ struct andr_img_hdr {
* 6. if second_size != 0: jump to second_addr
* else: jump to kernel_addr
*/
+struct header_image {
+ uint32_t code0; /* Executable code */
+ uint32_t code1; /* Executable code */
+ uint64_t text_offset; /* Image load offset, LE */
+ uint64_t image_size; /* Effective Image size, LE */
+ uint64_t res1; /* reserved */
+ uint64_t res2; /* reserved */
+ uint64_t res3; /* reserved */
+ uint64_t res4; /* reserved */
+ uint32_t magic; /* Magic number */
+ uint32_t res5;
+};
#endif
diff --git a/include/image.h b/include/image.h
index dd4c8e3..54a5d8e 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1245,6 +1245,7 @@ int android_image_get_fdt(const struct andr_img_hdr *hdr,
ulong android_image_get_end(const struct andr_img_hdr *hdr);
ulong android_image_get_kload(const struct andr_img_hdr *hdr);
void android_print_contents(const struct andr_img_hdr *hdr);
+bool image_arm64(void *images);
#endif /* CONFIG_ANDROID_BOOT_IMAGE */