MA-16457-1 avoid to try to access system partition
authorfaqiang.zhu <faqiang.zhu@nxp.com>
Tue, 25 Feb 2020 02:18:24 +0000 (10:18 +0800)
committerJi Luo <ji.luo@nxp.com>
Thu, 13 May 2021 01:49:18 +0000 (09:49 +0800)
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 <faqiang.zhu@nxp.com>
(cherry picked from commit 3a2418a1cc097cd956347fc12b0b4e0566652bfd)
(cherry picked from commit 133644540d6e5c89cc6e8109b2bf3ac6a9b897d1)

drivers/fastboot/fb_fsl/fb_fsl_boot.c
lib/libavb/avb_cmdline.c

index f0c4580..6a39737 100644 (file)
@@ -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);
index 65be721..4da2ebc 100644 (file)
 #include <log.h>
 #include <malloc.h>
 
+#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 */