Skip to contentSkip to conversation

usb: dfu: make nand upload working

RFC PATCH New Bo Shen 3 participants 6 messages Oct 12, 2013 – Nov 1, 2013

lore
Share & tools
lore

Bo Shen

author
#0 lore raw

RFC PATCH 1/1 usb: dfu: make nand upload working

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.

---
 drivers/dfu/dfu.c |    1 +
 1 file changed, 1 insertion(+)
drivers/dfu/dfu.c +1 -0
index 56b21c7..3c3ad1b 100644
@@ -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__);
Signature · 1 line
1.7.9.5
#1 lore raw

RFC PATCH 1/1 usb: dfu: make nand upload working

Quoted 15 lines · On Sat, 12 Oct 2013 15:47:14 +0800 Bo Shen <[email protected]> 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.

---
 drivers/dfu/dfu.c |    1 +
 1 file changed, 1 insertion(+)
drivers/dfu/dfu.c +0 -0
index 56b21c7..3c3ad1b 100644

drivers/dfu/dfu.c int dfu_read(struct dfu_entity *dfu, void *buf, · line 277

Quoted 4 lines
drivers/dfu/dfu.c +1 -0
@@ -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.

Quoted 4 lines
drivers/dfu/dfu.c +0 -0
 		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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131012/bd8b9cf4/attachment.pgp>

#2 lore raw

RFC PATCH 1/1 usb: dfu: make nand upload working

Dear Lukasz Majewski,

Quoted 21 lines

On Sat, 12 Oct 2013 15:47:14 +0800

Quoted 18 lines · Bo Shen

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.

---

 drivers/dfu/dfu.c |    1 +
 1 file changed, 1 insertion(+)
drivers/dfu/dfu.c +0 -0
index 56b21c7..3c3ad1b 100644
@@ -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)
 
Quoted 9 lines

drivers/dfu/dfu.c int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) · line 277

Quoted 3 lines
drivers/dfu/dfu.c +1 -0
 			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

author
#3 lore raw

RFC PATCH 1/1 usb: dfu: make nand upload working

In reply to Lukasz Majewski

Hi Lukasz Majewski,

Quoted 21 lines · Lukasz Majewski
Quoted 18 lines · On Sat, 12 Oct 2013 15:47:14 +0800 Bo Shen <[email protected]> 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.

---
  drivers/dfu/dfu.c |    1 +
  1 file changed, 1 insertion(+)
drivers/dfu/dfu.c +0 -0
index 56b21c7..3c3ad1b 100644
@@ -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;
 
Quoted 6 lines

drivers/dfu/dfu.c int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) · line 277

Quoted 1 line
drivers/dfu/dfu.c +1 -0
+		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.

Quoted 9 lines
Quoted 4 lines
drivers/dfu/dfu.c +0 -0
  		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

author
#4 lore raw

RFC PATCH 1/1 usb: dfu: make nand upload working

Hi Lukasz Majewski,

Quoted 29 lines · Bo Shen

Hi Lukasz Majewski,

Quoted 26 lines · Lukasz Majewski
Quoted 15 lines · On Sat, 12 Oct 2013 15:47:14 +0800 Bo Shen <[email protected]> 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.

---
  drivers/dfu/dfu.c |    1 +
  1 file changed, 1 insertion(+)
drivers/dfu/dfu.c +0 -0
index 56b21c7..3c3ad1b 100644

drivers/dfu/dfu.c int dfu_read(struct dfu_entity *dfu, void *buf, · line 277

Quoted 4 lines
drivers/dfu/dfu.c +1 -0
@@ -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).

Quoted 4 lines
Quoted 1 line

Such code shall be added to dfu_nand.c file.

Thanks for point out this.
I will check it.

After read more deeply into dfu core code, even we move this patch to nand related code as following.
I think this only a workaround for NAND uploading, because it the same as mmc uploading, need the dfu buffer size equal or larger than the upload file size or partition size.
So, does this acceptable? If acceptable, I will send v2.

---8>---

drivers/dfu/dfu_nand.c +0 -0
@@ -121,6 +121,7 @@ static int dfu_read_medium_nand(struct dfu_entity 

*dfu, u64 offset, void *buf,

         switch (dfu->layout) {
         case DFU_RAW_ADDR:
+               *len = dfu->data.nand.size;
                 ret = nand_block_read(dfu, offset, buf, len);
                 break;
         default:

---<8---

Best Regards,
Bo Shen

author
#5 lore raw

RFC PATCH 1/1 usb: dfu: make nand upload working

Hi Lukasz,

Quoted 37 lines · Bo Shen

Hi Lukasz Majewski,

Quoted 29 lines · Bo Shen

Hi Lukasz Majewski,

Quoted 26 lines · Lukasz Majewski
Quoted 15 lines · On Sat, 12 Oct 2013 15:47:14 +0800 Bo Shen <[email protected]> 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.

---
  drivers/dfu/dfu.c |    1 +
  1 file changed, 1 insertion(+)
drivers/dfu/dfu.c +0 -0
index 56b21c7..3c3ad1b 100644

drivers/dfu/dfu.c int dfu_read(struct dfu_entity *dfu, void *buf, · line 277

Quoted 4 lines
drivers/dfu/dfu.c +1 -0
@@ -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).

Quoted 4 lines
Quoted 1 line

Such code shall be added to dfu_nand.c file.

Thanks for point out this.
I will check it.

Quoted 6 lines

After read more deeply into dfu core code, even we move this patch to nand related code as following.
I think this only a workaround for NAND uploading, because it the same as mmc uploading, need the dfu buffer size equal or larger than the upload file size or partition size.
So, does this acceptable? If acceptable, I will send v2.

Would it possible to check this for NAND uploading?

Quoted 14 lines

---8>---

drivers/dfu/dfu_nand.c +1 -0
@@ -121,6 +121,7 @@ static int dfu_read_medium_nand(struct dfu_entity
 *dfu, u64 offset, void *buf,
 
         switch (dfu->layout) {
         case DFU_RAW_ADDR:
+               *len = dfu->data.nand.size;
                 ret = nand_block_read(dfu, offset, buf, len);
                 break;

default:
---<8---

Quoted 2 lines

Best Regards,
Bo Shen

Best Regards,
Bo Shen