]> Git Repo - J-u-boot.git/blame - cmd/dfu.c
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-marvell
[J-u-boot.git] / cmd / dfu.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
a006a5de
ŁM
2/*
3 * cmd_dfu.c -- dfu command
4 *
c2c146fb
LM
5 * Copyright (C) 2015
6 * Lukasz Majewski <[email protected]>
7 *
a006a5de
ŁM
8 * Copyright (C) 2012 Samsung Electronics
9 * authors: Andrzej Pietrasiewicz <[email protected]>
10 * Lukasz Majewski <[email protected]>
a006a5de
ŁM
11 */
12
13#include <common.h>
0a9ac5cb 14#include <watchdog.h>
a006a5de 15#include <dfu.h>
24b852a7 16#include <console.h>
a006a5de 17#include <g_dnl.h>
16297cfb 18#include <usb.h>
c2c146fb 19#include <net.h>
a006a5de
ŁM
20
21static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
22{
1cc03c5c 23
febabe3e 24 if (argc < 2)
16297cfb
MZ
25 return CMD_RET_USAGE;
26
bb4059a5 27#ifdef CONFIG_DFU_OVER_USB
16297cfb 28 char *usb_controller = argv[1];
0f44d335 29#endif
cbc1081d 30#if defined(CONFIG_DFU_OVER_USB) || defined(CONFIG_DFU_OVER_TFTP)
febabe3e
PD
31 char *interface = NULL;
32 char *devstring = NULL;
98a8f445 33#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
2b1f8c2b
AS
34 unsigned long value = 0;
35#endif
febabe3e
PD
36
37 if (argc >= 4) {
38 interface = argv[2];
39 devstring = argv[3];
40 }
2b1f8c2b 41
98a8f445 42#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
2b1f8c2b
AS
43 if (argc == 5 || argc == 3)
44 value = simple_strtoul(argv[argc - 1], NULL, 0);
45#endif
cbc1081d 46#endif
16297cfb 47
0f44d335 48 int ret = 0;
bb4059a5 49#ifdef CONFIG_DFU_OVER_TFTP
2b1f8c2b
AS
50 if (!strcmp(argv[1], "tftp"))
51 return update_tftp(value, interface, devstring);
c2c146fb 52#endif
bb4059a5 53#ifdef CONFIG_DFU_OVER_USB
dd64827e 54 ret = dfu_init_env_entities(interface, devstring);
a006a5de 55 if (ret)
afb8e71c 56 goto done;
a006a5de 57
98a8f445
AS
58#ifdef CONFIG_DFU_TIMEOUT
59 dfu_set_timeout(value * 1000);
60#endif
61
afb8e71c 62 ret = CMD_RET_SUCCESS;
febabe3e 63 if (strcmp(argv[argc - 1], "list") == 0) {
a006a5de
ŁM
64 dfu_show_entities();
65 goto done;
66 }
67
16297cfb 68 int controller_index = simple_strtoul(usb_controller, NULL, 0);
1cc03c5c 69
05341a87 70 run_usb_dnl_gadget(controller_index, "usb_dnl_dfu");
6bed7ce5 71
a006a5de
ŁM
72done:
73 dfu_free_entities();
0f44d335 74#endif
afb8e71c 75 return ret;
a006a5de
ŁM
76}
77
78U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
79 "Device Firmware Upgrade",
cbc1081d 80 ""
bb4059a5 81#ifdef CONFIG_DFU_OVER_USB
98a8f445
AS
82#ifdef CONFIG_DFU_TIMEOUT
83 "<USB_controller> [<interface> <dev>] [<timeout>] [list]\n"
84#else
febabe3e 85 "<USB_controller> [<interface> <dev>] [list]\n"
98a8f445 86#endif
16297cfb
MZ
87 " - device firmware upgrade via <USB_controller>\n"
88 " on device <dev>, attached to interface\n"
89 " <interface>\n"
98a8f445
AS
90#ifdef CONFIG_DFU_TIMEOUT
91 " [<timeout>] - specify inactivity timeout in seconds\n"
92#endif
16297cfb 93 " [list] - list available alt settings\n"
0f44d335 94#endif
bb4059a5
MV
95#ifdef CONFIG_DFU_OVER_TFTP
96#ifdef CONFIG_DFU_OVER_USB
0f44d335
MV
97 "dfu "
98#endif
febabe3e 99 "tftp [<interface> <dev>] [<addr>]\n"
c2c146fb
LM
100 " - device firmware upgrade via TFTP\n"
101 " on device <dev>, attached to interface\n"
102 " <interface>\n"
103 " [<addr>] - address where FIT image has been stored\n"
104#endif
a006a5de 105);
This page took 0.347472 seconds and 4 git commands to generate.