Skip to contentSkip to conversation

arm: stm32mp: stm32prog: always flush DFU on start command for uart

PATCH New Patrick Delaunay 3 participants 4 messages Dec 11, 2020 – Jan 13, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: stm32mp: stm32prog: always flush DFU on start command for uart

From: Patrick Delaunay <[email protected]>

Remove the test on data->dfu_seq, because dfu_seq=0 not only when the DFU is not started (mask with 0xffff). This flush is mandatory as the final treatment, common with USB, is done in DFU callback.

This patch avoids issue if the received length is a multiple of the DFU packet.

For example if size of bootfs partition is egual to 0x4000000, data->dfu_seq=0 at the end of the partition, the flush it not requested and the phase is not increased in the callback. U-Boot continue to request the bootfs in the next GetPhase command.

Fixes 468f0508b58b ("stm32mp: stm32prog: add serial link support")

---

 .../mach-stm32mp/cmd_stm32prog/stm32prog_serial.c   | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c +6 -7
index 8aad4be467..8fba92b2b5 100644
@@ -397,14 +397,13 @@ static u8 stm32prog_start(struct stm32prog_data *data, u32 address)
 		if (!dfu_entity)
 			return -ENODEV;
 
-		if (data->dfu_seq) {
-			ret = dfu_flush(dfu_entity, NULL, 0, data->dfu_seq);
-			data->dfu_seq = 0;
-			if (ret) {
-				stm32prog_err("DFU flush failed [%d]", ret);
-				return ret;
-			}
+		ret = dfu_flush(dfu_entity, NULL, 0, data->dfu_seq);
+		if (ret) {
+			stm32prog_err("DFU flush failed [%d]", ret);
+			return ret;
 		}
+		data->dfu_seq = 0;
+
 		printf("\n  received length = 0x%x\n", data->cursor);
 		if (data->header.present) {
 			if (data->cursor !=
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 arm: stm32mp: stm32prog: always flush DFU on start command for uart

Hi Patrick??

Quoted 37 lines · Patrick Delaunay

From: Patrick Delaunay <[email protected]>

Remove the test on data->dfu_seq, because dfu_seq=0 not only when the DFU is not started (mask with 0xffff). This flush is mandatory as the final treatment, common with USB, is done in DFU callback.

This patch avoids issue if the received length is a multiple of the DFU packet.

For example if size of bootfs partition is egual to 0x4000000, data->dfu_seq=0 at the end of the partition, the flush it not requested and the phase is not increased in the callback. U-Boot continue to request the bootfs in the next GetPhase command.

Fixes 468f0508b58b ("stm32mp: stm32prog: add serial link support")

---

 .../mach-stm32mp/cmd_stm32prog/stm32prog_serial.c   | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c +0 -7
index 8aad4be467..8fba92b2b5 100644
@@ -397,14 +397,13 @@ static u8 stm32prog_start(struct stm32prog_data *data, u32 address)
 		if (!dfu_entity)
 			return -ENODEV;
 
-		if (data->dfu_seq) {
-			ret = dfu_flush(dfu_entity, NULL, 0, data->dfu_seq);
-			data->dfu_seq = 0;
-			if (ret) {
-				stm32prog_err("DFU flush failed [%d]", ret);
-				return ret;
-			}

arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c static u8 stm32prog_start(struct stm32prog_data *data, u32 address) · line 409

Quoted 10 lines
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c +6 -0
+		ret = dfu_flush(dfu_entity, NULL, 0, data->dfu_seq);
+		if (ret) {
+			stm32prog_err("DFU flush failed [%d]", ret);
+			return ret;
 		}
+		data->dfu_seq = 0;
+
 		printf("\n  received length = 0x%x\n", data->cursor);
 		if (data->header.present) {
 			if (data->cursor !=

Thanks

Patrice

#2 lore raw

PATCH 1/1 arm: stm32mp: stm32prog: always flush DFU on start command for uart

In reply to Patrick Delaunay

Hi Patrick

Quoted 37 lines · Patrick Delaunay

From: Patrick Delaunay <[email protected]>

Remove the test on data->dfu_seq, because dfu_seq=0 not only when the DFU is not started (mask with 0xffff). This flush is mandatory as the final treatment, common with USB, is done in DFU callback.

This patch avoids issue if the received length is a multiple of the DFU packet.

For example if size of bootfs partition is egual to 0x4000000, data->dfu_seq=0 at the end of the partition, the flush it not requested and the phase is not increased in the callback. U-Boot continue to request the bootfs in the next GetPhase command.

Fixes 468f0508b58b ("stm32mp: stm32prog: add serial link support")

---

 .../mach-stm32mp/cmd_stm32prog/stm32prog_serial.c   | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c +0 -7
index 8aad4be467..8fba92b2b5 100644
@@ -397,14 +397,13 @@ static u8 stm32prog_start(struct stm32prog_data *data, u32 address)
 		if (!dfu_entity)
 			return -ENODEV;
 
-		if (data->dfu_seq) {
-			ret = dfu_flush(dfu_entity, NULL, 0, data->dfu_seq);
-			data->dfu_seq = 0;
-			if (ret) {
-				stm32prog_err("DFU flush failed [%d]", ret);
-				return ret;
-			}

arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c static u8 stm32prog_start(struct stm32prog_data *data, u32 address) · line 409

Quoted 10 lines
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_serial.c +6 -0
+		ret = dfu_flush(dfu_entity, NULL, 0, data->dfu_seq);
+		if (ret) {
+			stm32prog_err("DFU flush failed [%d]", ret);
+			return ret;
 		}
+		data->dfu_seq = 0;
+
 		printf("\n  received length = 0x%x\n", data->cursor);
 		if (data->header.present) {
 			if (data->cursor !=

Thanks

Patrice

#3 lore raw

PATCH 1/1 arm: stm32mp: stm32prog: always flush DFU on start command for uart

In reply to Patrick Delaunay

Hi,

Quoted 14 lines · Patrick Delaunay

From: Patrick Delaunay <[email protected]>

Remove the test on data->dfu_seq, because dfu_seq=0 not only when the DFU is not started (mask with 0xffff). This flush is mandatory as the final treatment, common with USB, is done in DFU callback.

This patch avoids issue if the received length is a multiple of the DFU packet.

For example if size of bootfs partition is egual to 0x4000000, data->dfu_seq=0 at the end of the partition, the flush it not requested and the phase is not increased in the callback. U-Boot continue to request the bootfs in the next GetPhase command.

Quoted 8 lines
Fixes 468f0508b58b ("stm32mp: stm32prog: add serial link support")

---

  .../mach-stm32mp/cmd_stm32prog/stm32prog_serial.c   | 13 ++++++-------
  1 file changed, 6 insertions(+), 7 deletions(-)

Applied to u-boot-stm/master, thanks!

Regards

Patrick