1 // SPDX-License-Identifier: GPL-2.0+
3 * cmd_dfu.c -- dfu command
6 * Lukasz Majewski <l.majewski@majess.pl>
8 * Copyright (C) 2012 Samsung Electronics
9 * authors: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10 * Lukasz Majewski <l.majewski@samsung.com>
22 static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
28 #ifdef CONFIG_DFU_OVER_USB
29 char *usb_controller = argv[1];
31 char *interface = NULL;
32 char *devstring = NULL;
33 #if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
34 unsigned long value = 0;
41 #if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
42 if (argc == 5 || argc == 3)
43 value = simple_strtoul(argv[argc - 1], NULL, 0);
47 #ifdef CONFIG_DFU_OVER_TFTP
48 if (!strcmp(argv[1], "tftp"))
49 return update_tftp(value, interface, devstring);
51 ret = dfu_init_env_entities(interface, devstring);
55 #ifdef CONFIG_DFU_TIMEOUT
56 dfu_set_timeout(value * 1000);
59 ret = CMD_RET_SUCCESS;
60 if (strcmp(argv[argc - 1], "list") == 0) {
65 #ifdef CONFIG_DFU_OVER_USB
66 int controller_index = simple_strtoul(usb_controller, NULL, 0);
69 ret = run_usb_dnl_gadget(controller_index, "usb_dnl_dfu");
71 if (dfu_reinit_needed) {
73 ret = dfu_init_env_entities(interface, devstring);
86 U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
87 "Device Firmware Upgrade",
89 #ifdef CONFIG_DFU_OVER_USB
90 #ifdef CONFIG_DFU_TIMEOUT
91 "<USB_controller> [<interface> <dev>] [<timeout>] [list]\n"
93 "<USB_controller> [<interface> <dev>] [list]\n"
95 " - device firmware upgrade via <USB_controller>\n"
96 " on device <dev>, attached to interface\n"
98 #ifdef CONFIG_DFU_TIMEOUT
99 " [<timeout>] - specify inactivity timeout in seconds\n"
102 " [list] - list available alt settings\n"
103 #ifdef CONFIG_DFU_OVER_TFTP
104 #ifdef CONFIG_DFU_OVER_USB
107 "tftp [<interface> <dev>] [<addr>]\n"
108 " - device firmware upgrade via TFTP\n"
109 " on device <dev>, attached to interface\n"
111 " [<addr>] - address where FIT image has been stored\n"