From 10a635bbbbfe36ab39ed77c84fe8d30000c638f5 Mon Sep 17 00:00:00 2001 From: "faqiang.zhu" Date: Tue, 25 Feb 2020 10:18:24 +0800 Subject: [PATCH] MA-16457-1 avoid to try to access system partition To enable dynamic partition feature, system partition will be a logic parition in "super" partition, uboot can't access system partition anymore. In i.MX Android use case, only vbmeta partition is used to verify other imags. boot and system are not used. so there is no need to access system partition to get avb device info, remove system partition from avb lib for standard android. Now, standard Android will boot with ramdisk in boot.img, there is no need to provide root info to kernel for standard Android. so only Android Auto will provide this info. Change-Id: I99a43eb8f7aa1dc635e3937c93266f881c9b3655 Signed-off-by: faqiang.zhu (cherry picked from commit 3a2418a1cc097cd956347fc12b0b4e0566652bfd) (cherry picked from commit 133644540d6e5c89cc6e8109b2bf3ac6a9b897d1) --- drivers/fastboot/fb_fsl/fb_fsl_boot.c | 20 +++++++++----------- lib/libavb/avb_cmdline.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/fastboot/fb_fsl/fb_fsl_boot.c b/drivers/fastboot/fb_fsl/fb_fsl_boot.c index f0c4580277..6a39737365 100644 --- a/drivers/fastboot/fb_fsl/fb_fsl_boot.c +++ b/drivers/fastboot/fb_fsl/fb_fsl_boot.c @@ -218,7 +218,7 @@ U_BOOT_CMD( ); #endif -#ifdef CONFIG_SYSTEM_RAMDISK_SUPPORT +#if defined CONFIG_SYSTEM_RAMDISK_SUPPORT && defined CONFIG_ANDROID_AUTO_SUPPORT /* Setup booargs for taking the system parition as ramdisk */ static void fastboot_setup_system_boot_args(const char *slot, bool append_root) { @@ -250,12 +250,6 @@ static void fastboot_setup_system_boot_args(const char *slot, bool append_root) } strcat(bootargs_3rd, "rootwait"); - /* for standard android, recovery ramdisk will be used anyway, to - * boot up Android, "androidboot.force_normal_boot=1" is needed */ -#ifndef CONFIG_ANDROID_AUTO_SUPPORT - strcat(bootargs_3rd, " androidboot.force_normal_boot=1"); -#endif - env_set("bootargs_3rd", bootargs_3rd); } else { printf("Can't find partition: %s\n", system_part_name); @@ -416,6 +410,7 @@ int vbh_calculate(uint8_t *vbh, AvbSlotVerifyData *avb_out_data) ret = -1; goto fail; } + /* Calculate VBH2 */ if (sha256_concatenation(hash_buf, vbh, image_hash)) { ret = -1; @@ -674,13 +669,16 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { "androidboot.verifiedbootstate=orange androidboot.flash.locked=0 androidboot.slot_suffix=%s ", avb_out_data->ab_suffix); } -#ifdef CONFIG_ANDROID_AUTO_SUPPORT strcat(bootargs_sec, avb_out_data->cmdline); -#else - strcat(bootargs_sec, strstr(avb_out_data->cmdline, "androidboot")); +#ifndef CONFIG_ANDROID_AUTO_SUPPORT + /* for standard android, recovery ramdisk will be used anyway, to + * boot up Android, "androidboot.force_normal_boot=1" is needed */ + if(!is_recovery_mode) { + strcat(bootargs_sec, " androidboot.force_normal_boot=1"); + } #endif env_set("bootargs_sec", bootargs_sec); -#ifdef CONFIG_SYSTEM_RAMDISK_SUPPORT +#if defined CONFIG_SYSTEM_RAMDISK_SUPPORT && defined CONFIG_ANDROID_AUTO_SUPPORT if(!is_recovery_mode) { if(avb_out_data->cmdline != NULL && strstr(avb_out_data->cmdline, "root=")) fastboot_setup_system_boot_args(avb_out_data->ab_suffix, false); diff --git a/lib/libavb/avb_cmdline.c b/lib/libavb/avb_cmdline.c index 65be721896..4da2ebc3f7 100644 --- a/lib/libavb/avb_cmdline.c +++ b/lib/libavb/avb_cmdline.c @@ -10,7 +10,11 @@ #include #include +#ifdef CONFIG_ANDROID_AUTO_SUPPORT #define NUM_GUIDS 3 +#else +#define NUM_GUIDS 2 +#endif /* Substitutes all variables (e.g. $(ANDROID_SYSTEM_PARTUUID)) with * values. Returns NULL on OOM, otherwise the cmdline with values @@ -21,10 +25,16 @@ char* avb_sub_cmdline(AvbOps* ops, const char* ab_suffix, bool using_boot_for_vbmeta, const AvbCmdlineSubstList* additional_substitutions) { +#ifdef CONFIG_ANDROID_AUTO_SUPPORT const char* part_name_str[NUM_GUIDS] = {"system", "boot", "vbmeta"}; const char* replace_str[NUM_GUIDS] = {"$(ANDROID_SYSTEM_PARTUUID)", "$(ANDROID_BOOT_PARTUUID)", "$(ANDROID_VBMETA_PARTUUID)"}; +#else + const char* part_name_str[NUM_GUIDS] = {"boot", "vbmeta"}; + const char* replace_str[NUM_GUIDS] = {"$(ANDROID_BOOT_PARTUUID)", + "$(ANDROID_VBMETA_PARTUUID)"}; +#endif char* ret = NULL; AvbIOResult io_ret; size_t n; @@ -33,7 +43,11 @@ char* avb_sub_cmdline(AvbOps* ops, * partition. */ if (using_boot_for_vbmeta) { +#ifdef CONFIG_ANDROID_AUTO_SUPPORT part_name_str[2] = "boot"; +#else + part_name_str[1] = "boot"; +#endif } /* Replace unique partition GUIDs */ -- 2.17.1