Browse Source

MA-9263-3 [Android] Partition: enable GPT partition on imx devices

1. pass androidboot.storage_type to android, 'init' use it to parse
different init.freescale.storage.rc.
2. store new ptable with gpt partition.
3. we use the last LBA as backup gpt table, there is many warning log
when boot, change print to debug

Change-Id: I84070735e9d4c2741b0e240bc1c61b357dabc5b8
Signed-off-by: Sanshan Zhang <sanshan.zhang@nxp.com>
Sanshan Zhang 4 years ago
parent
commit
da0ce27872
11 changed files with 159 additions and 21 deletions
  1. +2
    -2
      arch/arm/cpu/armv7/mx7ulp/soc.c
  2. +24
    -4
      common/image-android.c
  3. +3
    -3
      disk/part_efi.c
  4. +60
    -11
      drivers/usb/gadget/f_fastboot.c
  5. +11
    -0
      include/configs/mx6sabreandroid_common.h
  6. +3
    -0
      include/configs/mx6sabresd.h
  7. +11
    -0
      include/configs/mx6slevkandroid.h
  8. +12
    -0
      include/configs/mx6sxsabreautoandroid.h
  9. +11
    -0
      include/configs/mx6sxsabresdandroid.h
  10. +11
    -0
      include/configs/mx7dsabresdandroid.h
  11. +11
    -1
      include/configs/mx7ulp_evk_android.h

+ 2
- 2
arch/arm/cpu/armv7/mx7ulp/soc.c View File

@ -406,9 +406,9 @@ enum boot_device get_boot_device(void)
type = (bt1_cfg >> 8) & 0x1;
if (type)
boot_dev = MMC1_BOOT;
else
boot_dev = SD1_BOOT;
else
boot_dev = MMC1_BOOT;
return boot_dev;
}
#ifdef CONFIG_SERIAL_TAG


+ 24
- 4
common/image-android.c View File

@ -2,6 +2,7 @@
* Copyright (c) 2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*
* Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@ -12,6 +13,7 @@
#include <malloc.h>
#include <errno.h>
#include <asm/bootm.h>
#include <asm/imx-common/boot_mode.h>
#define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000
@ -92,9 +94,10 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
}
printf("Kernel command line: %s\n", newbootargs);
char commandline[ANDR_BOOT_ARGS_SIZE];
strcpy(commandline, newbootargs);
#ifdef CONFIG_SERIAL_TAG
struct tag_serialnr serialnr;
char commandline[ANDR_BOOT_ARGS_SIZE];
get_board_serial(&serialnr);
sprintf(commandline,
@ -102,10 +105,27 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
newbootargs,
serialnr.high,
serialnr.low);
setenv("bootargs", commandline);
#else
setenv("bootargs", newbootargs);
strcpy(newbootargs, commandline);
#endif
int bootdev = get_boot_device();
if (bootdev == SD1_BOOT || bootdev == SD2_BOOT ||
bootdev == SD3_BOOT || bootdev == SD4_BOOT) {
sprintf(commandline,
"%s androidboot.storage_type=sd gpt",
newbootargs);
} else if (bootdev == MMC1_BOOT || bootdev == MMC2_BOOT ||
bootdev == MMC3_BOOT || bootdev == MMC4_BOOT) {
sprintf(commandline,
"%s androidboot.storage_type=emmc",
newbootargs);
} else if (bootdev == NAND_BOOT) {
sprintf(commandline,
"%s androidboot.storage_type=nand",
newbootargs);
} else
printf("boot device type is incorrect.\n");
setenv("bootargs", commandline);
if (os_data) {
*os_data = (ulong)hdr;


+ 3
- 3
disk/part_efi.c View File

@ -143,7 +143,7 @@ static int validate_gpt_entries(gpt_header *gpt_h, gpt_entry *gpt_e)
le32_to_cpu(gpt_h->sizeof_partition_entry));
if (calc_crc32 != le32_to_cpu(gpt_h->partition_entry_array_crc32)) {
printf("%s: 0x%x != 0x%x\n",
debug("%s: 0x%x != 0x%x\n",
"GUID Partition Table Entry Array CRC is wrong",
le32_to_cpu(gpt_h->partition_entry_array_crc32),
calc_crc32);
@ -252,14 +252,14 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
/* This function validates AND fills in the GPT header and PTE */
if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
gpt_head, &gpt_pte) != 1) {
printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
debug("%s: *** ERROR: Invalid GPT ***\n", __func__);
if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
gpt_head, &gpt_pte) != 1) {
printf("%s: *** ERROR: Invalid Backup GPT ***\n",
__func__);
return -1;
} else {
printf("%s: *** Using Backup GPT ***\n",
debug("%s: *** Using Backup GPT ***\n",
__func__);
}
}


