summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBraden Kell <bradenkell@google.com>2018-01-31 09:42:56 -0800
committerBraden Kell <bradenkell@google.com>2018-01-31 14:32:44 -0800
commit7c600017c3a151d698baf1b9164aad18fce0e85b (patch)
tree756ddc9c67388ba5a515f844f69ba6b665aa54a5
parenta969e1ff9cca949a5524b7d4816be38189672336 (diff)
downloaduboot-imx-7c600017c3a151d698baf1b9164aad18fce0e85b.tar.gz
iMX7D: Load device tree from oem_bootloader
Load kernel.dtb from oem_bootloader root, or fall back to default behavior if that doesn't work. oem_bootloader should be ext2 or ext4. Bug: 72662957 Test: U-Boot loads modified dtb from oem_bootloader, or loads original dtb if kernel.dtb doesn't exist or oem_bootloader isn't formatted Change-Id: Ic93b572a482e85726e2fa0792997348c855f41a1
-rwxr-xr-xdrivers/usb/gadget/f_fastboot.c52
1 files changed, 47 insertions, 5 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 12e1973168..9153ae6496 100755
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -60,6 +60,10 @@ extern void trusty_os_init(void);
#include <fsl_avb.h>
#endif
+#ifdef CONFIG_ANDROID_THINGS_SUPPORT
+#include <fs.h>
+#endif
+
#define FASTBOOT_VERSION "0.4"
#ifdef CONFIG_FASTBOOT_LOCK
@@ -92,6 +96,11 @@ static unsigned int download_bytes;
static bool is_recovery_mode;
#endif
+#define AT_OEM_DTB "/kernel.dtb"
+#define AT_OEM_PART_NAME "oem_bootloader"
+#define AT_OEM_PART_SIZE 17
+#define AT_OEM_DEV_SIZE 6
+
/* common variables of fastboot getvar command */
char *fastboot_common_var[FASTBOOT_COMMON_VAR_NUM] = {
"version",
@@ -1526,6 +1535,33 @@ void bootimg_print_image_hdr(struct andr_img_hdr *hdr)
#endif
}
+#ifdef CONFIG_ANDROID_THINGS_SUPPORT
+static int android_things_load_fdt(const char *slot, struct andr_img_hdr *hdrload) {
+ /* check for kernel.dtb in oem_bootloader */
+ char oem_bootloader[AT_OEM_PART_SIZE];
+ snprintf(oem_bootloader, AT_OEM_PART_SIZE, AT_OEM_PART_NAME "%s", slot);
+ struct fastboot_ptentry *pte = fastboot_flash_find_ptn(oem_bootloader);
+ if (pte == NULL) {
+ printf("boota: no partition found for '%s'\n", oem_bootloader);
+ return -1;
+ }
+
+ char dev_part[AT_OEM_DEV_SIZE];
+ snprintf(dev_part, AT_OEM_DEV_SIZE, "%x:%x", fastboot_devinfo.dev_id,
+ pte->partition_index);
+ if (fs_set_blk_dev("mmc", dev_part, FS_TYPE_EXT) != 0)
+ return -1;
+
+ loff_t dtb_size;
+ if (!fs_read(AT_OEM_DTB, hdrload->second_addr, 0, 0, &dtb_size) && dtb_size) {
+ hdrload->second_size = dtb_size;
+ return 0;
+ }
+
+ return -1;
+}
+#endif
+
static struct andr_img_hdr boothdr __aligned(ARCH_DMA_MINALIGN);
#if defined(CONFIG_AVB_SUPPORT) && defined(CONFIG_MMC)
@@ -1540,6 +1576,7 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
ulong image_size;
u32 avb_metric;
bool check_image_arm64 = false;
+ char *slot = NULL;
AvbABFlowResult avb_result;
AvbSlotVerifyData *avb_out_data;
@@ -1572,14 +1609,15 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
printf("boota: bad boot image magic\n");
goto fail;
}
- printf(" verify OK, boot '%s%s'\n", avb_loadpart->partition_name, avb_out_data->ab_suffix);
+ slot = avb_out_data->ab_suffix;
+ printf(" verify OK, boot '%s%s'\n", avb_loadpart->partition_name, slot);
char bootargs_sec[2048];
sprintf(bootargs_sec, "androidboot.slot_suffix=%s %s",
- avb_out_data->ab_suffix, avb_out_data->cmdline);
+ slot, avb_out_data->cmdline);
setenv("bootargs_sec", bootargs_sec);
#ifdef CONFIG_SYSTEM_RAMDISK_SUPPORT
if(!is_recovery_mode)
- fastboot_setup_system_boot_args(avb_out_data->ab_suffix);
+ fastboot_setup_system_boot_args(slot);
#endif
image_size = avb_loadpart->data_size;
memcpy((void *)(ulong)(hdr->kernel_addr - hdr->page_size), (void *)hdr, image_size);
@@ -1597,7 +1635,7 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
hdr = &boothdr;
char bootimg[8];
- char *slot = select_slot(&fsl_avb_ab_ops);
+ slot = select_slot(&fsl_avb_ab_ops);
if (slot == NULL) {
printf("boota: no bootable slot\n");
goto fail;
@@ -1642,8 +1680,12 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
+ ALIGN(hdrload->kernel_size,hdrload->page_size), hdrload->ramdisk_size);
#ifdef CONFIG_OF_LIBFDT
+ bool fdt_loaded = false;
+#ifdef CONFIG_ANDROID_THINGS_SUPPORT
+ fdt_loaded = !android_things_load_fdt(slot, hdrload);
+#endif /* CONFIG_ANDROID_THINGS_SUPPORT */
/* load the dtb file */
- if (hdrload->second_size && hdrload->second_addr) {
+ if (!fdt_loaded && hdrload->second_size && hdrload->second_addr) {
memcpy((void *)(ulong)hdrload->second_addr, (void *)(ulong)hdrload->kernel_addr
+ ALIGN(hdrload->kernel_size, hdrload->page_size)
+ ALIGN(hdrload->ramdisk_size, hdrload->page_size), hdr->second_size);