[U-Boot] [PATCH v2] env: ti: boot: Handle reboot reason from BCB

In case of Android boot, reboot reason can be written into BCB (usually it's an area in 'misc' partition). U-Boot then can obtain that reboot reason from BCB and handle it accordingly to achieve correct Android boot flow, like it was suggested in [1]: - if it's empty: perform normal Android boot from eMMC - if it contains "bootonce-bootloader": get into fastboot mode - if it contains "boot-recovery": perform recovery boot
The latter is not implemented yet, as it depends on some features that are not implemented on TI platforms yet (in AOSP and in U-Boot).
[1] https://marc.info/?l=u-boot&m=152508418909737&w=2
Signed-off-by: Sam Protsenko semen.protsenko@linaro.org --- Changes in v2: - use CONTROL_PARTITION instead of "misc" to avoid hard code - add proper indentation
include/environment/ti/boot.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h index 54e9b2de4d..01b2981c5b 100644 --- a/include/environment/ti/boot.h +++ b/include/environment/ti/boot.h @@ -98,6 +98,10 @@ #define AB_SELECT "" #endif
+#define FASTBOOT_CMD \ + "echo Booting into fastboot ...; " \ + "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " + #define DEFAULT_COMMON_BOOT_TI_ARGS \ "console=" CONSOLEDEV ",115200n8\0" \ "fdtfile=undefined\0" \ @@ -117,6 +121,27 @@ "setenv mmcroot /dev/mmcblk0p2 rw; " \ "run mmcboot;\0" \ "emmc_android_boot=" \ + "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ + CONTROL_PARTITION "; then " \ + "if bcb test command = bootonce-bootloader; then " \ + "echo BCB: Bootloader boot...; " \ + "bcb clear command; bcb store; " \ + FASTBOOT_CMD \ + "elif bcb test command = boot-recovery; then " \ + "echo BCB: Recovery boot...; " \ + "echo Warning: recovery is not implemented; " \ + "echo Performing normal boot for now...; " \ + "run emmc_android_normal_boot; " \ + "else " \ + "echo BCB: Normal boot requested...; " \ + "run emmc_android_normal_boot; " \ + "fi; " \ + "else " \ + "echo Warning: BCB is corrupted or does not exist; " \ + "echo Performing normal boot...; " \ + "run emmc_android_normal_boot; " \ + "fi;\0" \ + "emmc_android_normal_boot=" \ "echo Trying to boot Android from eMMC ...; " \ "run update_to_fit; " \ "setenv eval_bootargs setenv bootargs $bootargs; " \ @@ -176,8 +201,7 @@ "if test ${dofastboot} -eq 1; then " \ "echo Boot fastboot requested, resetting dofastboot ...;" \ "setenv dofastboot 0; saveenv;" \ - "echo Booting into fastboot ...; " \ - "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \ + FASTBOOT_CMD \ "fi;" \ "if test ${boot_fit} -eq 1; then " \ "run update_to_fit;" \

On Fri, Jul 12, 2019 at 8:35 PM Sam Protsenko semen.protsenko@linaro.org wrote:
In case of Android boot, reboot reason can be written into BCB (usually it's an area in 'misc' partition). U-Boot then can obtain that reboot reason from BCB and handle it accordingly to achieve correct Android boot flow, like it was suggested in [1]:
- if it's empty: perform normal Android boot from eMMC
- if it contains "bootonce-bootloader": get into fastboot mode
- if it contains "boot-recovery": perform recovery boot
The latter is not implemented yet, as it depends on some features that are not implemented on TI platforms yet (in AOSP and in U-Boot).
[1] https://marc.info/?l=u-boot&m=152508418909737&w=2
Signed-off-by: Sam Protsenko semen.protsenko@linaro.org
Superseded by v3.
Changes in v2:
- use CONTROL_PARTITION instead of "misc" to avoid hard code
- add proper indentation
include/environment/ti/boot.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h index 54e9b2de4d..01b2981c5b 100644 --- a/include/environment/ti/boot.h +++ b/include/environment/ti/boot.h @@ -98,6 +98,10 @@ #define AB_SELECT "" #endif
+#define FASTBOOT_CMD \
"echo Booting into fastboot ...; " \
"fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; "
#define DEFAULT_COMMON_BOOT_TI_ARGS \ "console=" CONSOLEDEV ",115200n8\0" \ "fdtfile=undefined\0" \ @@ -117,6 +121,27 @@ "setenv mmcroot /dev/mmcblk0p2 rw; " \ "run mmcboot;\0" \ "emmc_android_boot=" \
"if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
CONTROL_PARTITION "; then " \
"if bcb test command = bootonce-bootloader; then " \
"echo BCB: Bootloader boot...; " \
"bcb clear command; bcb store; " \
FASTBOOT_CMD \
"elif bcb test command = boot-recovery; then " \
"echo BCB: Recovery boot...; " \
"echo Warning: recovery is not implemented; " \
"echo Performing normal boot for now...; " \
"run emmc_android_normal_boot; " \
"else " \
"echo BCB: Normal boot requested...; " \
"run emmc_android_normal_boot; " \
"fi; " \
"else " \
"echo Warning: BCB is corrupted or does not exist; " \
"echo Performing normal boot...; " \
"run emmc_android_normal_boot; " \
"fi;\0" \
"emmc_android_normal_boot=" \ "echo Trying to boot Android from eMMC ...; " \ "run update_to_fit; " \ "setenv eval_bootargs setenv bootargs $bootargs; " \
@@ -176,8 +201,7 @@ "if test ${dofastboot} -eq 1; then " \ "echo Boot fastboot requested, resetting dofastboot ...;" \ "setenv dofastboot 0; saveenv;" \
"echo Booting into fastboot ...; " \
"fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
FASTBOOT_CMD \ "fi;" \ "if test ${boot_fit} -eq 1; then " \ "run update_to_fit;" \
-- 2.20.1
participants (1)
-
Sam Protsenko