]> Git Repo - u-boot.git/blame_incremental - cmd/dfu.c
Merge tag 'u-boot-dfu-20240419' of https://source.denx.de/u-boot/custodians/u-boot-dfu
[u-boot.git] / cmd / dfu.c
... / ...
CommitLineData
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * cmd_dfu.c -- dfu command
4 *
5 * Copyright (C) 2015
6 * Lukasz Majewski <[email protected]>
7 *
8 * Copyright (C) 2012 Samsung Electronics
9 * authors: Andrzej Pietrasiewicz <[email protected]>
10 * Lukasz Majewski <[email protected]>
11 */
12
13#include <common.h>
14#include <command.h>
15#include <watchdog.h>
16#include <dfu.h>
17#include <console.h>
18#include <g_dnl.h>
19#include <usb.h>
20#include <net.h>
21
22static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
23{
24
25 if (argc < 2)
26 return CMD_RET_USAGE;
27
28#ifdef CONFIG_DFU_OVER_USB
29 char *usb_controller = argv[1];
30#endif
31 char *interface = NULL;
32 char *devstring = NULL;
33#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
34 unsigned long value = 0;
35#endif
36 if (argc >= 4) {
37 interface = argv[2];
38 devstring = argv[3];
39 }
40
41#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
42 if (argc == 5 || argc == 3)
43 value = simple_strtoul(argv[argc - 1], NULL, 0);
44#endif
45
46 int ret = 0;
47#ifdef CONFIG_DFU_OVER_TFTP
48 if (!strcmp(argv[1], "tftp"))
49 return update_tftp(value, interface, devstring);
50#endif
51 ret = dfu_init_env_entities(interface, devstring);
52 if (ret)
53 goto done;
54
55#ifdef CONFIG_DFU_TIMEOUT
56 dfu_set_timeout(value * 1000);
57#endif
58
59 ret = CMD_RET_SUCCESS;
60 if (strcmp(argv[argc - 1], "list") == 0) {
61 dfu_show_entities();
62 goto done;
63 }
64
65#ifdef CONFIG_DFU_OVER_USB
66 int controller_index = simple_strtoul(usb_controller, NULL, 0);
67 bool retry = false;
68 do {
69 ret = run_usb_dnl_gadget(controller_index, "usb_dnl_dfu");
70
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);
79
80#endif
81done:
82 dfu_free_entities();
83 return ret;
84}
85
86U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
87 "Device Firmware Upgrade",
88 ""
89#ifdef CONFIG_DFU_OVER_USB
90#ifdef CONFIG_DFU_TIMEOUT
91 "<USB_controller> [<interface> <dev>] [<timeout>] [list]\n"
92#else
93 "<USB_controller> [<interface> <dev>] [list]\n"
94#endif
95 " - device firmware upgrade via <USB_controller>\n"
96 " on device <dev>, attached to interface\n"
97 " <interface>\n"
98#ifdef CONFIG_DFU_TIMEOUT
99 " [<timeout>] - specify inactivity timeout in seconds\n"
100#endif
101#endif
102 " [list] - list available alt settings\n"
103#ifdef CONFIG_DFU_OVER_TFTP
104#ifdef CONFIG_DFU_OVER_USB
105 "dfu "
106#endif
107 "tftp [<interface> <dev>] [<addr>]\n"
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
113);
This page took 0.025881 seconds and 4 git commands to generate.