+ 60
- 11
drivers/usb/gadget/f_fastboot.c View File

@ -9,6 +9,7 @@
* Rob Herring <robh@kernel.org>
*
* Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@ -46,6 +47,10 @@
#define FASTBOOT_VERSION "0.4"
#ifdef CONFIG_EFI_PARTITION
#define ANDROID_GPT_OFFSET 0
#define ANDROID_GPT_SIZE 0x100000
#endif
#define FASTBOOT_INTERFACE_CLASS 0xff
#define FASTBOOT_INTERFACE_SUB_CLASS 0x42
#define FASTBOOT_INTERFACE_PROTOCOL 0x03
@ -160,6 +165,24 @@ static struct usb_gadget_strings *fastboot_strings[] = {
/*pentry index internally*/
#ifdef CONFIG_EFI_PARTITION
enum {
PTN_GPT_INDEX = 0,
PTN_BOOTLOADER_INDEX,
PTN_BOOT_INDEX,
PTN_RECOVERY_INDEX,
PTN_SYSTEM_INDEX,
PTN_CACHE_INDEX,
PTN_DEVICE_INDEX,
PTN_MISC_INDEX,
PTN_DATAFOOTER_INDEX,
PTN_VBMETA_INDEX,
PTN_PRESISTDATA_INDEX,
PTN_DATA_INDEX,
PTN_FBMISC_INDEX,
PTN_NUM
};
#else
enum {
PTN_MBR_INDEX = 0,
PTN_BOOTLOADER_INDEX,
@ -169,7 +192,7 @@ enum {
PTN_RECOVERY_INDEX,
PTN_DATA_INDEX
};
#endif /*CONFIG_EFI_PARTITION*/
static unsigned int download_bytes_unpadded;
static struct cmd_fastboot_interface interface = {
@ -1287,19 +1310,23 @@ static int _fastboot_parts_add_ptable_entry(int ptable_index,
struct fastboot_ptentry *ptable)
{
disk_partition_t info;
strcpy(ptable[ptable_index].name, name);
if (get_partition_info(dev_desc,
mmc_dos_partition_index, &info)) {
printf("Bad partition index:%d for partition:%s\n",
mmc_dos_partition_index, name);
return -1;
} else {
ptable[ptable_index].start = info.start;
ptable[ptable_index].length = info.size;
ptable[ptable_index].partition_id = mmc_partition_index;
ptable[ptable_index].partition_index = mmc_dos_partition_index;
}
ptable[ptable_index].start = info.start;
ptable[ptable_index].length = info.size;
ptable[ptable_index].partition_id = mmc_partition_index;
ptable[ptable_index].partition_index = mmc_dos_partition_index;
#ifdef CONFIG_EFI_PARTITION
strcpy(ptable[ptable_index].name, (const char *)info.name);
#else
strcpy(ptable[ptable_index].name, name);
#endif
return 0;
}
@ -1317,7 +1344,7 @@ static int _fastboot_parts_load_from_ptable(void)
struct mmc *mmc;
block_dev_desc_t *dev_desc;
struct fastboot_ptentry ptable[PTN_DATA_INDEX + 1];
struct fastboot_ptentry ptable[PTN_NUM + 1];
/* sata case in env */
if (fastboot_devinfo.type == DEV_SATA) {
@ -1364,12 +1391,20 @@ static int _fastboot_parts_load_from_ptable(void)
}
memset((char *)ptable, 0,
sizeof(struct fastboot_ptentry) * (PTN_DATA_INDEX + 1));
sizeof(struct fastboot_ptentry) * (PTN_NUM + 1));
#ifdef CONFIG_EFI_PARTITION
/* GPT */
strcpy(ptable[PTN_GPT_INDEX].name, "gpt");
ptable[PTN_GPT_INDEX].start = ANDROID_GPT_OFFSET / dev_desc->blksz;
ptable[PTN_GPT_INDEX].length = ANDROID_GPT_SIZE / dev_desc->blksz;
ptable[PTN_GPT_INDEX].partition_id = user_partition;
#else
/* MBR */
strcpy(ptable[PTN_MBR_INDEX].name, "mbr");
ptable[PTN_MBR_INDEX].start = ANDROID_MBR_OFFSET / dev_desc->blksz;
ptable[PTN_MBR_INDEX].length = ANDROID_MBR_SIZE / dev_desc->blksz;
ptable[PTN_MBR_INDEX].partition_id = user_partition;
#endif
/* Bootloader */
strcpy(ptable[PTN_BOOTLOADER_INDEX].name, FASTBOOT_PARTITION_BOOTLOADER);
ptable[PTN_BOOTLOADER_INDEX].start =
@ -1378,6 +1413,7 @@ static int _fastboot_parts_load_from_ptable(void)
ANDROID_BOOTLOADER_SIZE / dev_desc->blksz;
ptable[PTN_BOOTLOADER_INDEX].partition_id = boot_partition;
#ifndef CONFIG_EFI_PARTITION
_fastboot_parts_add_ptable_entry(PTN_KERNEL_INDEX,
CONFIG_ANDROID_BOOT_PARTITION_MMC,
user_partition,
@ -1394,8 +1430,21 @@ static int _fastboot_parts_load_from_ptable(void)
CONFIG_ANDROID_DATA_PARTITION_MMC,
user_partition,
FASTBOOT_PARTITION_DATA, dev_desc, ptable);
for (i = 0; i <= PTN_DATA_INDEX; i++)
#else
int tbl_idx;
int part_idx = 1;
int ret;
for (tbl_idx = 2; tbl_idx < PTN_NUM; tbl_idx++) {
ret = _fastboot_parts_add_ptable_entry(tbl_idx,
part_idx++,
user_partition,
NULL,
dev_desc, ptable);
if (ret)
break;
}
#endif /*CONFIG_EFI_PARTITION*/
for (i = 0; i <= PTN_NUM; i++)
fastboot_flash_add_ptn(&ptable[i]);
return 0;


+ 11
- 0
include/configs/mx6sabreandroid_common.h View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2013-2016 Freescale Semiconductor, Inc. All Rights Reserved.
* Copyright 2017 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@ -7,6 +8,7 @@
#ifndef MX6_SABRE_ANDROID_COMMON_H
#define MX6_SABRE_ANDROID_COMMON_H
#define CONFIG_EFI_PARTITION
#define CONFIG_CI_UDC
#define CONFIG_USBD_HS
#define CONFIG_USB_GADGET_DUALSPEED
@ -38,12 +40,21 @@
#define CONFIG_FASTBOOT_STORAGE_MMC
#endif
#ifdef CONFIG_EFI_PARTITION
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 3
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 4
#define CONFIG_ANDROID_MISC_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 10
#else
#define CONFIG_ANDROID_MAIN_MMC_BUS 2
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 5
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 4
#endif
#if defined(CONFIG_FASTBOOT_STORAGE_NAND)
#define ANDROID_FASTBOOT_NAND_PARTS "16m@64m(boot) 16m@80m(recovery) 810m@96m(android_root)ubifs"


+ 3
- 0
include/configs/mx6sabresd.h View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2012-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*
* Configuration settings for the Freescale i.MX6Q SabreSD board.
*
@ -34,7 +35,9 @@
#define CONFIG_SYS_FSL_USDHC_NUM 3
#define CONFIG_SYS_MMC_ENV_DEV 1 /* SDHC3 */
#ifndef CONFIG_SYS_MMC_ENV_PART
#define CONFIG_SYS_MMC_ENV_PART 0 /* user partition */
#endif
#ifdef CONFIG_SYS_USE_SPINOR
#define CONFIG_SF_DEFAULT_CS 0


+ 11
- 0
include/configs/mx6slevkandroid.h View File

@ -1,6 +1,7 @@
/*
* Copyright (C) 2013-2016 Freescale Semiconductor, Inc. All Rights Reserved.
* Copyright 2017 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@ -14,6 +15,7 @@
#define CONFIG_USBD_HS
#define CONFIG_USB_GADGET_DUALSPEED
#define CONFIG_EFI_PARTITION
#define CONFIG_USB_GADGET
#define CONFIG_CMD_USB_MASS_STORAGE
#define CONFIG_USB_FUNCTION_MASS_STORAGE
@ -34,12 +36,21 @@
#define CONFIG_FASTBOOT_STORAGE_MMC
#ifdef CONFIG_EFI_PARTITION
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 3
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 4
#define CONFIG_ANDROID_MISC_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 10
#else
#define CONFIG_ANDROID_MAIN_MMC_BUS 2
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 5
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 4
#endif
#define CONFIG_CMD_BOOTA
#define CONFIG_SUPPORT_RAW_INITRD


+ 12
- 0
include/configs/mx6sxsabreautoandroid.h View File

@ -1,6 +1,7 @@
/*
* Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@ -11,6 +12,8 @@
#define CONFIG_CI_UDC
#define CONFIG_USBD_HS
#define CONFIG_USB_GADGET_DUALSPEED
#define CONFIG_EFI_PARTITION
#define CONFIG_USB_GADGET
#define CONFIG_CMD_USB_MASS_STORAGE
@ -40,12 +43,21 @@
#define ANDROID_FASTBOOT_NAND_PARTS "16m@64m(boot) 16m@80m(recovery) 810m@96m(android_root)ubifs"
#endif
#ifdef CONFIG_EFI_PARTITION
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 3
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 4
#define CONFIG_ANDROID_MISC_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 10
#else
#define CONFIG_ANDROID_MAIN_MMC_BUS 2
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 5
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 4
#endif
#define CONFIG_CMD_BOOTA
#define CONFIG_SUPPORT_RAW_INITRD


+ 11
- 0
include/configs/mx6sxsabresdandroid.h View File

@ -1,6 +1,7 @@
/*
* Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@ -11,6 +12,7 @@
#define CONFIG_CI_UDC
#define CONFIG_USBD_HS
#define CONFIG_USB_GADGET_DUALSPEED
#define CONFIG_EFI_PARTITION
#define CONFIG_USB_GADGET
#define CONFIG_CMD_USB_MASS_STORAGE
@ -32,12 +34,21 @@
#define CONFIG_FASTBOOT_STORAGE_MMC
#ifdef CONFIG_EFI_PARTITION
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 3
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 4
#define CONFIG_ANDROID_MISC_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 10
#else
#define CONFIG_ANDROID_MAIN_MMC_BUS 2
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 5
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 4
#endif
#define CONFIG_CMD_BOOTA
#define CONFIG_SUPPORT_RAW_INITRD


+ 11
- 0
include/configs/mx7dsabresdandroid.h View File

@ -1,6 +1,7 @@
/*
* Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@ -11,6 +12,7 @@
#define CONFIG_CI_UDC
#define CONFIG_USBD_HS
#define CONFIG_USB_GADGET_DUALSPEED
#define CONFIG_EFI_PARTITION
#define CONFIG_USB_GADGET
#define CONFIG_CMD_USB_MASS_STORAGE
@ -31,12 +33,21 @@
#define CONFIG_ANDROID_RECOVERY
#define CONFIG_FASTBOOT_STORAGE_MMC
#ifdef CONFIG_EFI_PARTITION
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 3
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 4
#define CONFIG_ANDROID_MISC_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 10
#else
#define CONFIG_ANDROID_MAIN_MMC_BUS 2
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 5
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 4
#endif
#define CONFIG_CMD_BOOTA
#define CONFIG_SUPPORT_RAW_INITRD


+ 11
- 1
include/configs/mx7ulp_evk_android.h View File

@ -1,6 +1,7 @@
/*
* Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@ -11,7 +12,7 @@
#define CONFIG_CI_UDC
#define CONFIG_USBD_HS
#define CONFIG_USB_GADGET_DUALSPEED
#define CONFIG_EFI_PARTITION
#define CONFIG_USB_GADGET
#define CONFIG_CMD_USB_MASS_STORAGE
#define CONFIG_USB_FUNCTION_MASS_STORAGE
@ -35,12 +36,21 @@
#define CONFIG_ANDROID_RECOVERY
#define CONFIG_FASTBOOT_STORAGE_MMC
#ifdef CONFIG_EFI_PARTITION
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 3
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 4
#define CONFIG_ANDROID_MISC_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 10
#else
#define CONFIG_ANDROID_MAIN_MMC_BUS 2
#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 5
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 6
#define CONFIG_ANDROID_DATA_PARTITION_MMC 4
#endif
#define CONFIG_CMD_BOOTA
#define CONFIG_SUPPORT_RAW_INITRD


Loading…
Cancel
Save