summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2016-03-10 10:48:24 +0800
committerYe Li <ye.li@nxp.com>2017-04-05 19:47:58 +0800
commitd0d678fd9bbe9b115e06107f392229104de9b233 (patch)
tree00fa17609ced1332e0ae12093dadd845f042275b /common
parente84160eaf5c057da45a227039c6f8a7911f43a82 (diff)
MLK-12527-2 android: Add FSL android fastboot support
Integrate the FSL android fastboot features into community's fastboot. 1. Use USB gadget g_dnl driver 2. Integrate the FSL SD/SATA/NAND flash operations, since the GPT and EFI partitions are not support by i.MX. 3. Add FDT support to community's android image. 4. Add a new boot command "boota" for android image boot. The boota implements to load ramdisk and fdt to their loading addresses specified in boot.img header, while bootm won't do it for android image. 5. Support the authentication of boot.img at the "load_addr" for both SD and NAND. 6. We use new configuration CONFIG_FSL_FASTBOOT for Freescale's fastboot with relevant header file "fsl_fastboot.h". While disabling the configuration, the community fastboot is used. 7. Overwrite the cmdline in boot.img by using bootargs saved in local environment. 8. Add recovery and reboot-bootloader support. Signed-off-by: Ye Li <ye.li@nxp.com> (cherry picked from commit 23d63ff185929fff5e392efc853d69b606ba081a)
Diffstat (limited to 'common')
-rw-r--r--common/board_r.c25
-rw-r--r--common/image-android.c41
-rw-r--r--common/image-fdt.c31
3 files changed, 92 insertions, 5 deletions
diff --git a/common/board_r.c b/common/board_r.c
index 5c9e6987b9..014dbff74c 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -7,6 +7,8 @@
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Marius Groeger <mgroeger@sysgo.de>
*
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
+ *
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -66,6 +68,9 @@
#include <asm/arch/mmu.h>
#endif
#include <efi_loader.h>
+#ifdef CONFIG_FSL_FASTBOOT
+#include <fsl_fastboot.h>
+#endif
DECLARE_GLOBAL_DATA_PTR;
@@ -717,6 +722,20 @@ static int initr_kbd(void)
}
#endif
+#ifdef CONFIG_FSL_FASTBOOT
+static int initr_fastboot_setup(void)
+{
+ fastboot_setup();
+ return 0;
+}
+
+static int initr_check_fastboot(void)
+{
+ check_fastboot();
+ return 0;
+}
+#endif
+
static int run_main_loop(void)
{
#ifdef CONFIG_SANDBOX
@@ -894,6 +913,9 @@ static init_fnc_t init_sequence_r[] = {
#ifdef CONFIG_BOARD_LATE_INIT
board_late_init,
#endif
+#ifdef CONFIG_FSL_FASTBOOT
+ initr_fastboot_setup,
+#endif
#if defined(CONFIG_CMD_AMBAPP)
ambapp_init_reloc,
#if defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP)
@@ -942,6 +964,9 @@ static init_fnc_t init_sequence_r[] = {
#if defined(CONFIG_SPARC)
prom_init,
#endif
+#ifdef CONFIG_FSL_FASTBOOT
+ initr_check_fastboot,
+#endif
run_main_loop,
};
diff --git a/common/image-android.c b/common/image-android.c
index ee03b96aaa..12ae345906 100644
--- a/common/image-android.c
+++ b/common/image-android.c
@@ -1,6 +1,8 @@
/*
* Copyright (c) 2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
+ *
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -9,6 +11,7 @@
#include <android_image.h>
#include <malloc.h>
#include <errno.h>
+#include <asm/bootm.h>
#define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000
@@ -68,7 +71,6 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
int len = 0;
if (*hdr->cmdline) {
- printf("Kernel command line: %s\n", hdr->cmdline);
len += strlen(hdr->cmdline);
}
@@ -85,12 +87,25 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
if (bootargs) {
strcpy(newbootargs, bootargs);
- strcat(newbootargs, " ");
- }
- if (*hdr->cmdline)
+ } else if (*hdr->cmdline) {
strcat(newbootargs, hdr->cmdline);
+ }
+ printf("Kernel command line: %s\n", newbootargs);
+#ifdef CONFIG_SERIAL_TAG
+ struct tag_serialnr serialnr;
+ char commandline[ANDR_BOOT_ARGS_SIZE];
+ get_board_serial(&serialnr);
+
+ sprintf(commandline,
+ "%s androidboot.serialno=%08x%08x",
+ newbootargs,
+ serialnr.high,
+ serialnr.low);
+ setenv("bootargs", commandline);
+#else
setenv("bootargs", newbootargs);
+#endif
if (os_data) {
*os_data = (ulong)hdr;
@@ -174,3 +189,21 @@ void android_print_contents(const struct andr_img_hdr *hdr)
printf("%scmdline: %s\n", p, hdr->cmdline);
}
#endif
+
+int android_image_get_fdt(const struct andr_img_hdr *hdr,
+ ulong *fdt_data, ulong *fdt_len)
+{
+ if (!hdr->second_size)
+ return -1;
+
+ printf("FDT load addr 0x%08x size %u KiB\n",
+ hdr->second_addr, DIV_ROUND_UP(hdr->second_size, 1024));
+
+ *fdt_data = (unsigned long)hdr;
+ *fdt_data += hdr->page_size;
+ *fdt_data += ALIGN(hdr->kernel_size, hdr->page_size);
+ *fdt_data += ALIGN(hdr->ramdisk_size, hdr->page_size);
+
+ *fdt_len = hdr->second_size;
+ return 0;
+}
diff --git a/common/image-fdt.c b/common/image-fdt.c
index e7540be8d6..1e868962c1 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -6,6 +6,8 @@
* (C) Copyright 2000-2006
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
+ *
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -417,7 +419,34 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
debug("## No Flattened Device Tree\n");
goto no_fdt;
}
- } else {
+ }
+#ifdef CONFIG_ANDROID_BOOT_IMAGE
+ else if (genimg_get_format((void *)images->os.start) ==
+ IMAGE_FORMAT_ANDROID) {
+ ulong fdt_data, fdt_len;
+ android_image_get_fdt((void *)images->os.start,
+ &fdt_data, &fdt_len);
+
+ if (fdt_len) {
+ fdt_blob = (char *)fdt_data;
+ printf(" Booting using the fdt at 0x%p\n", fdt_blob);
+
+ if (fdt_check_header(fdt_blob) != 0) {
+ fdt_error("image is not a fdt");
+ goto error;
+ }
+
+ if (fdt_totalsize(fdt_blob) != fdt_len) {
+ fdt_error("fdt size != image size");
+ goto error;
+ }
+ } else {
+ debug("## No Flattened Device Tree\n");
+ goto no_fdt;
+ }
+ }
+#endif
+ else {
debug("## No Flattened Device Tree\n");
goto no_fdt;
}