MA-17519-4 boot up car2 with recovery ramdisk
authorfaqiang.zhu <faqiang.zhu@nxp.com>
Wed, 21 Oct 2020 08:14:38 +0000 (16:14 +0800)
committerJi Luo <ji.luo@nxp.com>
Thu, 13 May 2021 01:49:18 +0000 (09:49 +0800)
To use dynamic partition feature in Android, recovery ramdisk is used to
mount the logical partitions and boot up Android.

Define a configuration item "CONFIG_ANDROID_DYNAMIC_PARTITION", use it
to control the bootargs and whether ramdisk should be loaded instead of
"CONFIG_ANDROID_AUTO" because now Android auto also use dynamic
partition feature now.

Move the definition of function "fastboot_setup_system_boot_args" under
the macro "CONFIG_CMD_BOOTA" to avoid build warnings.

Signed-off-by: faqiang.zhu <faqiang.zhu@nxp.com>
Change-Id: I0b1cfe6120fc939e7f1a1eb600d8176c81edf129
(cherry picked from commit 972ccff86796e2b7f9a444d09550cd5e393cd93e)
(cherry picked from commit 7154723e8a43f06f27bab3692024f3579f4b78e4)

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

index b3fab73..0e51991 100644 (file)
@@ -218,7 +218,11 @@ U_BOOT_CMD(
 );
 #endif
 
-#if defined CONFIG_SYSTEM_RAMDISK_SUPPORT && defined CONFIG_ANDROID_AUTO_SUPPORT
+#ifdef CONFIG_CMD_BOOTA
+
+/* Section for Android bootimage format support */
+
+#ifndef CONFIG_ANDROID_DYNAMIC_PARTITION
 /* Setup booargs for taking the system parition as ramdisk */
 static void fastboot_setup_system_boot_args(const char *slot, bool append_root)
 {
@@ -258,14 +262,6 @@ static void fastboot_setup_system_boot_args(const char *slot, bool append_root)
 }
 #endif
 
-#ifdef CONFIG_CMD_BOOTA
-
-/* Section for Android bootimage format support
-* Refer:
-* http://android.git.kernel.org/?p=platform/system/core.git;a=blob;
-* f=mkbootimg/bootimg.h
-*/
-
 void
 bootimg_print_image_hdr(struct andr_img_hdr *hdr)
 {
@@ -695,15 +691,15 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
                }
                if (avb_out_data->cmdline != NULL)
                        strcat(bootargs_sec, avb_out_data->cmdline);
-#if defined(CONFIG_ANDROID_AB_SUPPORT) && !defined(CONFIG_ANDROID_AUTO_SUPPORT)
-               /* for standard android, recovery ramdisk will be used anyway, to
-                * boot up Android, "androidboot.force_normal_boot=1" is needed */
+#ifdef CONFIG_ANDROID_DYNAMIC_PARTITION
+               /* for the condition dynamic partition is used , recovery ramdisk is used to boot
+                * up Android, in this condition, "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_ANDROID_AUTO_SUPPORT
+#ifndef CONFIG_ANDROID_DYNAMIC_PARTITION
                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);
@@ -779,7 +775,7 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
                memcpy((void *)(ulong)vendor_boot_hdr->ramdisk_addr + vendor_boot_hdr->vendor_ramdisk_size,
                                (void *)(ulong)hdr_v3 + 4096 + ALIGN(hdr_v3->kernel_size, 4096), hdr_v3->ramdisk_size);
        } else {
-#if !defined(CONFIG_SYSTEM_RAMDISK_SUPPORT) || !defined(CONFIG_ANDROID_AUTO_SUPPORT)
+#if !defined(CONFIG_SYSTEM_RAMDISK_SUPPORT) || defined(CONFIG_ANDROID_DYNAMIC_PARTITION)
                memcpy((void *)(ulong)hdr->ramdisk_addr, (void *)(ulong)hdr + hdr->page_size
                                + ALIGN(hdr->kernel_size, hdr->page_size), hdr->ramdisk_size);
 #else
@@ -885,7 +881,7 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
        sprintf(fdt_addr_start, "0x%x", fdt_addr);
 
        /* Don't pass ramdisk addr for Android Auto if we are not booting from recovery */
-#ifdef CONFIG_ANDROID_AUTO_SUPPORT
+#ifndef CONFIG_ANDROID_DYNAMIC_PARTITION
        if (!is_recovery_mode)
                boot_args[2] = NULL;
 #endif
index 1ebc1a1..2785d6f 100644 (file)
@@ -371,8 +371,12 @@ config TRUSTY_UNLOCK_PERMISSION
        bool "Support unlock permission protection in trusty"
        depends on IMX_TRUSTY_OS
 
+config ANDROID_DYNAMIC_PARTITION
+       bool "Support to boot up Android with system image in logical partitions"
+
 config VIRTUAL_AB_SUPPORT
        bool "Support virtual AB update"
+       select ANDROID_DYNAMIC_PARTITION
 
 config LOAD_KEY_FROM_RPMB
        bool "Support load AVB public key from RPMB storage"
index 4da2ebc..dde1182 100644 (file)
@@ -10,7 +10,7 @@
 #include <log.h>
 #include <malloc.h>
 
-#ifdef CONFIG_ANDROID_AUTO_SUPPORT
+#ifndef CONFIG_ANDROID_DYNAMIC_PARTITION
 #define NUM_GUIDS 3
 #else
 #define NUM_GUIDS 2
@@ -25,7 +25,7 @@ char* avb_sub_cmdline(AvbOps* ops,
                       const char* ab_suffix,
                       bool using_boot_for_vbmeta,
                       const AvbCmdlineSubstList* additional_substitutions) {
-#ifdef CONFIG_ANDROID_AUTO_SUPPORT
+#ifndef CONFIG_ANDROID_DYNAMIC_PARTITION
   const char* part_name_str[NUM_GUIDS] = {"system", "boot", "vbmeta"};
   const char* replace_str[NUM_GUIDS] = {"$(ANDROID_SYSTEM_PARTUUID)",
                                         "$(ANDROID_BOOT_PARTUUID)",
@@ -43,7 +43,7 @@ char* avb_sub_cmdline(AvbOps* ops,
    * partition.
    */
   if (using_boot_for_vbmeta) {
-#ifdef CONFIG_ANDROID_AUTO_SUPPORT
+#ifndef CONFIG_ANDROID_DYNAMIC_PARTITION
     part_name_str[2] = "boot";
 #else
     part_name_str[1] = "boot";