MA-11641 [Android]Get bootmode from argv[] in do_boota
authorLuo Ji <ji.luo@nxp.com>
Thu, 29 Mar 2018 08:32:04 +0000 (16:32 +0800)
committerLuo Ji <ji.luo@nxp.com>
Wed, 4 Apr 2018 10:23:30 +0000 (18:23 +0800)
Don't set the recovery mode to is_recovery_mode in
fastboot_run_bootmode(). The boota command is like
"boota <partition>" if we enable AVB, so we can get
the boot mode from argv[].

Change-Id: I6ff46f9bdc9b7b766698b508f73005a956766767
Signed-off-by: Luo Ji <ji.luo@nxp.com>
drivers/usb/gadget/f_fastboot.c

index e4cdb8f..241f526 100755 (executable)
@@ -93,9 +93,6 @@ extern void trusty_os_init(void);
  */
 static unsigned int download_size;
 static unsigned int download_bytes;
-#if defined(CONFIG_AVB_SUPPORT) && defined(CONFIG_MMC)
-static bool is_recovery_mode = false;
-#endif
 
 /* common variables of fastboot getvar command */
 char *fastboot_common_var[FASTBOOT_COMMON_VAR_NUM] = {
@@ -1248,6 +1245,11 @@ void board_fastboot_setup(void)
 #ifdef CONFIG_ANDROID_RECOVERY
 void board_recovery_setup(void)
 {
+/* boot from current mmc with avb verify */
+#ifdef CONFIG_AVB_SUPPORT
+       if (!getenv("bootcmd_android_recovery"))
+               setenv("bootcmd_android_recovery", "boota recovery");
+#else
 #if defined(CONFIG_FASTBOOT_STORAGE_MMC)
        static char boot_dev_part[32];
        u32 dev_no;
@@ -1274,7 +1276,7 @@ void board_recovery_setup(void)
                        bootdev);
                return;
        }
-
+#endif /* CONFIG_AVB_SUPPORT */
        printf("setup env for recovery..\n");
        setenv("bootcmd", "run bootcmd_android_recovery");
 }
@@ -1481,11 +1483,7 @@ void fastboot_run_bootmode(void)
        case BOOTMODE_RECOVERY_KEY_PRESSED:
                /* Make the boot into recovery mode */
                puts("Fastboot: Got Recovery key pressing or recovery commands!\n");
-#if defined(CONFIG_AVB_SUPPORT) && defined(CONFIG_MMC)
-               is_recovery_mode = true;
-#else
                board_recovery_setup();
-#endif
                break;
 #endif
        default:
@@ -1541,15 +1539,21 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
        ulong image_size;
        u32 avb_metric;
        bool check_image_arm64 =  false;
+       bool is_recovery_mode = false;
 
 #if defined (CONFIG_ARCH_IMX8) || defined (CONFIG_ARCH_IMX8M)
        size_t lz4_len = DST_DECOMPRESS_LEN;
 #endif
-
        AvbABFlowResult avb_result;
        AvbSlotVerifyData *avb_out_data;
        AvbPartitionData *avb_loadpart;
 
+       /* get bootmode, default to boot "boot" */
+       if (argc > 1) {
+               is_recovery_mode =
+                       (strncmp(argv[1], "recovery", sizeof("recovery")) != 0) ? false: true;
+       }
+
 #ifdef CONFIG_FASTBOOT_LOCK
        /* check lock state */
        FbLockState lock_status = fastboot_get_lock_stat();