cmd_fastboot.c 948 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2008 - 2009 Windriver, <www.windriver.com>
  3. * Author: Tom Rix <Tom.Rix@windriver.com>
  4. *
  5. * (C) Copyright 2014 Linaro, Ltd.
  6. * Rob Herring <robh@kernel.org>
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #include <common.h>
  11. #include <command.h>
  12. #include <g_dnl.h>
  13. static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
  14. {
  15. int ret;
  16. g_dnl_clear_detach();
  17. ret = g_dnl_register("usb_dnl_fastboot");
  18. if (ret)
  19. return ret;
  20. if (!g_dnl_board_usb_cable_connected()) {
  21. puts("\rUSB cable not detected.\n" \
  22. "Command exit.\n");
  23. g_dnl_unregister();
  24. g_dnl_clear_detach();
  25. return CMD_RET_FAILURE;
  26. }
  27. while (1) {
  28. if (g_dnl_detach())
  29. break;
  30. if (ctrlc())
  31. break;
  32. usb_gadget_handle_interrupts(0);
  33. }
  34. g_dnl_unregister();
  35. g_dnl_clear_detach();
  36. return CMD_RET_SUCCESS;
  37. }
  38. U_BOOT_CMD(
  39. fastboot, 1, 0, do_fastboot,
  40. "use USB Fastboot protocol",
  41. "\n"
  42. " - run as a fastboot usb device"
  43. );