mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Eric Bénard" <eric@eukrea.com>
To: barebox@lists.infradead.org
Subject: [PATCH 2/4] dfu: fill bwPollTimeout and better handle detach
Date: Tue,  3 Jan 2012 17:59:27 +0100	[thread overview]
Message-ID: <1325609969-21471-2-git-send-email-eric@eukrea.com> (raw)
In-Reply-To: <1325609969-21471-1-git-send-email-eric@eukrea.com>

- bwPollTimeout is set to 10 ms, from the DFU spec, this
is the minimum time, in milliseconds, that the host should
wait before sending a subsequent DFU_GETSTATUS request.
Without this, I get 25 seconds value and dfu-util waits twice 25s
during download
- when in IDEL and receiving DETACH, first return 0 to make
dfu-util happy, then use a dfudetach variable to exit dfu
(without an USB reset as per the comment on line 425) and
return to runtime mode.
- tested on i.MX25 & i.MX35

Signed-off-by: Eric Bénard <eric@eukrea.com>
---
 drivers/usb/gadget/dfu.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c
index 0a0d244..f26c1e4 100644
--- a/drivers/usb/gadget/dfu.c
+++ b/drivers/usb/gadget/dfu.c
@@ -67,6 +67,7 @@ static int dfualt;
 static int dfufd = -EINVAL;;
 static struct usb_dfu_dev *dfu_devs;
 static int dfu_num_alt;
+static int dfudetach;
 
 /* USB DFU functional descriptor */
 static struct usb_dfu_func_descriptor usb_dfu_func = {
@@ -204,6 +205,9 @@ static int dfu_status(struct usb_function *f, const struct usb_ctrlrequest *ctrl
 	dstat->bStatus = dfu->dfu_status;
 	dstat->bState  = dfu->dfu_state;
 	dstat->iString = 0;
+	dstat->bwPollTimeout[0] = 10;
+	dstat->bwPollTimeout[1] = 0;
+	dstat->bwPollTimeout[2] = 0;
 
 	return sizeof(*dstat);
 }
@@ -425,6 +429,8 @@ static int dfu_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
 			 * least the Linux USB stack likes to send a number of resets
 			 * in a row :( */
 			dfu->dfu_state = DFU_STATE_dfuMANIFEST_WAIT_RST;
+			value = 0;
+			dfudetach = 1;
 			break;
 		default:
 			dfu->dfu_state = DFU_STATE_dfuERROR;
@@ -690,11 +696,12 @@ int usb_dfu_register(struct usb_dfu_pdata *pdata)
 
 	while (1) {
 		usb_gadget_poll();
-		if (ctrlc())
+		if (ctrlc() || dfudetach)
 			goto out;
 	}
 
 out:
+	dfudetach = 0;
 	usb_composite_unregister(&dfu_driver);
 
 	return 0;
-- 
1.7.7.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-01-03 16:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-03 16:59 [PATCH 1/4] fsl_udc: update and fix Eric Bénard
2012-01-03 16:59 ` Eric Bénard [this message]
2012-01-04  9:05   ` [PATCH 2/4] dfu: fill bwPollTimeout and better handle detach Jean-Christophe PLAGNIOL-VILLARD
2012-01-03 16:59 ` [PATCH 3/4] serial gadget: enable/disable on request Eric Bénard
2012-01-03 20:52   ` [PATCH v2 " Eric Bénard
2012-01-04  8:00     ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-04  8:11       ` Eric Bénard
2012-01-04  8:57         ` Sascha Hauer
2012-01-04  8:17     ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-04  8:31       ` [PATCH v3 " Eric Bénard
2012-01-04  9:03         ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-03 16:59 ` [PATCH 4/4] eukrea_cpuimx35: fix compilation when CONFIG_USB_GADGET is enabled Eric Bénard
2012-01-04  9:03 ` [PATCH 1/4] fsl_udc: update and fix Sascha Hauer
2012-01-04  9:19   ` Eric Bénard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325609969-21471-2-git-send-email-eric@eukrea.com \
    --to=eric@eukrea.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox