Commit 6bed7ce569fc409843ff2537937ea1b5fd0f694d
Committed by
Marek Vasut
1 parent
6dd30af0fa
Exists in
master
and in
53 other branches
dfu: Implementation of target reset after communication with dfu-util's -R switch
This patch extends dfu code to support transmission with -R switch specified at dfu-util. When -R is specified, the extra USB_REQ_DFU_DETACH request is sent after successful data transmission. Then dfu resources are released and reset command is issued. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Showing 4 changed files with 28 additions and 1 deletions Side-by-side Diff
common/cmd_dfu.c
... | ... | @@ -19,8 +19,8 @@ |
19 | 19 | { |
20 | 20 | const char *str_env; |
21 | 21 | char *s = "dfu"; |
22 | + int ret, i = 0; | |
22 | 23 | char *env_bkp; |
23 | - int ret; | |
24 | 24 | |
25 | 25 | if (argc < 3) |
26 | 26 | return CMD_RET_USAGE; |
... | ... | @@ -49,6 +49,15 @@ |
49 | 49 | |
50 | 50 | g_dnl_register(s); |
51 | 51 | while (1) { |
52 | + if (dfu_reset()) | |
53 | + /* | |
54 | + * This extra number of usb_gadget_handle_interrupts() | |
55 | + * calls is necessary to assure correct transmission | |
56 | + * completion with dfu-util | |
57 | + */ | |
58 | + if (++i == 10) | |
59 | + goto exit; | |
60 | + | |
52 | 61 | if (ctrlc()) |
53 | 62 | goto exit; |
54 | 63 | |
... | ... | @@ -59,6 +68,9 @@ |
59 | 68 | done: |
60 | 69 | dfu_free_entities(); |
61 | 70 | free(env_bkp); |
71 | + | |
72 | + if (dfu_reset()) | |
73 | + run_command("reset", 0); | |
62 | 74 | |
63 | 75 | return CMD_RET_SUCCESS; |
64 | 76 | } |
drivers/dfu/dfu.c
... | ... | @@ -16,8 +16,19 @@ |
16 | 16 | #include <linux/list.h> |
17 | 17 | #include <linux/compiler.h> |
18 | 18 | |
19 | +static bool dfu_reset_request; | |
19 | 20 | static LIST_HEAD(dfu_list); |
20 | 21 | static int dfu_alt_num; |
22 | + | |
23 | +bool dfu_reset(void) | |
24 | +{ | |
25 | + return dfu_reset_request; | |
26 | +} | |
27 | + | |
28 | +void dfu_trigger_reset() | |
29 | +{ | |
30 | + dfu_reset_request = true; | |
31 | +} | |
21 | 32 | |
22 | 33 | static int dfu_find_alt_num(const char *s) |
23 | 34 | { |
drivers/usb/gadget/f_dfu.c
include/dfu.h
... | ... | @@ -109,6 +109,8 @@ |
109 | 109 | const char *dfu_get_layout(enum dfu_layout l); |
110 | 110 | struct dfu_entity *dfu_get_entity(int alt); |
111 | 111 | char *dfu_extract_token(char** e, int *n); |
112 | +void dfu_trigger_reset(void); | |
113 | +bool dfu_reset(void); | |
112 | 114 | |
113 | 115 | int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num); |
114 | 116 | int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num); |