Skip to contentSkip to conversation

usb:gadget:f_thor: fix write to filesystem by add dfu_flush()

PATCH New Przemyslaw Marczak 3 participants 17 messages Apr 17, 2014 – May 10, 2014 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb:gadget:f_thor: fix write to filesystem by add dfu_flush()

Since dfu read/write operations needs to be flushed manually, writing to filesystem on MMC by thor was broken. MMC raw write actually is working fine because current dfu_flush() function writes filesystem only. This commit adds dfu_flush() to f_thor and now filesystem write is working.

This change was tested on Trats2 board.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>
---
 drivers/usb/gadget/f_thor.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/usb/gadget/f_thor.c +9 -4
index f5c0224..ba47945 100644
@@ -204,14 +204,14 @@ static long long int download_head(unsigned long long total,
 
 static int download_tail(long long int left, int cnt)
 {
+	struct dfu_entity *dfu_entity = dfu_get_entity(alt_setting_num);
 	void *transfer_buffer = dfu_get_buf();
 	int ret;
 
 	debug("%s: left: %llu cnt: %d\n", __func__, left, cnt);
 
 	if (left) {
-		ret = dfu_write(dfu_get_entity(alt_setting_num),
-				transfer_buffer, left, cnt++);
+		ret = dfu_write(dfu_entity, transfer_buffer, left, cnt++);
 		if (ret) {
 			error("DFU write failed [%d]: left: %llu", ret, left);
 			return ret;
@@ -225,11 +225,16 @@ static int download_tail(long long int left, int cnt)
 	 * This also frees memory malloc'ed by dfu_get_buf(), so no explicit
 	 * need fo call dfu_free_buf() is needed.
 	 */
-	ret = dfu_write(dfu_get_entity(alt_setting_num),
-			transfer_buffer, 0, cnt);
+	ret = dfu_write(dfu_entity, transfer_buffer, 0, cnt);
 	if (ret)
 		error("DFU write failed [%d] cnt: %d", ret, cnt);
 
+	ret = dfu_flush(dfu_entity, transfer_buffer, 0, cnt);
+	if (ret) {
+		error("DFU flush failed!");
+		return ret;
+	}
+
 	return ret;
 }
 
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 1/1 usb:gadget:f_thor: fix write to filesystem by add dfu_flush()

Quoted 40 lines · Przemyslaw Marczak

Since dfu read/write operations needs to be flushed manually, writing to filesystem on MMC by thor was broken. MMC raw write actually is working fine because current dfu_flush() function writes filesystem only. This commit adds dfu_flush() to f_thor and now filesystem write is working.

This change was tested on Trats2 board.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>
---
 drivers/usb/gadget/f_thor.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/usb/gadget/f_thor.c +2 -2
index f5c0224..ba47945 100644
@@ -204,14 +204,14 @@ static long long int download_head(unsigned long long
 total,
 
 static int download_tail(long long int left, int cnt)
 {
+	struct dfu_entity *dfu_entity = dfu_get_entity(alt_setting_num);
 	void *transfer_buffer = dfu_get_buf();
 	int ret;
 
 	debug("%s: left: %llu cnt: %d\n", __func__, left, cnt);
 
 	if (left) {
-		ret = dfu_write(dfu_get_entity(alt_setting_num),
-				transfer_buffer, left, cnt++);
+		ret = dfu_write(dfu_entity, transfer_buffer, left, cnt++);
 		if (ret) {
 			error("DFU write failed [%d]: left: %llu", ret, left);
drivers/usb/gadget/f_thor.c +0 -0
 			return ret;

drivers/usb/gadget/f_thor.c static int download_tail(long long int left, int cnt) · line 230

Quoted 8 lines
drivers/usb/gadget/f_thor.c +1 -2
@@ -225,11 +225,16 @@ static int download_tail(long long int left, int cnt)
 	 * This also frees memory malloc'ed by dfu_get_buf(), so no explicit
 	 * need fo call dfu_free_buf() is needed.
 	 */
-	ret = dfu_write(dfu_get_entity(alt_setting_num),
-			transfer_buffer, 0, cnt);
+	ret = dfu_write(dfu_entity, transfer_buffer, 0, cnt);
 	if (ret)
 		error("DFU write failed [%d] cnt: %d", ret, cnt);

Please split this into two patches, one which does cleanup (that's the part above) and one which fixes the functionality (that's the part below).

drivers/usb/gadget/f_thor.c static int download_tail(long long int left, int cnt) · line 239

Quoted 8 lines
drivers/usb/gadget/f_thor.c +6 -0
+	ret = dfu_flush(dfu_entity, transfer_buffer, 0, cnt);
+	if (ret) {
+		error("DFU flush failed!");
+		return ret;
+	}
+
 	return ret;
 }

Best regards,
Marek Vasut

#2 lore raw

PATCH v2 1/2 usb:gadget:f_thor: code cleanup in function download_tail()

In reply to Przemyslaw Marczak

In thor's download_tail() function, dfu_get_entity() is called before each dfu_write() call and the returned entity pointers are the same. So dfu_get_entity() can be called just once and this patch changes this.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

---

Changes v2:
- separate fix and cleanup into two commits

 drivers/usb/gadget/f_thor.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/gadget/f_thor.c +3 -4
index f5c0224..231f9c0 100644
@@ -204,14 +204,14 @@ static long long int download_head(unsigned long long total,
 
 static int download_tail(long long int left, int cnt)
 {
+	struct dfu_entity *dfu_entity = dfu_get_entity(alt_setting_num);
 	void *transfer_buffer = dfu_get_buf();
 	int ret;
 
 	debug("%s: left: %llu cnt: %d\n", __func__, left, cnt);
 
 	if (left) {
-		ret = dfu_write(dfu_get_entity(alt_setting_num),
-				transfer_buffer, left, cnt++);
+		ret = dfu_write(dfu_entity, transfer_buffer, left, cnt++);
 		if (ret) {
 			error("DFU write failed [%d]: left: %llu", ret, left);
 			return ret;
@@ -225,8 +225,7 @@ static int download_tail(long long int left, int cnt)
 	 * This also frees memory malloc'ed by dfu_get_buf(), so no explicit
 	 * need fo call dfu_free_buf() is needed.
 	 */
-	ret = dfu_write(dfu_get_entity(alt_setting_num),
-			transfer_buffer, 0, cnt);
+	ret = dfu_write(dfu_entity, transfer_buffer, 0, cnt);
 	if (ret)
 		error("DFU write failed [%d] cnt: %d", ret, cnt);
 
Signature · 1 line
1.9.1
#3 lore raw

PATCH v2 2/2 usb:gadget:f_thor: fix write to filesystem by add dfu_flush()

Since dfu read/write operations needs to be flushed manually, writing to filesystem on MMC by thor was broken. MMC raw write actually is working fine because current dfu_flush() function writes filesystem only. This commit adds dfu_flush() to f_thor and now filesystem write is working.

This change was tested on Trats2 board.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

---

Changes v2:
- separate fix and cleanup into two commits

 drivers/usb/gadget/f_thor.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/usb/gadget/f_thor.c +6 -0
index 231f9c0..ba47945 100644
@@ -229,6 +229,12 @@ static int download_tail(long long int left, int cnt)
 	if (ret)
 		error("DFU write failed [%d] cnt: %d", ret, cnt);
 
+	ret = dfu_flush(dfu_entity, transfer_buffer, 0, cnt);
+	if (ret) {
+		error("DFU flush failed!");
+		return ret;
+	}
+
 	return ret;
 }
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 2/2 usb:gadget:f_thor: fix write to filesystem by add dfu_flush()

Quoted 6 lines · Przemyslaw Marczak

Since dfu read/write operations needs to be flushed manually, writing to filesystem on MMC by thor was broken. MMC raw write actually is working fine because current dfu_flush() function writes filesystem only. This commit adds dfu_flush() to f_thor and now filesystem write is working.

Quoted 7 lines

This change was tested on Trats2 board.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

Best regards,
Marek Vasut

#5 lore raw

PATCH v2 1/2 usb:gadget:f_thor: code cleanup in function download_tail()

In reply to Przemyslaw Marczak
Quoted 10 lines · Przemyslaw Marczak

In thor's download_tail() function, dfu_get_entity() is called before each dfu_write() call and the returned entity pointers are the same. So dfu_get_entity() can be called just once and this patch changes this.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

Best regards,
Marek Vasut

#6 lore raw

PATCH v3 1/2 usb:gadget:f_thor: code cleanup in function download_tail()

In reply to Przemyslaw Marczak

In thor's download_tail() function, dfu_get_entity() is called before each dfu_write() call and the returned entity pointers are the same. So dfu_get_entity() can be called just once and this patch changes this.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

---
Changes v2:
- separate fix and cleanup into two commits

Changes v3:
- download_tail(): add exit label

---
 drivers/usb/gadget/f_thor.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/usb/gadget/f_thor.c +5 -5
index f5c0224..1190c74 100644
@@ -204,17 +204,17 @@ static long long int download_head(unsigned long long total,
 
 static int download_tail(long long int left, int cnt)
 {
+	struct dfu_entity *dfu_entity = dfu_get_entity(alt_setting_num);
 	void *transfer_buffer = dfu_get_buf();
 	int ret;
 
 	debug("%s: left: %llu cnt: %d\n", __func__, left, cnt);
 
 	if (left) {
-		ret = dfu_write(dfu_get_entity(alt_setting_num),
-				transfer_buffer, left, cnt++);
+		ret = dfu_write(dfu_entity, transfer_buffer, left, cnt++);
 		if (ret) {
 			error("DFU write failed [%d]: left: %llu", ret, left);
-			return ret;
+			goto exit;
 		}
 	}
 
@@ -225,11 +225,11 @@ static int download_tail(long long int left, int cnt)
 	 * This also frees memory malloc'ed by dfu_get_buf(), so no explicit
 	 * need fo call dfu_free_buf() is needed.
 	 */
-	ret = dfu_write(dfu_get_entity(alt_setting_num),
-			transfer_buffer, 0, cnt);
+	ret = dfu_write(dfu_entity, transfer_buffer, 0, cnt);
 	if (ret)
 		error("DFU write failed [%d] cnt: %d", ret, cnt);
 
+exit:
 	return ret;
 }
 
Signature · 1 line
1.9.1
#7 lore raw

PATCH v3 2/2 usb:gadget:f_thor: fix write to filesystem by add dfu_flush()

Since dfu read/write operations needs to be flushed manually, writing to filesystem on MMC by thor was broken. MMC raw write actually is working fine because current dfu_flush() function writes filesystem only. This commit adds dfu_flush() to f_thor and now filesystem write is working.

This change was tested on Trats2 board.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

---
Changes v2:
- separate fix and cleanup into two commits

Changes v3:
- none

---
 drivers/usb/gadget/f_thor.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/gadget/f_thor.c +7 -1
index 1190c74..1420606 100644
@@ -226,8 +226,14 @@ static int download_tail(long long int left, int cnt)
 	 * need fo call dfu_free_buf() is needed.
 	 */
 	ret = dfu_write(dfu_entity, transfer_buffer, 0, cnt);
-	if (ret)
+	if (ret) {
 		error("DFU write failed [%d] cnt: %d", ret, cnt);
+		goto exit;
+	}
+
+	ret = dfu_flush(dfu_entity, transfer_buffer, 0, cnt);
+	if (ret)
+		error("DFU flush failed!");
 
 exit:
 	return ret;
Signature · 1 line
1.9.1
#8 lore raw

PATCH v3 2/2 usb:gadget:f_thor: fix write to filesystem by add dfu_flush()

Hi Przemyslaw,

Quoted 30 lines

Since dfu read/write operations needs to be flushed manually, writing to filesystem on MMC by thor was broken. MMC raw write actually is working fine because current dfu_flush() function writes filesystem only. This commit adds dfu_flush() to f_thor and now filesystem write is working.

This change was tested on Trats2 board.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

---
Changes v2:
- separate fix and cleanup into two commits

Changes v3:
- none

---
 drivers/usb/gadget/f_thor.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/gadget/f_thor.c +0 -0
index 1190c74..1420606 100644

drivers/usb/gadget/f_thor.c static int download_tail(long long int left, int · line 229

Quoted 4 lines
drivers/usb/gadget/f_thor.c +0 -0
@@ -226,8 +226,14 @@ static int download_tail(long long int left, int
 cnt)
 	 * need fo call dfu_free_buf() is needed.
 	 */
 	ret = dfu_write(dfu_entity, transfer_buffer, 0, cnt);

I think this dfu_write() call can be now removed, since what we expect now is to call the dfu_flush() here.

After this change please accordingly update the above comment.

Quoted 12 lines
drivers/usb/gadget/f_thor.c +7 -1
-	if (ret)
+	if (ret) {
 		error("DFU write failed [%d] cnt: %d", ret, cnt);
+		goto exit;
+	}
+
+	ret = dfu_flush(dfu_entity, transfer_buffer, 0, cnt);
+	if (ret)
+		error("DFU flush failed!");
 
 exit:

return ret;

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#9 lore raw

PATCH v3 2/2 usb:gadget:f_thor: fix write to filesystem by add dfu_flush()

Quoted 15 lines · Lukasz Majewski

Hi Przemyslaw,

Quoted 13 lines

Since dfu read/write operations needs to be flushed manually, writing to filesystem on MMC by thor was broken. MMC raw write actually is working fine because current dfu_flush() function writes filesystem only. This commit adds dfu_flush() to f_thor and now filesystem write is working.

This change was tested on Trats2 board.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

Please submit new patches on top of u-boot-usb/master , thanks.

Best regards,
Marek Vasut

#10 lore raw

PATCH v4 1/3 usb:gadget:f_thor: code cleanup in function download_tail()

In reply to Przemyslaw Marczak

In thor's download_tail() function, dfu_get_entity() is called before each dfu_write() call and the returned entity pointers are the same. So dfu_get_entity() can be called just once and this patch changes this.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

---
Changes v2:
- separate fix and cleanup into two commits

Changes v3:
- download_tail(): add exit label

Changes v4:
- none

---
 drivers/usb/gadget/f_thor.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/usb/gadget/f_thor.c +5 -5
index f5c0224..1190c74 100644
@@ -204,17 +204,17 @@ static long long int download_head(unsigned long long total,
 
 static int download_tail(long long int left, int cnt)
 {
+	struct dfu_entity *dfu_entity = dfu_get_entity(alt_setting_num);
 	void *transfer_buffer = dfu_get_buf();
 	int ret;
 
 	debug("%s: left: %llu cnt: %d\n", __func__, left, cnt);
 
 	if (left) {
-		ret = dfu_write(dfu_get_entity(alt_setting_num),
-				transfer_buffer, left, cnt++);
+		ret = dfu_write(dfu_entity, transfer_buffer, left, cnt++);
 		if (ret) {
 			error("DFU write failed [%d]: left: %llu", ret, left);
-			return ret;
+			goto exit;
 		}
 	}
 
@@ -225,11 +225,11 @@ static int download_tail(long long int left, int cnt)
 	 * This also frees memory malloc'ed by dfu_get_buf(), so no explicit
 	 * need fo call dfu_free_buf() is needed.
 	 */
-	ret = dfu_write(dfu_get_entity(alt_setting_num),
-			transfer_buffer, 0, cnt);
+	ret = dfu_write(dfu_entity, transfer_buffer, 0, cnt);
 	if (ret)
 		error("DFU write failed [%d] cnt: %d", ret, cnt);
 
+exit:
 	return ret;
 }
 
Signature · 1 line
1.9.1
#11 lore raw

PATCH v4 1/3 usb:gadget:f_thor: code cleanup in function download_tail()

Hello Heiko,

Quoted 15 lines · Przemyslaw Marczak

In thor's download_tail() function, dfu_get_entity() is called before each dfu_write() call and the returned entity pointers are the same. So dfu_get_entity() can be called just once and this patch changes this.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

---
Changes v2:
- separate fix and cleanup into two commits

Quoted 6 lines

Changes v3:
- download_tail(): add exit label

Changes v4:
- none
---

Could you look at those changes, please?

Thank you

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#12 lore raw

PATCH v4 1/3 usb:gadget:f_thor: code cleanup in function download_tail()

In reply to Przemyslaw Marczak

Hello Marek,

Quoted 15 lines · Przemyslaw Marczak

In thor's download_tail() function, dfu_get_entity() is called before each dfu_write() call and the returned entity pointers are the same. So dfu_get_entity() can be called just once and this patch changes this.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

---
Changes v2:
- separate fix and cleanup into two commits

Quoted 5 lines

Changes v3:
- download_tail(): add exit label

Changes v4:
- none

I've checked the u-boot-usb/master tree and I found that one commit of this patch set is missed, because it is v3 (there was only two commits). Could you please apply the patch set version 4?

Thank you,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#13 lore raw

PATCH v4 1/3 usb:gadget:f_thor: code cleanup in function download_tail()

Hi Przemyslaw, Marek,

Quoted 21 lines

Hello Marek,

Quoted 18 lines · Przemyslaw Marczak

In thor's download_tail() function, dfu_get_entity() is called before each dfu_write() call and the returned entity pointers are the same. So dfu_get_entity() can be called just once and this patch changes this.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

---
Changes v2:
- separate fix and cleanup into two commits

Changes v3:
- download_tail(): add exit label

Quoted 6 lines
Quoted 2 lines

Changes v4:
- none

I've checked the u-boot-usb/master tree and I found that one commit of this patch set is missed, because it is v3 (there was only two commits). Could you please apply the patch set version 4?

I've discussed this issue with Przemek, and we agreed that Przemek will prepare diff patch between version 3, which is already in mainline and version 4.

Then, after ML review, I will pull them to u-boot-dfu branch.

Marek, does it work for you?

Quoted 2 lines

Thank you,

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#14 lore raw

PATCH v4 1/3 usb:gadget:f_thor: code cleanup in function download_tail()

Quoted 30 lines · Lukasz Majewski

Hi Przemyslaw, Marek,

Quoted 21 lines

Hello Marek,

Quoted 18 lines · Przemyslaw Marczak

In thor's download_tail() function, dfu_get_entity() is called before each dfu_write() call and the returned entity pointers are the same. So dfu_get_entity() can be called just once and this patch changes this.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

---
Changes v2:
- separate fix and cleanup into two commits

Changes v3:
- download_tail(): add exit label

Quoted 6 lines
Quoted 2 lines

Changes v4:
- none

I've checked the u-boot-usb/master tree and I found that one commit of this patch set is missed, because it is v3 (there was only two commits). Could you please apply the patch set version 4?

Quoted 7 lines

I've discussed this issue with Przemek, and we agreed that Przemek will prepare diff patch between version 3, which is already in mainline and version 4.

Then, after ML review, I will pull them to u-boot-dfu branch.

Marek, does it work for you?

Yes, thanks.

Best regards,
Marek Vasut

#15 lore raw

PATCH v4 2/3 usb:gadget:f_thor: fix write to filesystem by add dfu_flush()

In reply to Przemyslaw Marczak

Since dfu read/write operations needs to be flushed manually, writing to filesystem on MMC by thor was broken. MMC raw write actually is working fine because current dfu_flush() function writes filesystem only. This commit adds dfu_flush() to f_thor and now filesystem write is working.

This change was tested on Trats2 board.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Tom Rini <[email protected]>

---
Changes v2:
- separate fix and cleanup into two commits

Changes v3:
- none

Changes v4:
- download_tail(): remove dfu_write with 0 size

---
 drivers/usb/gadget/f_thor.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/gadget/f_thor.c +4 -4
index 1190c74..a3ab6b9 100644
@@ -219,15 +219,15 @@ static int download_tail(long long int left, int cnt)
 	}
 
 	/*
-	 * To store last "packet" DFU storage backend requires dfu_write with
-	 * size parameter equal to 0
+	 * To store last "packet" or write file from buffer to filesystem
+	 * DFU storage backend requires dfu_flush
 	 *
 	 * This also frees memory malloc'ed by dfu_get_buf(), so no explicit
 	 * need fo call dfu_free_buf() is needed.
 	 */
-	ret = dfu_write(dfu_entity, transfer_buffer, 0, cnt);
+	ret = dfu_flush(dfu_entity, transfer_buffer, 0, cnt);
 	if (ret)
-		error("DFU write failed [%d] cnt: %d", ret, cnt);
+		error("DFU flush failed!");
 
 exit:
 	return ret;
Signature · 1 line
1.9.1
#16 lore raw

PATCH v4 3/3 drivers:dfu: dfu_flush(): add raw data flush to complete

In reply to Przemyslaw Marczak

Before dfu write and flush operations separation, dfu write data was flushed by host download request with len of zero size.

Since above change manually calling dfu write with zero size has non sense (e.g. in THOR). This should be done by flush operation.
So now dfu_write_buffer_drain() is called in dfu_flush(). If there is any raw data to flush (like it can be in thor) then it will be physically written to medium.

---
Changes v4:
- new commit

---
 drivers/dfu/dfu.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/dfu/dfu.c +4 -0
index 8a09aaf..94e9116 100644
@@ -131,6 +131,10 @@ int dfu_flush(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
 {
 	int ret = 0;
 
+	ret = dfu_write_buffer_drain(dfu);
+	if (ret)
+		return ret;
+
 	if (dfu->flush_medium)
 		ret = dfu->flush_medium(dfu);
 
Signature · 1 line
1.9.1