]>
git.ipfire.org Git - people/ms/u-boot.git/blob - common/dfu.c
14b60f1fbbb0039b9855cd20ae6eeaa2c9aa4f4d
5 * Lukasz Majewski <l.majewski@majess.pl>
7 * Copyright (C) 2012 Samsung Electronics
8 * authors: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
9 * Lukasz Majewski <l.majewski@samsung.com>
11 * SPDX-License-Identifier: GPL-2.0+
22 int run_usb_dnl_gadget(int usbctrl_index
, char *usb_dnl_gadget
)
24 bool dfu_reset
= false;
27 board_usb_init(usbctrl_index
, USB_INIT_DEVICE
);
29 g_dnl_register(usb_dnl_gadget
);
33 * Check if USB bus reset is performed after detach,
34 * which indicates that -R switch has been passed to
35 * dfu-util. In this case reboot the device
37 if (dfu_usb_get_reset()) {
43 * This extra number of usb_gadget_handle_interrupts()
44 * calls is necessary to assure correct transmission
45 * completion with dfu-util
54 if (dfu_get_defer_flush()) {
56 * Call to usb_gadget_handle_interrupts() is necessary
57 * to act on ZLP OUT transaction from HOST PC after
58 * transmitting the whole file.
60 * If this ZLP OUT packet is NAK'ed, the HOST libusb
61 * function fails after timeout (by default it is set to
62 * 5 seconds). In such situation the dfu-util program
63 * exits with error message.
65 usb_gadget_handle_interrupts(usbctrl_index
);
66 ret
= dfu_flush(dfu_get_defer_flush(), NULL
, 0, 0);
67 dfu_set_defer_flush(NULL
);
69 error("Deferred dfu_flush() failed!");
75 usb_gadget_handle_interrupts(usbctrl_index
);
79 board_usb_cleanup(usbctrl_index
, USB_INIT_DEVICE
);
82 run_command("reset", 0);