]>
Commit | Line | Data |
---|---|---|
a006a5de ŁM |
1 | /* |
2 | * cmd_dfu.c -- dfu command | |
3 | * | |
c2c146fb LM |
4 | * Copyright (C) 2015 |
5 | * Lukasz Majewski <[email protected]> | |
6 | * | |
a006a5de ŁM |
7 | * Copyright (C) 2012 Samsung Electronics |
8 | * authors: Andrzej Pietrasiewicz <[email protected]> | |
9 | * Lukasz Majewski <[email protected]> | |
10 | * | |
1a459660 | 11 | * SPDX-License-Identifier: GPL-2.0+ |
a006a5de ŁM |
12 | */ |
13 | ||
14 | #include <common.h> | |
0a9ac5cb | 15 | #include <watchdog.h> |
a006a5de | 16 | #include <dfu.h> |
24b852a7 | 17 | #include <console.h> |
a006a5de | 18 | #include <g_dnl.h> |
16297cfb | 19 | #include <usb.h> |
c2c146fb | 20 | #include <net.h> |
a006a5de ŁM |
21 | |
22 | static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) | |
23 | { | |
1cc03c5c | 24 | |
16297cfb MZ |
25 | if (argc < 4) |
26 | return CMD_RET_USAGE; | |
27 | ||
28 | char *usb_controller = argv[1]; | |
29 | char *interface = argv[2]; | |
30 | char *devstring = argv[3]; | |
31 | ||
05341a87 | 32 | int ret; |
c2c146fb LM |
33 | #ifdef CONFIG_DFU_TFTP |
34 | unsigned long addr = 0; | |
35 | if (!strcmp(argv[1], "tftp")) { | |
36 | if (argc == 5) | |
37 | addr = simple_strtoul(argv[4], NULL, 0); | |
38 | ||
39 | return update_tftp(addr, interface, devstring); | |
40 | } | |
41 | #endif | |
a006a5de | 42 | |
dd64827e | 43 | ret = dfu_init_env_entities(interface, devstring); |
a006a5de | 44 | if (ret) |
afb8e71c | 45 | goto done; |
a006a5de | 46 | |
afb8e71c | 47 | ret = CMD_RET_SUCCESS; |
16297cfb | 48 | if (argc > 4 && strcmp(argv[4], "list") == 0) { |
a006a5de ŁM |
49 | dfu_show_entities(); |
50 | goto done; | |
51 | } | |
52 | ||
16297cfb | 53 | int controller_index = simple_strtoul(usb_controller, NULL, 0); |
1cc03c5c | 54 | |
05341a87 | 55 | run_usb_dnl_gadget(controller_index, "usb_dnl_dfu"); |
6bed7ce5 | 56 | |
a006a5de ŁM |
57 | done: |
58 | dfu_free_entities(); | |
afb8e71c | 59 | return ret; |
a006a5de ŁM |
60 | } |
61 | ||
62 | U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu, | |
63 | "Device Firmware Upgrade", | |
16297cfb MZ |
64 | "<USB_controller> <interface> <dev> [list]\n" |
65 | " - device firmware upgrade via <USB_controller>\n" | |
66 | " on device <dev>, attached to interface\n" | |
67 | " <interface>\n" | |
68 | " [list] - list available alt settings\n" | |
c2c146fb LM |
69 | #ifdef CONFIG_DFU_TFTP |
70 | "dfu tftp <interface> <dev> [<addr>]\n" | |
71 | " - device firmware upgrade via TFTP\n" | |
72 | " on device <dev>, attached to interface\n" | |
73 | " <interface>\n" | |
74 | " [<addr>] - address where FIT image has been stored\n" | |
75 | #endif | |
a006a5de | 76 | ); |