Commit 4d226b92 authored by Sanshan Zhang's avatar Sanshan Zhang Committed by Ye Li

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: default avatarSanshan Zhang <sanshan.zhang@nxp.com>
(cherry picked from commit da0ce2787256a323371641b0764266d386d767a5)
Signed-off-by: default avatarYe Li <ye.li@nxp.com>
parent 9fe1f23c
......@@ -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;
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6QSABREAUTO=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/mx6dl.cfg,MX6DL"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6QSABREAUTO=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/mx6dl.cfg,MX6DL"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_NAND_BOOT=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6SABRESD=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sabresd/mx6dlsabresd.cfg,MX6DL"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6QSABREAUTO=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/mx6qp.cfg,MX6QP"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6QSABREAUTO=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/mx6qp.cfg,MX6QP"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_NAND_BOOT=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6SABRESD=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sabresd/mx6qp.cfg,MX6QP"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6QSABREAUTO=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg,MX6Q"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6QSABREAUTO=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg,MX6Q"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_NAND_BOOT=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6SABRESD=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sabresd/mx6q_4x_mt41j128.cfg,MX6Q"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
......
......@@ -3,6 +3,7 @@ CONFIG_ARCH_MX6=y
CONFIG_TARGET_MX6SLEVK=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6slevk/imximage.cfg,MX6SL"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
CONFIG_HUSH_PARSER=y
CONFIG_CMD_BOOTZ=y
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6QSABREAUTO=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/mx6solo.cfg,MX6S"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6QSABREAUTO=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6qsabreauto/mx6solo.cfg,MX6S"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_NAND_BOOT=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6SABRESD=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sabresd/mx6solo_4x_mt41j128.cfg,MX6S"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6SXSABREAUTO=y
CONFIG_DEFAULT_DEVICE_TREE="imx6sx-sabreauto"
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sxsabreauto/imximage.cfg"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
CONFIG_HUSH_PARSER=y
CONFIG_CMD_BOOTZ=y
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6SXSABREAUTO=y
CONFIG_DEFAULT_DEVICE_TREE="imx6sx-sabreauto"
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sxsabreauto/imximage.cfg"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_NAND_BOOT=y
CONFIG_BOOTDELAY=3
CONFIG_HUSH_PARSER=y
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX6SXSABRESD=y
CONFIG_VIDEO=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6sxsabresd/imximage.cfg"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
......
......@@ -5,6 +5,7 @@ CONFIG_VIDEO=y
CONFIG_DEFAULT_DEVICE_TREE="imx6ul-14x14-evk"
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6ul_14x14_evk/imximage.cfg"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
CONFIG_BOARD_EARLY_INIT_F=y
CONFIG_HUSH_PARSER=y
......
......@@ -8,6 +8,7 @@ CONFIG_VIDEO=y
CONFIG_DEFAULT_DEVICE_TREE="imx7d-sdb"
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx7dsabresd/imximage.cfg"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOOTDELAY=3
# CONFIG_CONSOLE_MUX is not set
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
......
......@@ -4,6 +4,7 @@ CONFIG_TARGET_MX7ULP_EVK=y
CONFIG_DEFAULT_DEVICE_TREE="imx7ulp-evk-qspi"
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx7ulp_evk/imximage.cfg"
CONFIG_FASTBOOT=y
CONFIG_EFI_PARTITION=y
CONFIG_BOARD_LATE_INIT=y
CONFIG_BOARD_EARLY_INIT_F=y
CONFIG_HUSH_PARSER=y
......
......@@ -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);
......@@ -248,14 +248,14 @@ int part_get_info_efi(struct blk_desc *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__);
}
}
......
......@@ -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
......@@ -165,11 +170,20 @@ static struct usb_gadget_strings *fastboot_strings[] = {
#ifdef CONFIG_FSL_FASTBOOT
#ifdef CONFIG_EFI_PARTITION
#define ANDROID_BOOT_PARTITION_MMC 1
#define ANDROID_RECOVERY_PARTITION_MMC 2
#define ANDROID_SYSTEM_PARTITION_MMC 3
#define ANDROID_CACHE_PARTITION_MMC 4
#define ANDROID_MISC_PARTITION_MMC 6
#define ANDROID_DATA_PARTITION_MMC 10
#else
#define ANDROID_BOOT_PARTITION_MMC 1
#define ANDROID_SYSTEM_PARTITION_MMC 5
#define ANDROID_RECOVERY_PARTITION_MMC 2
#define ANDROID_CACHE_PARTITION_MMC 6
#define ANDROID_DATA_PARTITION_MMC 4
#endif
#define ANDROID_MBR_OFFSET 0
#define ANDROID_MBR_SIZE 0x200
......@@ -189,6 +203,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,
......@@ -196,9 +228,10 @@ enum {
PTN_URAMDISK_INDEX,
PTN_SYSTEM_INDEX,
PTN_RECOVERY_INDEX,
PTN_DATA_INDEX
PTN_DATA_INDEX,
PTN_NUM
};
#endif /*CONFIG_EFI_PARTITION*/
static unsigned int download_bytes_unpadded;
static struct cmd_fastboot_interface interface = {
......@@ -1145,19 +1178,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 (part_get_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;
}
......@@ -1175,7 +1212,7 @@ static int _fastboot_parts_load_from_ptable(void)
struct mmc *mmc;
struct blk_desc *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) {
......@@ -1222,12 +1259,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 =
......@@ -1236,6 +1281,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,
ANDROID_BOOT_PARTITION_MMC,
user_partition,
......@@ -1252,8 +1298,21 @@ static int _fastboot_parts_load_from_ptable(void)
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;
......
/*
* Copyright (C) 2012-2016 Freescale Semiconductor, Inc.
* Copyright 2017 NXP
*
* Configuration settings for the Freescale i.MX6Q SabreSD board.
*
......@@ -44,7 +45,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_CMD_SF
#define CONFIG_SF_DEFAULT_CS 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment