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.s...@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-u...@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-u...@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

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to