Commit 7163f0ca1c757fd28532bf1ac3daccc3255e4e0d

Authored by Luo Ji
1 parent 51e281b664

MA-11641 [Android]Get bootmode from argv[] in do_boota

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>

Showing 1 changed file with 13 additions and 9 deletions Side-by-side Diff

drivers/usb/gadget/f_fastboot.c
... ... @@ -93,9 +93,6 @@
93 93 */
94 94 static unsigned int download_size;
95 95 static unsigned int download_bytes;
96   -#if defined(CONFIG_AVB_SUPPORT) && defined(CONFIG_MMC)
97   -static bool is_recovery_mode = false;
98   -#endif
99 96  
100 97 /* common variables of fastboot getvar command */
101 98 char *fastboot_common_var[FASTBOOT_COMMON_VAR_NUM] = {
... ... @@ -1248,6 +1245,11 @@
1248 1245 #ifdef CONFIG_ANDROID_RECOVERY
1249 1246 void board_recovery_setup(void)
1250 1247 {
  1248 +/* boot from current mmc with avb verify */
  1249 +#ifdef CONFIG_AVB_SUPPORT
  1250 + if (!getenv("bootcmd_android_recovery"))
  1251 + setenv("bootcmd_android_recovery", "boota recovery");
  1252 +#else
1251 1253 #if defined(CONFIG_FASTBOOT_STORAGE_MMC)
1252 1254 static char boot_dev_part[32];
1253 1255 u32 dev_no;
... ... @@ -1274,7 +1276,7 @@
1274 1276 bootdev);
1275 1277 return;
1276 1278 }
1277   -
  1279 +#endif /* CONFIG_AVB_SUPPORT */
1278 1280 printf("setup env for recovery..\n");
1279 1281 setenv("bootcmd", "run bootcmd_android_recovery");
1280 1282 }
1281 1283  
... ... @@ -1481,11 +1483,7 @@
1481 1483 case BOOTMODE_RECOVERY_KEY_PRESSED:
1482 1484 /* Make the boot into recovery mode */
1483 1485 puts("Fastboot: Got Recovery key pressing or recovery commands!\n");
1484   -#if defined(CONFIG_AVB_SUPPORT) && defined(CONFIG_MMC)
1485   - is_recovery_mode = true;
1486   -#else
1487 1486 board_recovery_setup();
1488   -#endif
1489 1487 break;
1490 1488 #endif
1491 1489 default:
1492 1490  
1493 1491  
... ... @@ -1541,14 +1539,20 @@
1541 1539 ulong image_size;
1542 1540 u32 avb_metric;
1543 1541 bool check_image_arm64 = false;
  1542 + bool is_recovery_mode = false;
1544 1543  
1545 1544 #if defined (CONFIG_ARCH_IMX8) || defined (CONFIG_ARCH_IMX8M)
1546 1545 size_t lz4_len = DST_DECOMPRESS_LEN;
1547 1546 #endif
1548   -
1549 1547 AvbABFlowResult avb_result;
1550 1548 AvbSlotVerifyData *avb_out_data;
1551 1549 AvbPartitionData *avb_loadpart;
  1550 +
  1551 + /* get bootmode, default to boot "boot" */
  1552 + if (argc > 1) {
  1553 + is_recovery_mode =
  1554 + (strncmp(argv[1], "recovery", sizeof("recovery")) != 0) ? false: true;
  1555 + }
1552 1556  
1553 1557 #ifdef CONFIG_FASTBOOT_LOCK
1554 1558 /* check lock state */