diff options
author | Roman Kovalivskyi <roman.kovalivskyi@globallogic.com> | 2020-07-28 23:35:34 +0300 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2020-09-01 14:47:43 +0200 |
commit | 0ebf9842e56c5b8cb7cb1f990bb452cc14af6225 (patch) | |
tree | ebf946bbe1c92eadb323856ff9471b21732e85f2 /drivers/fastboot/fb_bcb_impl.c | |
parent | 2b2a771b40876c3db456705d5dcc5b60249d4075 (diff) |
fastboot: Add default fastboot_set_reboot_flag implementation
Default implementation of fastboot_set_reboot_flag function that depends
on "bcb" commands could be used in general case if there are no need to
make any platform-specific implementation, otherwise it could be
disabled via Kconfig option FASTBOOT_USE_BCB_SET_REBOOT_FLAG.
Please note that FASTBOOT_USE_BCB_SET_REBOOT_FLAG is mutually exclusive
with some platforms which already have their own implementation of this
function.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Diffstat (limited to 'drivers/fastboot/fb_bcb_impl.c')
-rw-r--r-- | drivers/fastboot/fb_bcb_impl.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/fastboot/fb_bcb_impl.c b/drivers/fastboot/fb_bcb_impl.c new file mode 100644 index 00000000000..89ec3601b6f --- /dev/null +++ b/drivers/fastboot/fb_bcb_impl.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2020 GlobalLogic. + * Roman Kovalivskyi <roman.kovalivskyi@globallogic.com> + */ + +#include <common.h> +#include <fastboot.h> + +/** + * fastboot_set_reboot_flag() - Set flag to indicate reboot-bootloader + * + * Set flag which indicates that we should reboot into the bootloader + * following the reboot that fastboot executes after this function. + * + * This function should be overridden in your board file with one + * which sets whatever flag your board specific Android bootloader flow + * requires in order to re-enter the bootloader. + */ +int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason) +{ + char cmd[64]; + + if (reason >= FASTBOOT_REBOOT_REASONS_COUNT) + return -EINVAL; + + snprintf(cmd, sizeof(cmd), "bcb load %d misc", + CONFIG_FASTBOOT_FLASH_MMC_DEV); + + if (run_command(cmd, 0)) + return -ENODEV; + + snprintf(cmd, sizeof(cmd), "bcb set command %s", + fastboot_boot_cmds[reason]); + + if (run_command(cmd, 0)) + return -ENOEXEC; + + if (run_command("bcb store", 0)) + return -EIO; + + return 0; +} |