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>
21 static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
27 #ifdef CONFIG_DFU_OVER_USB
28 char *usb_controller = argv[1];
30 char *interface = NULL;
31 char *devstring = NULL;
32 #if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
33 unsigned long value = 0;
40 #if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
41 if (argc == 5 || argc == 3)
42 value = simple_strtoul(argv[argc - 1], NULL, 0);
46 #ifdef CONFIG_DFU_OVER_TFTP
47 if (!strcmp(argv[1], "tftp"))
48 return update_tftp(value, interface, devstring);
50 ret = dfu_init_env_entities(interface, devstring);
54 #ifdef CONFIG_DFU_TIMEOUT
55 dfu_set_timeout(value * 1000);
58 ret = CMD_RET_SUCCESS;
59 if (strcmp(argv[argc - 1], "list") == 0) {
64 #ifdef CONFIG_DFU_OVER_USB
65 int controller_index = simple_strtoul(usb_controller, NULL, 0);
68 ret = run_usb_dnl_gadget(controller_index, "usb_dnl_dfu");
70 if (dfu_reinit_needed) {
72 ret = dfu_init_env_entities(interface, devstring);
85 U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
86 "Device Firmware Upgrade",
88 #ifdef CONFIG_DFU_OVER_USB
89 #ifdef CONFIG_DFU_TIMEOUT
90 "<USB_controller> [<interface> <dev>] [<timeout>] [list]\n"
92 "<USB_controller> [<interface> <dev>] [list]\n"
94 " - device firmware upgrade via <USB_controller>\n"
95 " on device <dev>, attached to interface\n"
97 #ifdef CONFIG_DFU_TIMEOUT
98 " [<timeout>] - specify inactivity timeout in seconds\n"
101 " [list] - list available alt settings\n"
102 #ifdef CONFIG_DFU_OVER_TFTP
103 #ifdef CONFIG_DFU_OVER_USB
106 "tftp [<interface> <dev>] [<addr>]\n"
107 " - device firmware upgrade via TFTP\n"
108 " on device <dev>, attached to interface\n"
110 " [<addr>] - address where FIT image has been stored\n"