* [PATCH 6/7] DFU : disable state fix
@ 2013-03-12 16:38 Renaud C.
2013-03-13 10:34 ` Cerrato Renaud
0 siblings, 1 reply; 3+ messages in thread
From: Renaud C. @ 2013-03-12 16:38 UTC (permalink / raw)
To: barebox
[-- Attachment #1.1: Type: text/plain, Size: 1246 bytes --]
When an USB_REQ_DFU_DETACH request is received, the device state switch
to DFU_STATE_appDETACH, and then wait for an usb reset to switch
to DFU_STATE_dfuIDLE (through dfu_disable() being called).
I noticed that using dfu-util v0.7 on my AT91SAM9260 board, the programming
failed because of the device not entering the DFU_STATE_dfuIDLE after an
usb reset (staying in the DFU_STATE_appDETACH state).
According to the current implementation, once the USB_REQ_DFU_DETACH is
sent and right after the usb reset, if the DFU client set more than one
configuration (by iterating over them for example), the device state will
reset to the DFU_STATE_appDETACH state on the 2nd iteration because of the
following line in set_config (composite.c, line 362) :
...
if(cdev->config)
reset_config(); // will call dfu_disable() again!
...
The attached patch is a *try* to fix the issue by leaving the device in
the DFU_STATE_dfuIDLE state after an usb reset if already in that
state. dfu-util will complain about the device already in
the DFU_STATE_dfuIDLE on the next start, but everything is still working.
This may need a REVISIT, but since the dfu_disable() gets called on both
configuration change and usb reset, we can't do this easily for now..
[-- Attachment #1.2: Type: text/html, Size: 1567 bytes --]
[-- Attachment #2: dfu-disable-state-fix.patch --]
[-- Type: application/octet-stream, Size: 904 bytes --]
From b0a10ca598c0936f68ec90c88166d474fed1bdd8 Mon Sep 17 00:00:00 2001
From: Cerrato Renaud <r.cerrato@til-technologies.fr>
Date: Mon, 11 Mar 2013 15:34:30 +0100
Subject: [PATCH] dfu disable state fix
---
drivers/usb/gadget/dfu.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c
index e051879..e4af567 100644
--- a/drivers/usb/gadget/dfu.c
+++ b/drivers/usb/gadget/dfu.c
@@ -514,14 +514,12 @@ static void dfu_disable(struct usb_function *f)
struct f_dfu *dfu = func_to_dfu(f);
switch (dfu->dfu_state) {
+ case DFU_STATE_dfuIDLE:
case DFU_STATE_appDETACH:
dfu->dfu_state = DFU_STATE_dfuIDLE;
break;
- case DFU_STATE_dfuMANIFEST_WAIT_RST:
- dfu->dfu_state = DFU_STATE_appIDLE;
- break;
default:
- dfu->dfu_state = DFU_STATE_appDETACH;
+ dfu->dfu_state = DFU_STATE_appIDLE;
break;
}
--
1.7.2.5
[-- Attachment #3: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 6/7] DFU : disable state fix
2013-03-12 16:38 [PATCH 6/7] DFU : disable state fix Renaud C.
@ 2013-03-13 10:34 ` Cerrato Renaud
2013-03-13 12:17 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 1 reply; 3+ messages in thread
From: Cerrato Renaud @ 2013-03-13 10:34 UTC (permalink / raw)
To: barebox
Inlined patch below.
Signed-off-by: Cerrato Renaud <r.cerrato@til-technologies.fr>
---
drivers/usb/gadget/dfu.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c
index e051879..e4af567 100644
--- a/drivers/usb/gadget/dfu.c
+++ b/drivers/usb/gadget/dfu.c
@@ -514,14 +514,12 @@ static void dfu_disable(struct usb_function *f)
struct f_dfu *dfu = func_to_dfu(f);
switch (dfu->dfu_state) {
+ case DFU_STATE_dfuIDLE:
case DFU_STATE_appDETACH:
dfu->dfu_state = DFU_STATE_dfuIDLE;
break;
- case DFU_STATE_dfuMANIFEST_WAIT_RST:
- dfu->dfu_state = DFU_STATE_appIDLE;
- break;
default:
- dfu->dfu_state = DFU_STATE_appDETACH;
+ dfu->dfu_state = DFU_STATE_appIDLE;
break;
}
--
1.7.2.5
On 12/03/2013 17:38, Renaud C. wrote:
> When an USB_REQ_DFU_DETACH request is received, the device state switch to DFU_STATE_appDETACH, and then wait for an usb reset to switch to DFU_STATE_dfuIDLE (through dfu_disable() being called).
>
> I noticed that using dfu-util v0.7 on my AT91SAM9260 board, the programming failed because of the device not entering the DFU_STATE_dfuIDLE after an usb reset (staying in the DFU_STATE_appDETACH state).
>
> According to the current implementation, once the USB_REQ_DFU_DETACH is sent and right after the usb reset, if the DFU client set more than one configuration (by iterating over them for example), the device state will reset to the DFU_STATE_appDETACH state on the 2nd iteration because of the following line in set_config (composite.c, line 362) :
>
> ...
> if(cdev->config)
> reset_config(); // will call dfu_disable() again!
> ...
>
> The attached patch is a *try* to fix the issue by leaving the device in the DFU_STATE_dfuIDLE state after an usb reset if already in that state. dfu-util will complain about the device already in the DFU_STATE_dfuIDLE on the next start, but everything is still working.
>
> This may need a REVISIT, but since the dfu_disable() gets called on both configuration change and usb reset, we can't do this easily for now..
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 6/7] DFU : disable state fix
2013-03-13 10:34 ` Cerrato Renaud
@ 2013-03-13 12:17 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 3+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-03-13 12:17 UTC (permalink / raw)
To: Cerrato Renaud; +Cc: barebox
Hi,
please start a new thread
with patch [0/x] ....
and the patch series as reply
use git-send-email for this
Best Resgards,
J.
On 11:34 Wed 13 Mar , Cerrato Renaud wrote:
> Inlined patch below.
>
>
> Signed-off-by: Cerrato Renaud <r.cerrato@til-technologies.fr>
> ---
> drivers/usb/gadget/dfu.c | 6 ++----
> 1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c
> index e051879..e4af567 100644
> --- a/drivers/usb/gadget/dfu.c
> +++ b/drivers/usb/gadget/dfu.c
> @@ -514,14 +514,12 @@ static void dfu_disable(struct usb_function *f)
> struct f_dfu *dfu = func_to_dfu(f);
>
> switch (dfu->dfu_state) {
> + case DFU_STATE_dfuIDLE:
> case DFU_STATE_appDETACH:
> dfu->dfu_state = DFU_STATE_dfuIDLE;
> break;
> - case DFU_STATE_dfuMANIFEST_WAIT_RST:
> - dfu->dfu_state = DFU_STATE_appIDLE;
> - break;
> default:
> - dfu->dfu_state = DFU_STATE_appDETACH;
> + dfu->dfu_state = DFU_STATE_appIDLE;
> break;
> }
>
> --
> 1.7.2.5
>
>
> On 12/03/2013 17:38, Renaud C. wrote:
> > When an USB_REQ_DFU_DETACH request is received, the device state switch to DFU_STATE_appDETACH, and then wait for an usb reset to switch to DFU_STATE_dfuIDLE (through dfu_disable() being called).
> >
> > I noticed that using dfu-util v0.7 on my AT91SAM9260 board, the programming failed because of the device not entering the DFU_STATE_dfuIDLE after an usb reset (staying in the DFU_STATE_appDETACH state).
> >
> > According to the current implementation, once the USB_REQ_DFU_DETACH is sent and right after the usb reset, if the DFU client set more than one configuration (by iterating over them for example), the device state will reset to the DFU_STATE_appDETACH state on the 2nd iteration because of the following line in set_config (composite.c, line 362) :
> >
> > ...
> > if(cdev->config)
> > reset_config(); // will call dfu_disable() again!
> > ...
> >
> > The attached patch is a *try* to fix the issue by leaving the device in the DFU_STATE_dfuIDLE state after an usb reset if already in that state. dfu-util will complain about the device already in the DFU_STATE_dfuIDLE on the next start, but everything is still working.
> >
> > This may need a REVISIT, but since the dfu_disable() gets called on both configuration change and usb reset, we can't do this easily for now..
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
>
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-13 12:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-12 16:38 [PATCH 6/7] DFU : disable state fix Renaud C.
2013-03-13 10:34 ` Cerrato Renaud
2013-03-13 12:17 ` Jean-Christophe PLAGNIOL-VILLARD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox