public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] dfu: dfu_sf: Use the erase sector size for erase operations
@ 2015-09-22  3:55 Fabio Estevam
  2015-09-22  7:46 ` Lukasz Majewski
  2015-10-20  0:06 ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 8+ messages in thread
From: Fabio Estevam @ 2015-09-22  3:55 UTC (permalink / raw)
  To: u-boot

From: Fabio Estevam <fabio.estevam@freescale.com>

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.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/dfu/dfu_sf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index c3d3c3b..448d95d 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -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;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] dfu: dfu_sf: Use the erase sector size for erase operations
  2015-09-22  3:55 [U-Boot] [PATCH] dfu: dfu_sf: Use the erase sector size for erase operations Fabio Estevam
@ 2015-09-22  7:46 ` Lukasz Majewski
  2015-10-19  0:11   ` Fabio Estevam
  2015-10-20  0:06 ` [U-Boot] " Tom Rini
  1 sibling, 1 reply; 8+ messages in thread
From: Lukasz Majewski @ 2015-09-22  7:46 UTC (permalink / raw)
  To: u-boot

Hi Fabio,

> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> 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.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/dfu/dfu_sf.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
> index c3d3c3b..448d95d 100644
> --- a/drivers/dfu/dfu_sf.c
> +++ b/drivers/dfu/dfu_sf.c
> @@ -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;
>  

Acked-by: Lukasz Majewski <l.majewski@samsung.com>

Applied to u-boot-dfu tree.

Thanks for your work.

I'm looking forward for more patches :-)

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] dfu: dfu_sf: Use the erase sector size for erase operations
  2015-09-22  7:46 ` Lukasz Majewski
@ 2015-10-19  0:11   ` Fabio Estevam
  2015-10-19  8:07     ` Lukasz Majewski
  0 siblings, 1 reply; 8+ messages in thread
From: Fabio Estevam @ 2015-10-19  0:11 UTC (permalink / raw)
  To: u-boot

Hi Lukasz,

On Tue, Sep 22, 2015 at 4:46 AM, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Hi Fabio,
>
>> From: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> 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.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

> Acked-by: Lukasz Majewski <l.majewski@samsung.com>
>
> 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?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] dfu: dfu_sf: Use the erase sector size for erase operations
  2015-10-19  0:11   ` Fabio Estevam
@ 2015-10-19  8:07     ` Lukasz Majewski
  2015-10-19 10:56       ` Otavio Salvador
  0 siblings, 1 reply; 8+ messages in thread
From: Lukasz Majewski @ 2015-10-19  8:07 UTC (permalink / raw)
  To: u-boot

Hi Fabio,

> Hi Lukasz,
> 
> On Tue, Sep 22, 2015 at 4:46 AM, Lukasz Majewski
> <l.majewski@samsung.com> wrote:
> > Hi Fabio,
> >
> >> From: Fabio Estevam <fabio.estevam@freescale.com>
> >>
> >> 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.
> >>
> >> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> 
> > Acked-by: Lukasz Majewski <l.majewski@samsung.com>
> >
> > 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.


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] dfu: dfu_sf: Use the erase sector size for erase operations
  2015-10-19  8:07     ` Lukasz Majewski
@ 2015-10-19 10:56       ` Otavio Salvador
  2015-10-19 11:08         ` Lukasz Majewski
  2015-10-19 11:18         ` Lukasz Majewski
  0 siblings, 2 replies; 8+ messages in thread
From: Otavio Salvador @ 2015-10-19 10:56 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 19, 2015 at 6:07 AM, Lukasz Majewski <l.majewski@samsung.com> wrote:
>> On Tue, Sep 22, 2015 at 4:46 AM, Lukasz Majewski
>> <l.majewski@samsung.com> wrote:
>> >> From: Fabio Estevam <fabio.estevam@freescale.com>
>> >>
>> >> 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.
>> >>
>> >> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
>>
>> > Acked-by: Lukasz Majewski <l.majewski@samsung.com>
>> >
>> > 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.

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

-- 
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] dfu: dfu_sf: Use the erase sector size for erase operations
  2015-10-19 10:56       ` Otavio Salvador
@ 2015-10-19 11:08         ` Lukasz Majewski
  2015-10-19 11:18         ` Lukasz Majewski
  1 sibling, 0 replies; 8+ messages in thread
From: Lukasz Majewski @ 2015-10-19 11:08 UTC (permalink / raw)
  To: u-boot

Hi Otavio,

> On Mon, Oct 19, 2015 at 6:07 AM, Lukasz Majewski
> <l.majewski@samsung.com> wrote:
> >> On Tue, Sep 22, 2015 at 4:46 AM, Lukasz Majewski
> >> <l.majewski@samsung.com> wrote:
> >> >> From: Fabio Estevam <fabio.estevam@freescale.com>
> >> >>
> >> >> 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.
> >> >>
> >> >> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> >>
> >> > Acked-by: Lukasz Majewski <l.majewski@samsung.com>
> >> >
> >> > 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.
> 
> 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.


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH] dfu: dfu_sf: Use the erase sector size for erase operations
  2015-10-19 10:56       ` Otavio Salvador
  2015-10-19 11:08         ` Lukasz Majewski
@ 2015-10-19 11:18         ` Lukasz Majewski
  1 sibling, 0 replies; 8+ messages in thread
From: Lukasz Majewski @ 2015-10-19 11:18 UTC (permalink / raw)
  To: u-boot

Hi Tom,

> On Mon, Oct 19, 2015 at 6:07 AM, Lukasz Majewski
> <l.majewski@samsung.com> wrote:
> >> On Tue, Sep 22, 2015 at 4:46 AM, Lukasz Majewski
> >> <l.majewski@samsung.com> wrote:
> >> >> From: Fabio Estevam <fabio.estevam@freescale.com>
> >> >>
> >> >> 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.
> >> >>
> >> >> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> >>
> >> > Acked-by: Lukasz Majewski <l.majewski@samsung.com>
> >> >
> >> > 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.
> 
> 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/


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] dfu: dfu_sf: Use the erase sector size for erase operations
  2015-09-22  3:55 [U-Boot] [PATCH] dfu: dfu_sf: Use the erase sector size for erase operations Fabio Estevam
  2015-09-22  7:46 ` Lukasz Majewski
@ 2015-10-20  0:06 ` Tom Rini
  1 sibling, 0 replies; 8+ messages in thread
From: Tom Rini @ 2015-10-20  0:06 UTC (permalink / raw)
  To: u-boot

On Tue, Sep 22, 2015 at 12:55:00AM -0300, Fabio Estevam wrote:

> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> 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.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> Acked-by: Lukasz Majewski <l.majewski@samsung.com>

Applied to u-boot/master, thanks!

-- 
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>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-10-20  0:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-22  3:55 [U-Boot] [PATCH] dfu: dfu_sf: Use the erase sector size for erase operations Fabio Estevam
2015-09-22  7:46 ` Lukasz Majewski
2015-10-19  0:11   ` Fabio Estevam
2015-10-19  8:07     ` Lukasz Majewski
2015-10-19 10:56       ` Otavio Salvador
2015-10-19 11:08         ` Lukasz Majewski
2015-10-19 11:18         ` Lukasz Majewski
2015-10-20  0:06 ` [U-Boot] " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox