Patchwork [U-Boot,1/2] cmd_sf: let "sf update" erase last sector as a whole

login
register
mail settings
Submitter Gerlando Falauto
Date April 3, 2012, 3:14 p.m.
Message ID <1333466098-31783-2-git-send-email-gerlando.falauto@keymile.com>
Download mbox | patch
Permalink /patch/150467/
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Comments

Gerlando Falauto - April 3, 2012, 3:14 p.m.
make "sf update" work with unaligned `len' parameter, by deleting the
whole last sector before writing, so to allow for:

 sf update ${load_addr_r} 0 ${filesize}

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Cc: Valentin Longchamp <valentin.longchamp@keymile.com>
Cc: Holger Brunck <holger.brunck@keymile.com>
---
 common/cmd_sf.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Simon Glass - April 4, 2012, 12:28 a.m.
On Tue, Apr 3, 2012 at 8:14 AM, Gerlando Falauto
<gerlando.falauto@keymile.com> wrote:
> make "sf update" work with unaligned `len' parameter, by deleting the
> whole last sector before writing, so to allow for:
>
>  sf update ${load_addr_r} 0 ${filesize}
>
> Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
> Cc: Valentin Longchamp <valentin.longchamp@keymile.com>
> Cc: Holger Brunck <holger.brunck@keymile.com>

Acked-by: Simon Glass <sjg@chromium.org>

> ---
>  common/cmd_sf.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/common/cmd_sf.c b/common/cmd_sf.c
> index 3cfedde..d97d4a5 100644
> --- a/common/cmd_sf.c
> +++ b/common/cmd_sf.c
> @@ -142,7 +142,8 @@ static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
>                *skipped += len;
>                return NULL;
>        }
> -       if (spi_flash_erase(flash, offset, len))
> +       /* Erase the entire sector */
> +       if (spi_flash_erase(flash, offset, flash->sector_size))
>                return "erase";
>        if (spi_flash_write(flash, offset, len, buf))
>                return "write";
> --
> 1.7.1
>

Patch

diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index 3cfedde..d97d4a5 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -142,7 +142,8 @@  static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
 		*skipped += len;
 		return NULL;
 	}
-	if (spi_flash_erase(flash, offset, len))
+	/* Erase the entire sector */
+	if (spi_flash_erase(flash, offset, flash->sector_size))
 		return "erase";
 	if (spi_flash_write(flash, offset, len, buf))
 		return "write";