fb_bcb_impl.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2020 GlobalLogic.
  4. * Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
  5. */
  6. #include <common.h>
  7. #include <fastboot.h>
  8. /**
  9. * fastboot_set_reboot_flag() - Set flag to indicate reboot-bootloader
  10. *
  11. * Set flag which indicates that we should reboot into the bootloader
  12. * following the reboot that fastboot executes after this function.
  13. *
  14. * This function should be overridden in your board file with one
  15. * which sets whatever flag your board specific Android bootloader flow
  16. * requires in order to re-enter the bootloader.
  17. */
  18. int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
  19. {
  20. char cmd[64];
  21. if (reason >= FASTBOOT_REBOOT_REASONS_COUNT)
  22. return -EINVAL;
  23. snprintf(cmd, sizeof(cmd), "bcb load %d misc",
  24. CONFIG_FASTBOOT_FLASH_MMC_DEV);
  25. if (run_command(cmd, 0))
  26. return -ENODEV;
  27. snprintf(cmd, sizeof(cmd), "bcb set command %s",
  28. fastboot_boot_cmds[reason]);
  29. if (run_command(cmd, 0))
  30. return -ENOEXEC;
  31. if (run_command("bcb store", 0))
  32. return -EIO;
  33. return 0;
  34. }