Blame view
cmd/dfu.c
2.39 KB
83d290c56 SPDX: Convert all... |
1 |
// SPDX-License-Identifier: GPL-2.0+ |
a006a5dea dfu:cmd: Support ... |
2 3 4 |
/* * cmd_dfu.c -- dfu command * |
c2c146fb8 dfu: command: Ext... |
5 6 7 |
* Copyright (C) 2015 * Lukasz Majewski <l.majewski@majess.pl> * |
a006a5dea dfu:cmd: Support ... |
8 9 10 |
* Copyright (C) 2012 Samsung Electronics * authors: Andrzej Pietrasiewicz <andrzej.p@samsung.com> * Lukasz Majewski <l.majewski@samsung.com> |
a006a5dea dfu:cmd: Support ... |
11 12 13 |
*/ #include <common.h> |
0a9ac5cb5 dfu: cmd: trigger... |
14 |
#include <watchdog.h> |
a006a5dea dfu:cmd: Support ... |
15 |
#include <dfu.h> |
24b852a7a Move console defi... |
16 |
#include <console.h> |
a006a5dea dfu:cmd: Support ... |
17 |
#include <g_dnl.h> |
16297cfb2 usb: new board-sp... |
18 |
#include <usb.h> |
c2c146fb8 dfu: command: Ext... |
19 |
#include <net.h> |
a006a5dea dfu:cmd: Support ... |
20 21 22 |
static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { |
1cc03c5c5 dfu: Provide mean... |
23 |
|
febabe3ed dfu: allow to man... |
24 |
if (argc < 2) |
16297cfb2 usb: new board-sp... |
25 |
return CMD_RET_USAGE; |
bb4059a53 dfu: Rename _FUNC... |
26 |
#ifdef CONFIG_DFU_OVER_USB |
16297cfb2 usb: new board-sp... |
27 |
char *usb_controller = argv[1]; |
0f44d3353 dfu: Fix up the K... |
28 |
#endif |
cbc1081da dfu: Avoid declar... |
29 |
#if defined(CONFIG_DFU_OVER_USB) || defined(CONFIG_DFU_OVER_TFTP) |
febabe3ed dfu: allow to man... |
30 31 |
char *interface = NULL; char *devstring = NULL; |
98a8f445f dfu: Add optional... |
32 |
#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP) |
2b1f8c2bd dfu: Refactor do_... |
33 34 |
unsigned long value = 0; #endif |
febabe3ed dfu: allow to man... |
35 36 37 38 39 |
if (argc >= 4) { interface = argv[2]; devstring = argv[3]; } |
2b1f8c2bd dfu: Refactor do_... |
40 |
|
98a8f445f dfu: Add optional... |
41 |
#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP) |
2b1f8c2bd dfu: Refactor do_... |
42 43 44 |
if (argc == 5 || argc == 3) value = simple_strtoul(argv[argc - 1], NULL, 0); #endif |
cbc1081da dfu: Avoid declar... |
45 |
#endif |
16297cfb2 usb: new board-sp... |
46 |
|
0f44d3353 dfu: Fix up the K... |
47 |
int ret = 0; |
bb4059a53 dfu: Rename _FUNC... |
48 |
#ifdef CONFIG_DFU_OVER_TFTP |
2b1f8c2bd dfu: Refactor do_... |
49 50 |
if (!strcmp(argv[1], "tftp")) return update_tftp(value, interface, devstring); |
c2c146fb8 dfu: command: Ext... |
51 |
#endif |
bb4059a53 dfu: Rename _FUNC... |
52 |
#ifdef CONFIG_DFU_OVER_USB |
dd64827eb dfu: defer parsin... |
53 |
ret = dfu_init_env_entities(interface, devstring); |
a006a5dea dfu:cmd: Support ... |
54 |
if (ret) |
afb8e71ca dfu: free entitie... |
55 |
goto done; |
a006a5dea dfu:cmd: Support ... |
56 |
|
98a8f445f dfu: Add optional... |
57 58 59 |
#ifdef CONFIG_DFU_TIMEOUT dfu_set_timeout(value * 1000); #endif |
afb8e71ca dfu: free entitie... |
60 |
ret = CMD_RET_SUCCESS; |
febabe3ed dfu: allow to man... |
61 |
if (strcmp(argv[argc - 1], "list") == 0) { |
a006a5dea dfu:cmd: Support ... |
62 63 64 |
dfu_show_entities(); goto done; } |
16297cfb2 usb: new board-sp... |
65 |
int controller_index = simple_strtoul(usb_controller, NULL, 0); |
1cc03c5c5 dfu: Provide mean... |
66 |
|
05341a876 common: dfu: sape... |
67 |
run_usb_dnl_gadget(controller_index, "usb_dnl_dfu"); |
6bed7ce56 dfu: Implementati... |
68 |
|
a006a5dea dfu:cmd: Support ... |
69 70 |
done: dfu_free_entities(); |
0f44d3353 dfu: Fix up the K... |
71 |
#endif |
afb8e71ca dfu: free entitie... |
72 |
return ret; |
a006a5dea dfu:cmd: Support ... |
73 74 75 76 |
} U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu, "Device Firmware Upgrade", |
cbc1081da dfu: Avoid declar... |
77 |
"" |
bb4059a53 dfu: Rename _FUNC... |
78 |
#ifdef CONFIG_DFU_OVER_USB |
98a8f445f dfu: Add optional... |
79 80 81 82 |
#ifdef CONFIG_DFU_TIMEOUT "<USB_controller> [<interface> <dev>] [<timeout>] [list] " #else |
febabe3ed dfu: allow to man... |
83 84 |
"<USB_controller> [<interface> <dev>] [list] " |
98a8f445f dfu: Add optional... |
85 |
#endif |
16297cfb2 usb: new board-sp... |
86 87 88 89 90 91 |
" - device firmware upgrade via <USB_controller> " " on device <dev>, attached to interface " " <interface> " |
98a8f445f dfu: Add optional... |
92 93 94 95 |
#ifdef CONFIG_DFU_TIMEOUT " [<timeout>] - specify inactivity timeout in seconds " #endif |
16297cfb2 usb: new board-sp... |
96 97 |
" [list] - list available alt settings " |
0f44d3353 dfu: Fix up the K... |
98 |
#endif |
bb4059a53 dfu: Rename _FUNC... |
99 100 |
#ifdef CONFIG_DFU_OVER_TFTP #ifdef CONFIG_DFU_OVER_USB |
0f44d3353 dfu: Fix up the K... |
101 102 |
"dfu " #endif |
febabe3ed dfu: allow to man... |
103 104 |
"tftp [<interface> <dev>] [<addr>] " |
c2c146fb8 dfu: command: Ext... |
105 106 107 108 109 110 111 112 113 |
" - device firmware upgrade via TFTP " " on device <dev>, attached to interface " " <interface> " " [<addr>] - address where FIT image has been stored " #endif |
a006a5dea dfu:cmd: Support ... |
114 |
); |