]> Git Repo - J-u-boot.git/blame - cmd/dfu.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[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
d678a59d 13#include <common.h>
09140113 14#include <command.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 21
09140113 22static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
a006a5de 23{
1cc03c5c 24
febabe3e 25 if (argc < 2)
16297cfb
MZ
26 return CMD_RET_USAGE;
27
bb4059a5 28#ifdef CONFIG_DFU_OVER_USB
16297cfb 29 char *usb_controller = argv[1];
0f44d335 30#endif
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 if (argc >= 4) {
37 interface = argv[2];
38 devstring = argv[3];
39 }
2b1f8c2b 40
98a8f445 41#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
2b1f8c2b
AS
42 if (argc == 5 || argc == 3)
43 value = simple_strtoul(argv[argc - 1], NULL, 0);
cbc1081d 44#endif
16297cfb 45
0f44d335 46 int ret = 0;
bb4059a5 47#ifdef CONFIG_DFU_OVER_TFTP
2b1f8c2b
AS
48 if (!strcmp(argv[1], "tftp"))
49 return update_tftp(value, interface, devstring);
c2c146fb 50#endif
dd64827e 51 ret = dfu_init_env_entities(interface, devstring);
a006a5de 52 if (ret)
afb8e71c 53 goto done;
a006a5de 54
98a8f445
AS
55#ifdef CONFIG_DFU_TIMEOUT
56 dfu_set_timeout(value * 1000);
57#endif
58
afb8e71c 59 ret = CMD_RET_SUCCESS;
febabe3e 60 if (strcmp(argv[argc - 1], "list") == 0) {
a006a5de
ŁM
61 dfu_show_entities();
62 goto done;
63 }
64
e9b0fd83 65#ifdef CONFIG_DFU_OVER_USB
16297cfb 66 int controller_index = simple_strtoul(usb_controller, NULL, 0);
9129f2f1
MS
67 bool retry = false;
68 do {
74fe3f2e 69 ret = run_usb_dnl_gadget(controller_index, "usb_dnl_dfu");
1cc03c5c 70
9129f2f1
MS
71 if (dfu_reinit_needed) {
72 dfu_free_entities();
73 ret = dfu_init_env_entities(interface, devstring);
74 if (ret)
75 goto done;
76 retry = true;
77 }
78 } while (retry);
6bed7ce5 79
e9b0fd83 80#endif
a006a5de
ŁM
81done:
82 dfu_free_entities();
afb8e71c 83 return ret;
a006a5de
ŁM
84}
85
86U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
87 "Device Firmware Upgrade",
cbc1081d 88 ""
bb4059a5 89#ifdef CONFIG_DFU_OVER_USB
98a8f445
AS
90#ifdef CONFIG_DFU_TIMEOUT
91 "<USB_controller> [<interface> <dev>] [<timeout>] [list]\n"
92#else
febabe3e 93 "<USB_controller> [<interface> <dev>] [list]\n"
98a8f445 94#endif
16297cfb
MZ
95 " - device firmware upgrade via <USB_controller>\n"
96 " on device <dev>, attached to interface\n"
97 " <interface>\n"
98a8f445
AS
98#ifdef CONFIG_DFU_TIMEOUT
99 " [<timeout>] - specify inactivity timeout in seconds\n"
100#endif
0f44d335 101#endif
e9b0fd83 102 " [list] - list available alt settings\n"
bb4059a5
MV
103#ifdef CONFIG_DFU_OVER_TFTP
104#ifdef CONFIG_DFU_OVER_USB
0f44d335
MV
105 "dfu "
106#endif
febabe3e 107 "tftp [<interface> <dev>] [<addr>]\n"
c2c146fb
LM
108 " - device firmware upgrade via TFTP\n"
109 " on device <dev>, attached to interface\n"
110 " <interface>\n"
111 " [<addr>] - address where FIT image has been stored\n"
112#endif
a006a5de 113);
This page took 0.418755 seconds and 4 git commands to generate.