cmd_fastboot.c 901 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. return CMD_RET_FAILURE;
  24. }
  25. while (1) {
  26. if (g_dnl_detach())
  27. break;
  28. if (ctrlc())
  29. break;
  30. usb_gadget_handle_interrupts();
  31. }
  32. g_dnl_unregister();
  33. g_dnl_clear_detach();
  34. return CMD_RET_SUCCESS;
  35. }
  36. U_BOOT_CMD(
  37. fastboot, 1, 0, do_fastboot,
  38. "use USB Fastboot protocol",
  39. "\n"
  40. " - run as a fastboot usb device"
  41. );