[U-Boot] [PATCH] Pad data length for nand write

Scott Wood scottwood at freescale.com
Tue Feb 17 22:16:57 CET 2009


Derek Ou wrote:
> This routine is copied from nand_write_opts() at nand_util.c of v1.3.4.  

v1.3.4 had its own buffer; it did not use the caller's.

> It maybe better
> to pad data length and data buffer in do_nand() at cmd_nand.c.

Or pass a flag to nand_write_skip_bad().

   But I
> don't see real
> difference.  I didn't allocate a new buffer since the data length is 
> defined in the command
> arguments and I have no knowledge of a safe location and large enough 
> memory space
> to store data.

You can define a static array for holding one page, as v1.3.4 did.  The 
space after the caller's buffer is *not* a safe location.

> Maybe we should implement, like Wolfgang said, a "+length" syntax in the 
> "nand write"
> command to indicates "round up to the next page boundary". 

Sounds good.  If we do that, we should do similarly with "nand erase". 
It currently (sometimes) warns and rounds up if you give it a 
non-block-aligned size.

> In this 
> case, do_nand()
> can assume that it's safe to write pass memory address (add + length) 
> and Flash offset
> (off + length).

No, it will *not* assume that it's safe to write to any memory of the 
caller's.  It will allocate its own buffer.

-Scott


More information about the U-Boot mailing list