[PATCH v3 3/3] fastboot: Add default fastboot_set_reboot_flag implementation
Roman Stratiienko
r.stratiienko at gmail.com
Sat Jun 13 22:00:14 CEST 2020
Hi Roman,
ср, 10 июн. 2020 г. в 19:37, Roman Kovalivskyi
<roman.kovalivskyi at globallogic.com>:
>
> 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 at globallogic.com>
> ---
> drivers/fastboot/Kconfig | 9 +++++++
> drivers/fastboot/Makefile | 1 +
> drivers/fastboot/fb_bcb_impl.c | 48 ++++++++++++++++++++++++++++++++++
> 3 files changed, 58 insertions(+)
> create mode 100644 drivers/fastboot/fb_bcb_impl.c
It was my comment to move the logic out of fb_comon.c to a separate file,
but it can look more natural in cmd/bcb.c under #ifdef. It is not a
critical requirement from
my side, and if you do not agree, just ignore it.
>
> diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
> index d4436dfc9173..bcb43bc5d556 100644
> --- a/drivers/fastboot/Kconfig
> +++ b/drivers/fastboot/Kconfig
> @@ -165,6 +165,15 @@ config FASTBOOT_CMD_OEM_FORMAT
> relies on the env variable partitions to contain the list of
> partitions as required by the gpt command.
>
> +config FASTBOOT_USE_BCB_SET_REBOOT_FLAG
> + bool "Enable default fastboot_set_reboot_flag implementation"
Description is not clear. Consider "Use BCB by fastboot to set boot reason"
> + depends on CMD_BCB && !ARCH_MESON && !ARCH_ROCKCHIP && !TARGET_KC1 && \
> + !TARGET_SNIPER && !TARGET_AM57XX_EVM && !TARGET_DRA7XX_EVM
> + default 1
Should be 'y'
> + help
> + Add default implementation of fastboot_set_reboot_flag that uses
> + "bcb" commands.
Fix indents. should be tab+2 spaces. Also help can be more verbose.
Regards,
Roman Stratiienko
> +
> endif # FASTBOOT
>
> endmenu
> diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile
> index 048af5aa8234..2b2c390fe4de 100644
> --- a/drivers/fastboot/Makefile
> +++ b/drivers/fastboot/Makefile
> @@ -5,3 +5,4 @@ obj-y += fb_getvar.o
> obj-y += fb_command.o
> obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o
> obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o
> +obj-$(CONFIG_FASTBOOT_USE_BCB_SET_REBOOT_FLAG) += fb_bcb_impl.o
> diff --git a/drivers/fastboot/fb_bcb_impl.c b/drivers/fastboot/fb_bcb_impl.c
> new file mode 100644
> index 000000000000..a5ae94e2e357
> --- /dev/null
> +++ b/drivers/fastboot/fb_bcb_impl.c
> @@ -0,0 +1,48 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2020 GlobalLogic.
> + * Roman Kovalivskyi <roman.kovalivskyi at 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)
> +{
> + static const char * const boot_cmds[] = {
> + "bootonce-bootloader",
> + "boot-fastboot",
> + "boot-recovery"
> + };
> +
> + char cmd[32];
> +
> + 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", boot_cmds[reason]);
> +
> + if (run_command(cmd, 0))
> + return -ENOEXEC;
> +
> + if (run_command("bcb store", 0))
> + return -EIO;
> +
> + return 0;
> +}
> --
> 2.17.1
>
More information about the U-Boot
mailing list