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(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
27 #ifdef CONFIG_DFU_OVER_USB
28 char *usb_controller = argv[1];
30 #if defined(CONFIG_DFU_OVER_USB) || defined(CONFIG_DFU_OVER_TFTP)
31 char *interface = NULL;
32 char *devstring = NULL;
33 #if defined(CONFIG_DFU_OVER_TFTP)
34 unsigned long value = 0;
42 #if defined(CONFIG_DFU_OVER_TFTP)
43 if (argc == 5 || argc == 3)
44 value = simple_strtoul(argv[argc - 1], NULL, 0);
49 #ifdef CONFIG_DFU_OVER_TFTP
50 if (!strcmp(argv[1], "tftp"))
51 return update_tftp(value, interface, devstring);
53 #ifdef CONFIG_DFU_OVER_USB
54 ret = dfu_init_env_entities(interface, devstring);
58 ret = CMD_RET_SUCCESS;
59 if (strcmp(argv[argc - 1], "list") == 0) {
64 int controller_index = simple_strtoul(usb_controller, NULL, 0);
66 run_usb_dnl_gadget(controller_index, "usb_dnl_dfu");
74 U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
75 "Device Firmware Upgrade",
77 #ifdef CONFIG_DFU_OVER_USB
78 "<USB_controller> [<interface> <dev>] [list]\n"
79 " - device firmware upgrade via <USB_controller>\n"
80 " on device <dev>, attached to interface\n"
82 " [list] - list available alt settings\n"
84 #ifdef CONFIG_DFU_OVER_TFTP
85 #ifdef CONFIG_DFU_OVER_USB
88 "tftp [<interface> <dev>] [<addr>]\n"
89 " - device firmware upgrade via TFTP\n"
90 " on device <dev>, attached to interface\n"
92 " [<addr>] - address where FIT image has been stored\n"