* [U-Boot] [PATCH] dfu: Implementation of target reset after communication with dfu-util's -R switch
@ 2013-07-18 11:19 Lukasz Majewski
2013-07-19 4:30 ` Heiko Schocher
2013-07-24 3:37 ` Marek Vasut
0 siblings, 2 replies; 3+ messages in thread
From: Lukasz Majewski @ 2013-07-18 11:19 UTC (permalink / raw)
To: u-boot
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>
---
common/cmd_dfu.c | 14 +++++++++++++-
drivers/dfu/dfu.c | 11 +++++++++++
drivers/usb/gadget/f_dfu.c | 2 ++
include/dfu.h | 2 ++
4 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
index 83ef324..2d5db63 100644
--- a/common/cmd_dfu.c
+++ b/common/cmd_dfu.c
@@ -31,8 +31,8 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
const char *str_env;
char *s = "dfu";
+ int ret, i = 0;
char *env_bkp;
- int ret;
if (argc < 3)
return CMD_RET_USAGE;
@@ -61,6 +61,15 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
g_dnl_register(s);
while (1) {
+ if (dfu_reset())
+ /*
+ * This extra number of usb_gadget_handle_interrupts()
+ * calls is necessary to assure correct transmission
+ * completion with dfu-util
+ */
+ if (++i == 10)
+ goto exit;
+
if (ctrlc())
goto exit;
@@ -72,6 +81,9 @@ done:
dfu_free_entities();
free(env_bkp);
+ if (dfu_reset())
+ run_command("reset", 0);
+
return CMD_RET_SUCCESS;
}
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 0521752..a06db2f 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -28,9 +28,20 @@
#include <linux/list.h>
#include <linux/compiler.h>
+static bool dfu_reset_request;
static LIST_HEAD(dfu_list);
static int dfu_alt_num;
+bool dfu_reset(void)
+{
+ return dfu_reset_request;
+}
+
+void dfu_trigger_reset()
+{
+ dfu_reset_request = true;
+}
+
static int dfu_find_alt_num(const char *s)
{
int i = 0;
diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index d7ae0c0..e869703 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -324,6 +324,8 @@ static int state_dfu_idle(struct f_dfu *f_dfu,
DFU_STATE_dfuMANIFEST_WAIT_RST;
to_runtime_mode(f_dfu);
f_dfu->dfu_state = DFU_STATE_appIDLE;
+
+ dfu_trigger_reset();
break;
default:
f_dfu->dfu_state = DFU_STATE_dfuERROR;
diff --git a/include/dfu.h b/include/dfu.h
index 124653c..b17b80d 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -121,6 +121,8 @@ const char *dfu_get_dev_type(enum dfu_device_type t);
const char *dfu_get_layout(enum dfu_layout l);
struct dfu_entity *dfu_get_entity(int alt);
char *dfu_extract_token(char** e, int *n);
+void dfu_trigger_reset(void);
+bool dfu_reset(void);
int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] dfu: Implementation of target reset after communication with dfu-util's -R switch
2013-07-18 11:19 [U-Boot] [PATCH] dfu: Implementation of target reset after communication with dfu-util's -R switch Lukasz Majewski
@ 2013-07-19 4:30 ` Heiko Schocher
2013-07-24 3:37 ` Marek Vasut
1 sibling, 0 replies; 3+ messages in thread
From: Heiko Schocher @ 2013-07-19 4:30 UTC (permalink / raw)
To: u-boot
Hello Lukasz,
Am 18.07.2013 13:19, schrieb Lukasz Majewski:
> 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>
> ---
> common/cmd_dfu.c | 14 +++++++++++++-
> drivers/dfu/dfu.c | 11 +++++++++++
> drivers/usb/gadget/f_dfu.c | 2 ++
> include/dfu.h | 2 ++
> 4 files changed, 28 insertions(+), 1 deletion(-)
Tested on AM335x based boards, so:
Tested-by: Heiko Schocher <hs@denx.de>
Thanks!
bye,
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] dfu: Implementation of target reset after communication with dfu-util's -R switch
2013-07-18 11:19 [U-Boot] [PATCH] dfu: Implementation of target reset after communication with dfu-util's -R switch Lukasz Majewski
2013-07-19 4:30 ` Heiko Schocher
@ 2013-07-24 3:37 ` Marek Vasut
1 sibling, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2013-07-24 3:37 UTC (permalink / raw)
To: u-boot
Dear Lukasz Majewski,
> 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>
> ---
> common/cmd_dfu.c | 14 +++++++++++++-
> drivers/dfu/dfu.c | 11 +++++++++++
> drivers/usb/gadget/f_dfu.c | 2 ++
> include/dfu.h | 2 ++
> 4 files changed, 28 insertions(+), 1 deletion(-)
>
Applied, thanks
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-24 3:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-18 11:19 [U-Boot] [PATCH] dfu: Implementation of target reset after communication with dfu-util's -R switch Lukasz Majewski
2013-07-19 4:30 ` Heiko Schocher
2013-07-24 3:37 ` Marek Vasut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox