Blame view
cmd/dfu.c
1.7 KB
a006a5dea
|
1 2 3 |
/* * cmd_dfu.c -- dfu command * |
c2c146fb8
|
4 5 6 |
* Copyright (C) 2015 * Lukasz Majewski <l.majewski@majess.pl> * |
a006a5dea
|
7 8 9 10 |
* Copyright (C) 2012 Samsung Electronics * authors: Andrzej Pietrasiewicz <andrzej.p@samsung.com> * Lukasz Majewski <l.majewski@samsung.com> * |
1a4596601
|
11 |
* SPDX-License-Identifier: GPL-2.0+ |
a006a5dea
|
12 13 14 |
*/ #include <common.h> |
0a9ac5cb5
|
15 |
#include <watchdog.h> |
a006a5dea
|
16 |
#include <dfu.h> |
24b852a7a
|
17 |
#include <console.h> |
a006a5dea
|
18 |
#include <g_dnl.h> |
16297cfb2
|
19 |
#include <usb.h> |
c2c146fb8
|
20 |
#include <net.h> |
a006a5dea
|
21 22 23 |
static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { |
1cc03c5c5
|
24 |
|
16297cfb2
|
25 26 27 28 29 30 |
if (argc < 4) return CMD_RET_USAGE; char *usb_controller = argv[1]; char *interface = argv[2]; char *devstring = argv[3]; |
05341a876
|
31 |
int ret; |
c2c146fb8
|
32 33 34 35 36 37 38 39 40 |
#ifdef CONFIG_DFU_TFTP unsigned long addr = 0; if (!strcmp(argv[1], "tftp")) { if (argc == 5) addr = simple_strtoul(argv[4], NULL, 0); return update_tftp(addr, interface, devstring); } #endif |
a006a5dea
|
41 |
|
dd64827eb
|
42 |
ret = dfu_init_env_entities(interface, devstring); |
a006a5dea
|
43 |
if (ret) |
afb8e71ca
|
44 |
goto done; |
a006a5dea
|
45 |
|
afb8e71ca
|
46 |
ret = CMD_RET_SUCCESS; |
16297cfb2
|
47 |
if (argc > 4 && strcmp(argv[4], "list") == 0) { |
a006a5dea
|
48 49 50 |
dfu_show_entities(); goto done; } |
16297cfb2
|
51 |
int controller_index = simple_strtoul(usb_controller, NULL, 0); |
1cc03c5c5
|
52 |
|
05341a876
|
53 |
run_usb_dnl_gadget(controller_index, "usb_dnl_dfu"); |
6bed7ce56
|
54 |
|
a006a5dea
|
55 56 |
done: dfu_free_entities(); |
afb8e71ca
|
57 |
return ret; |
a006a5dea
|
58 59 60 61 |
} U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu, "Device Firmware Upgrade", |
16297cfb2
|
62 63 64 65 66 67 68 69 70 71 |
"<USB_controller> <interface> <dev> [list] " " - device firmware upgrade via <USB_controller> " " on device <dev>, attached to interface " " <interface> " " [list] - list available alt settings " |
c2c146fb8
|
72 73 74 75 76 77 78 79 80 81 82 83 |
#ifdef CONFIG_DFU_TFTP "dfu tftp <interface> <dev> [<addr>] " " - device firmware upgrade via TFTP " " on device <dev>, attached to interface " " <interface> " " [<addr>] - address where FIT image has been stored " #endif |
a006a5dea
|
84 |
); |