Patchwork [U-Boot,RFC] usb: dfu: make nand upload working

login
register
mail settings
Submitter Bo Shen
Date Oct. 12, 2013, 7:47 a.m.
Message ID <1381564034-5935-1-git-send-email-voice.shen@atmel.com>
Download mbox | patch
Permalink /patch/282986/
State Superseded
Delegated to: Marek Vasut
Headers show

Comments

Bo Shen - Oct. 12, 2013, 7:47 a.m.
If won't pass value to dfu->r_left, it always 0, make no transfer,
the dfu-util on host side report failed. So, before starting transfer,
pass the value, then nand uploading can work.

Signed-off-by: Bo Shen <voice.shen@atmel.com>

---
 drivers/dfu/dfu.c |    1 +
 1 file changed, 1 insertion(+)
Lukasz Majewski - Oct. 12, 2013, 9:19 p.m.
On Sat, 12 Oct 2013 15:47:14 +0800
Bo Shen <voice.shen@atmel.com> wrote:

> If won't pass value to dfu->r_left, it always 0, make no transfer,
> the dfu-util on host side report failed. So, before starting transfer,
> pass the value, then nand uploading can work.
> 
> Signed-off-by: Bo Shen <voice.shen@atmel.com>
> 
> ---
>  drivers/dfu/dfu.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> index 56b21c7..3c3ad1b 100644
> --- a/drivers/dfu/dfu.c
> +++ b/drivers/dfu/dfu.c
> @@ -274,6 +274,7 @@ int dfu_read(struct dfu_entity *dfu, void *buf,
> int size, int blk_seq_num) if (dfu->i_buf_start == NULL)
>  			return -ENOMEM;
>  
> +		dfu->r_left = dfu->data.nand.size;

Please do not add nand related code to "generic" DFU code. This can
damage DFU operation with other memories (like eMMC).

Such code shall be added to dfu_nand.c file.

>  		ret = dfu->read_medium(dfu, 0, dfu->i_buf_start,
> &dfu->r_left); if (ret != 0) {
>  			debug("%s: failed to get r_left\n",
> __func__);

Best regards,

Lukasz Majewski
Marek Vasut - Oct. 13, 2013, 8:50 p.m.
Dear Lukasz Majewski,

> On Sat, 12 Oct 2013 15:47:14 +0800
> 
> Bo Shen <voice.shen@atmel.com> wrote:
> > If won't pass value to dfu->r_left, it always 0, make no transfer,
> > the dfu-util on host side report failed. So, before starting transfer,
> > pass the value, then nand uploading can work.
> > 
> > Signed-off-by: Bo Shen <voice.shen@atmel.com>
> > 
> > ---
> > 
> >  drivers/dfu/dfu.c |    1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> > index 56b21c7..3c3ad1b 100644
> > --- a/drivers/dfu/dfu.c
> > +++ b/drivers/dfu/dfu.c
> > @@ -274,6 +274,7 @@ int dfu_read(struct dfu_entity *dfu, void *buf,
> > int size, int blk_seq_num) if (dfu->i_buf_start == NULL)
> > 
> >  			return -ENOMEM;
> > 
> > +		dfu->r_left = dfu->data.nand.size;
> 
> Please do not add nand related code to "generic" DFU code. This can
> damage DFU operation with other memories (like eMMC).
> 
> Such code shall be added to dfu_nand.c file.
> 

ACK, waiting for V2.

Lukasz, do you have a suggestion where this should be placed and why is this an 
actual issue?

Best regards,
Marek Vasut
Bo Shen - Oct. 14, 2013, 7:25 a.m.
Hi Lukasz Majewski,

On 10/13/2013 05:19, Lukasz Majewski wrote:
> On Sat, 12 Oct 2013 15:47:14 +0800
> Bo Shen <voice.shen@atmel.com> wrote:
>
>> If won't pass value to dfu->r_left, it always 0, make no transfer,
>> the dfu-util on host side report failed. So, before starting transfer,
>> pass the value, then nand uploading can work.
>>
>> Signed-off-by: Bo Shen <voice.shen@atmel.com>
>>
>> ---
>>   drivers/dfu/dfu.c |    1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
>> index 56b21c7..3c3ad1b 100644
>> --- a/drivers/dfu/dfu.c
>> +++ b/drivers/dfu/dfu.c
>> @@ -274,6 +274,7 @@ int dfu_read(struct dfu_entity *dfu, void *buf,
>> int size, int blk_seq_num) if (dfu->i_buf_start == NULL)
>>   			return -ENOMEM;
>>
>> +		dfu->r_left = dfu->data.nand.size;
>
> Please do not add nand related code to "generic" DFU code. This can
> damage DFU operation with other memories (like eMMC).
>
> Such code shall be added to dfu_nand.c file.

Thanks for point out this.
I will check it.

>>   		ret = dfu->read_medium(dfu, 0, dfu->i_buf_start,
>> &dfu->r_left); if (ret != 0) {
>>   			debug("%s: failed to get r_left\n",
>> __func__);
>
> Best regards,
>
> Lukasz Majewski
>

Best Regards,
Bo Shen

Patch

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 56b21c7..3c3ad1b 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -274,6 +274,7 @@  int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
 		if (dfu->i_buf_start == NULL)
 			return -ENOMEM;
 
+		dfu->r_left = dfu->data.nand.size;
 		ret = dfu->read_medium(dfu, 0, dfu->i_buf_start, &dfu->r_left);
 		if (ret != 0) {
 			debug("%s: failed to get r_left\n", __func__);