public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Bo Shen <voice.shen@atmel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH 2/2] usb: dfu: correct dfu buffer inited value
Date: Tue, 5 Nov 2013 17:48:38 +0800	[thread overview]
Message-ID: <5278BEF6.5000301@atmel.com> (raw)
In-Reply-To: <20131104111704.43a3be15@amdc308.digital.local>

Hi Lukasz,

On 11/4/2013 18:17, Lukasz Majewski wrote:
> Hi Bo,
>
>> After dfu buffer is initialized, the buffer should be all available,
>> while not 0. Initialize its value to min(dfu_buf_size, dfu->r_left).
>>
>> Signed-off-by: Bo Shen <voice.shen@atmel.com>
>>
>> ---
>>   drivers/dfu/dfu.c |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
>> index 65c6984..b8c8aa4 100644
>> --- a/drivers/dfu/dfu.c
>> +++ b/drivers/dfu/dfu.c
>> @@ -288,7 +288,7 @@ int dfu_read(struct dfu_entity *dfu, void *buf,
>> int size, int blk_seq_num) dfu->offset = 0;
>>   		dfu->i_buf_end = dfu_get_buf() + dfu_buf_size;
>>   		dfu->i_buf = dfu->i_buf_start;
>> -		dfu->b_left = 0;
>> +		dfu->b_left = min(dfu_buf_size, dfu->r_left);
>>
>
> I've testd in on Trats. It causes dfu read to be performed two times.

Have you apply these two patches together:
[RFC PATCH 1/2] usb: dfu: decrease dfu->r_left along with the transfer
[RFC PATCH 2/2] usb: dfu: correct dfu buffer inited value

I test this with dfu mmc.

Without these two patches, it will read file two times.
--->8---
U-Boot> dfu mmc 0
GADGET DRIVER: usb_dnl_dfu
reading image.bin
3049120 bytes read in 628 ms (4.6 MiB/s)
reading image.bin
3049120 bytes read in 628 ms (4.6 MiB/s)
---8<---

with these two patches, it only read file one time.
--->8---
U-Boot> dfu mmc 0
GADGET DRIVER: usb_dnl_dfu
reading image.bin
3049120 bytes read in 628 ms (4.6 MiB/s)
---8<---

The result is opposite.

> Could you write a more verbose message to explain the problem that you
> are trying to solve? I can _only_ suppose that you want to read/write
> data from/to NAND memory.
>
> So, I'm curious why dfu-util breaks with your setup but works at am335x.
> Both chips are supposed to use dfu_nand.c for performing NAND
> read/write.

For the NAND upload, if without patch: [U-Boot,RFC] usb: dfu: make nand 
upload working (http://patchwork.ozlabs.org/patch/283886/)
It doesn't work at my side. more information as following:
--->8---
$ ./dfu-util -l
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util at lists.gnumonks.org

Found Runtime: [413c:8187] devnum=0, cfg=1, intf=3, alt=0, name="UNDEFINED"
Found DFU: [03eb:6156] devnum=0, cfg=1, intf=0, alt=0, name="sama5d34ek.dtb"
Found DFU: [03eb:6156] devnum=0, cfg=1, intf=0, alt=1, name="uImage"
Found DFU: [03eb:6156] devnum=0, cfg=1, intf=0, alt=2, name="rootfs.ubi"

$ ./dfu-util -d 03eb:6156 -U kernel.image -a 1
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util at lists.gnumonks.org

Filter on vendor = 0x03eb product = 0x6156
Opening DFU capable USB device... ID 03eb:6156
WARNING: Can not find cached DFU functional descriptor
Warning: Assuming DFU version 1.0
Run-time device DFU version 0100
Found DFU: [03eb:6156] devnum=0, cfg=1, intf=0, alt=1, name="uImage"
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuUPLOAD-IDLE, status = 0
aborting previous incomplete transfer
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Error obtaining cached DFU functional descriptor
DFU mode device DFU version 0110
Device returned transfer size 4096
bytes_per_hash=4096
Copying data from DFU device to PC
Starting upload: [] finished!
---8<---

It doesn't transfer anything.

After apply the patch for NAND upload, it works OK. And only perform one 
time reading.

>
>>   		dfu->bad_skip = 0;
>>

Best Regards,
Bo Shen

  reply	other threads:[~2013-11-05  9:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16  9:26 [U-Boot] [RFC PATCH 1/2] usb: dfu: decrease dfu->r_left along with the transfer Bo Shen
2013-10-16  9:26 ` [U-Boot] [RFC PATCH 2/2] usb: dfu: correct dfu buffer inited value Bo Shen
2013-11-04 10:17   ` Lukasz Majewski
2013-11-05  9:48     ` Bo Shen [this message]
2013-11-06  8:54       ` Lukasz Majewski
2013-11-06 13:51         ` Marek Vasut
2013-10-19  0:44 ` [U-Boot] [RFC PATCH 1/2] usb: dfu: decrease dfu->r_left along with the transfer Marek Vasut
2013-10-21 22:24   ` Lukasz Majewski
2013-10-22  2:42     ` Marek Vasut
2013-11-01  1:18       ` Bo Shen

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=5278BEF6.5000301@atmel.com \
    --to=voice.shen@atmel.com \
    --cc=u-boot@lists.denx.de \
    /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