[U-Boot] [PATCH 2/2] cmd_sf: Add handler for +len arg for erase command.

Scott Wood scottwood at freescale.com
Wed Feb 16 22:47:17 CET 2011


On Wed, 16 Feb 2011 15:27:54 -0500
Richard Retanubun <RichardRetanubun at ruggedcom.com> wrote:

> This patch adds [+]len handler for the erase command that will
> automatically round up the requested erase length to the flash's
> sector_size.
> ---
>  common/cmd_sf.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 files changed, 49 insertions(+), 4 deletions(-)
> 
> diff --git a/common/cmd_sf.c b/common/cmd_sf.c
> index 6e7be81..bbd4842 100644
> --- a/common/cmd_sf.c
> +++ b/common/cmd_sf.c
> @@ -19,6 +19,48 @@
>  
>  static struct spi_flash *flash;
>  
> +
> +/*
> + * This function computes the length argument for the erase command.
> + * The length on which the command is to operate can be given in two forms:
> + * 1. <cmd> offset len  - operate on <'offset',  'len')
> + * 2. <cmd> offset +len - operate on <'offset',  'round_up(len)')
> + * If the second form is used and the length doesn't fall on the
> + * sector boundary, than it will be adjusted to the next sector boundary.
> + * If it isn't in the flash, the function will fail (return -1).

On NOR, + is used to indicate that the second argument is a length,
as opposed to an ending address.  Rounding seems like a side effect of
length mode.

On NAND we unconditionally round up erase lengths, as we don't support
ending-address mode (looks like SPI doesn't either).

-Scott



More information about the U-Boot mailing list