]>
git.ipfire.org Git - people/ms/u-boot.git/blob - common/cmd_dfu.c
2 * cmd_dfu.c -- dfu command
4 * Copyright (C) 2012 Samsung Electronics
5 * authors: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
6 * Lukasz Majewski <l.majewski@samsung.com>
8 * SPDX-License-Identifier: GPL-2.0+
17 static int do_dfu(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
19 bool dfu_reset
= false;
24 char *usb_controller
= argv
[1];
25 char *interface
= argv
[2];
26 char *devstring
= argv
[3];
30 ret
= dfu_init_env_entities(interface
, devstring
);
34 ret
= CMD_RET_SUCCESS
;
35 if (argc
> 4 && strcmp(argv
[4], "list") == 0) {
40 int controller_index
= simple_strtoul(usb_controller
, NULL
, 0);
41 board_usb_init(controller_index
, USB_INIT_DEVICE
);
43 g_dnl_register("usb_dnl_dfu");
47 * Check if USB bus reset is performed after detach,
48 * which indicates that -R switch has been passed to
49 * dfu-util. In this case reboot the device
51 if (dfu_usb_get_reset()) {
57 * This extra number of usb_gadget_handle_interrupts()
58 * calls is necessary to assure correct transmission
59 * completion with dfu-util
69 usb_gadget_handle_interrupts(controller_index
);
73 board_usb_cleanup(controller_index
, USB_INIT_DEVICE
);
78 run_command("reset", 0);
85 U_BOOT_CMD(dfu
, CONFIG_SYS_MAXARGS
, 1, do_dfu
,
86 "Device Firmware Upgrade",
87 "<USB_controller> <interface> <dev> [list]\n"
88 " - device firmware upgrade via <USB_controller>\n"
89 " on device <dev>, attached to interface\n"
91 " [list] - list available alt settings\n"