Skip to contentSkip to conversation

dfu: dfu_sf: Use the erase sector size for erase operations

PATCH In review Fabio Estevam 4 participants 8 messages Sep 22, 2015 – Oct 20, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dfu: dfu_sf: Use the erase sector size for erase operations

From: Fabio Estevam <[email protected]>

SPI NOR flashes need to erase the entire sector size and we cannot pass any arbitrary length for the erase operation.

To illustrate the problem:

Copying data from PC to DFU device
Download [=========================] 100% 478208 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was
Done!

In this case, the binary has 478208 bytes and the M25P32 SPI NOR has an erase sector of 64kB.

478208 = 7 entire sectors of 64kiB + 19456 bytes.

Erasing the first seven 64 kB sectors works fine, but when trying to erase the remainding 19456 causes problem and the board hangs.

Fix the issue by always erasing with the erase sector size.

---
 drivers/dfu/dfu_sf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dfu/dfu_sf.c +2 -1
index c3d3c3b..448d95d 100644
@@ -28,7 +28,8 @@ static int dfu_write_medium_sf(struct dfu_entity *dfu,
 {
 	int ret;
 
-	ret = spi_flash_erase(dfu->data.sf.dev, offset, *len);
+	ret = spi_flash_erase(dfu->data.sf.dev, offset,
+			      dfu->data.sf.dev->sector_size);
 	if (ret)
 		return ret;
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 dfu: dfu_sf: Use the erase sector size for erase operations

Hi Fabio,

Quoted 35 lines

From: Fabio Estevam <[email protected]>

SPI NOR flashes need to erase the entire sector size and we cannot pass any arbitrary length for the erase operation.

To illustrate the problem:

Copying data from PC to DFU device
Download [=========================] 100% 478208 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was
Done!

In this case, the binary has 478208 bytes and the M25P32 SPI NOR has an erase sector of 64kB.

478208 = 7 entire sectors of 64kiB + 19456 bytes.

Erasing the first seven 64 kB sectors works fine, but when trying to erase the remainding 19456 causes problem and the board hangs.

Fix the issue by always erasing with the erase sector size.

---
 drivers/dfu/dfu_sf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dfu/dfu_sf.c +0 -0
index c3d3c3b..448d95d 100644

drivers/dfu/dfu_sf.c static int dfu_write_medium_sf(struct dfu_entity · line 35

Quoted 9 lines
drivers/dfu/dfu_sf.c +2 -1
@@ -28,7 +28,8 @@ static int dfu_write_medium_sf(struct dfu_entity
 *dfu, {
 	int ret;
 
-	ret = spi_flash_erase(dfu->data.sf.dev, offset, *len);
+	ret = spi_flash_erase(dfu->data.sf.dev, offset,
+			      dfu->data.sf.dev->sector_size);
 	if (ret)
 		return ret;
 

Applied to u-boot-dfu tree.

Thanks for your work.

I'm looking forward for more patches :-)

Signature · 5 lines
Best regards,

Lukasz Majewski

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

PATCH 1/1 dfu: dfu_sf: Use the erase sector size for erase operations

Hi Lukasz,

Quoted 29 lines · Lukasz Majewski

Hi Fabio,

Quoted 18 lines

From: Fabio Estevam <[email protected]>

SPI NOR flashes need to erase the entire sector size and we cannot pass any arbitrary length for the erase operation.

To illustrate the problem:

Copying data from PC to DFU device
Download [=========================] 100% 478208 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was
Done!

In this case, the binary has 478208 bytes and the M25P32 SPI NOR has an erase sector of 64kB.

Quoted 8 lines

478208 = 7 entire sectors of 64kiB + 19456 bytes.

Erasing the first seven 64 kB sectors works fine, but when trying to erase the remainding 19456 causes problem and the board hangs.

Fix the issue by always erasing with the erase sector size.

Quoted 7 lines

Applied to u-boot-dfu tree.

Thanks for your work.

I'm looking forward for more patches :-)

Any chance of getting this one applied for 2015.10?

#3 lore raw

PATCH 1/1 dfu: dfu_sf: Use the erase sector size for erase operations

Hi Fabio,

Quoted 35 lines

Hi Lukasz,

Quoted 31 lines · Lukasz Majewski

Hi Fabio,

Quoted 18 lines

From: Fabio Estevam <[email protected]>

SPI NOR flashes need to erase the entire sector size and we cannot pass any arbitrary length for the erase operation.

To illustrate the problem:

Copying data from PC to DFU device
Download [=========================] 100% 478208 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was
Done!

In this case, the binary has 478208 bytes and the M25P32 SPI NOR has an erase sector of 64kB.

Quoted 8 lines

478208 = 7 entire sectors of 64kiB + 19456 bytes.

Erasing the first seven 64 kB sectors works fine, but when trying to erase the remainding 19456 causes problem and the board hangs.

Fix the issue by always erasing with the erase sector size.

Quoted 7 lines
Quoted 5 lines

Applied to u-boot-dfu tree.

Thanks for your work.

I'm looking forward for more patches :-)

Any chance of getting this one applied for 2015.10?

Probably not :-( since we have now -rc5.

I plan to send pull request in the next merge window.

My apologies, since I was busy with ELCE2015 preparation, so I've forgotten to send early PR to Marek.

Signature · 5 lines
Best regards,

Lukasz Majewski

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

PATCH 1/1 dfu: dfu_sf: Use the erase sector size for erase operations

Quoted 37 lines · Lukasz Majewski
Quoted 37 lines
Quoted 34 lines · Lukasz Majewski
Quoted 18 lines

From: Fabio Estevam <[email protected]>

SPI NOR flashes need to erase the entire sector size and we cannot pass any arbitrary length for the erase operation.

To illustrate the problem:

Copying data from PC to DFU device
Download [=========================] 100% 478208 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was
Done!

In this case, the binary has 478208 bytes and the M25P32 SPI NOR has an erase sector of 64kB.

Quoted 8 lines

478208 = 7 entire sectors of 64kiB + 19456 bytes.

Erasing the first seven 64 kB sectors works fine, but when trying to erase the remainding 19456 causes problem and the board hangs.

Fix the issue by always erasing with the erase sector size.

Applied to u-boot-dfu tree.

Thanks for your work.

I'm looking forward for more patches :-)

Quoted 8 lines
Quoted 1 line

Any chance of getting this one applied for 2015.10?

Probably not :-( since we have now -rc5.

I plan to send pull request in the next merge window.

My apologies, since I was busy with ELCE2015 preparation, so I've forgotten to send early PR to Marek.

This has been acked in September and it is a very trivial change, why not include it?

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#5 lore raw

PATCH 1/1 dfu: dfu_sf: Use the erase sector size for erase operations

Hi Otavio,

Quoted 44 lines
Quoted 42 lines · Lukasz Majewski
Quoted 32 lines
Quoted 30 lines · Lukasz Majewski
Quoted 20 lines

From: Fabio Estevam <[email protected]>

SPI NOR flashes need to erase the entire sector size and we cannot pass any arbitrary length for the erase operation.

To illustrate the problem:

Copying data from PC to DFU device
Download [=========================] 100% 478208 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was Done!

In this case, the binary has 478208 bytes and the M25P32 SPI NOR has an erase sector of 64kB.

478208 = 7 entire sectors of 64kiB + 19456 bytes.

Quoted 7 lines

Erasing the first seven 64 kB sectors works fine, but when trying to erase the remainding 19456 causes problem and the board hangs.

Fix the issue by always erasing with the erase sector size.

Quoted 7 lines
Quoted 5 lines

Applied to u-boot-dfu tree.

Thanks for your work.

I'm looking forward for more patches :-)

Any chance of getting this one applied for 2015.10?

Probably not :-( since we have now -rc5.

Quoted 8 lines
Quoted 4 lines

I plan to send pull request in the next merge window.

My apologies, since I was busy with ELCE2015 preparation, so I've forgotten to send early PR to Marek.

This has been acked in September and it is a very trivial change, why not include it?

I'm discussing it now with Tom. I hope that he would take those two patches.

Signature · 5 lines
Best regards,

Lukasz Majewski

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

PATCH 1/1 dfu: dfu_sf: Use the erase sector size for erase operations

In reply to Otavio Salvador

Hi Tom,

Quoted 44 lines
Quoted 42 lines · Lukasz Majewski
Quoted 32 lines
Quoted 30 lines · Lukasz Majewski
Quoted 20 lines

From: Fabio Estevam <[email protected]>

SPI NOR flashes need to erase the entire sector size and we cannot pass any arbitrary length for the erase operation.

To illustrate the problem:

Copying data from PC to DFU device
Download [=========================] 100% 478208 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was Done!

In this case, the binary has 478208 bytes and the M25P32 SPI NOR has an erase sector of 64kB.

478208 = 7 entire sectors of 64kiB + 19456 bytes.

Quoted 7 lines

Erasing the first seven 64 kB sectors works fine, but when trying to erase the remainding 19456 causes problem and the board hangs.

Fix the issue by always erasing with the erase sector size.

Quoted 7 lines
Quoted 5 lines

Applied to u-boot-dfu tree.

Thanks for your work.

I'm looking forward for more patches :-)

Any chance of getting this one applied for 2015.10?

Probably not :-( since we have now -rc5.

Quoted 8 lines
Quoted 4 lines

I plan to send pull request in the next merge window.

My apologies, since I was busy with ELCE2015 preparation, so I've forgotten to send early PR to Marek.

This has been acked in September and it is a very trivial change, why not include it?

Two patches to be applied as fixes for dfu subsystem.

https://patchwork.ozlabs.org/patch/520827/
https://patchwork.ozlabs.org/patch/521575/

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
#7 lore raw
In reply to Fabio Estevam
Quoted 20 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

SPI NOR flashes need to erase the entire sector size and we cannot pass any arbitrary length for the erase operation.

To illustrate the problem:

Copying data from PC to DFU device
Download [=========================] 100% 478208 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was
Done!

In this case, the binary has 478208 bytes and the M25P32 SPI NOR has an erase sector of 64kB.

478208 = 7 entire sectors of 64kiB + 19456 bytes.

Quoted 7 lines

Erasing the first seven 64 kB sectors works fine, but when trying to erase the remainding 19456 causes problem and the board hangs.

Fix the issue by always erasing with the erase sector size.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151019/e547c5e3/attachment.sig>