[U-Boot] [PATCH] fw_env: add NAND support
Guennadi Liakhovetski
lg at denx.de
Tue Sep 2 23:18:22 CEST 2008
On Tue, 2 Sep 2008, Wolfgang Denk wrote:
> > + /* Offset inside a block */
> > + block_seek = offset - blockstart;
> ...
> > + /* Limit to one block for the first read */
>
> Why?
Because this is on NAND, there we have to perform all IO block at a time.
> > +
> > + /*
> > + * If a block is bad, we retry in the next block at the same
> > + * offset - see common/env_nand.c::writeenv()
> > + */
> > + lseek (fd, blockstart + block_seek, SEEK_SET);
>
> Hm... there was a "continue" for the badblock case just above, so do
> we really try the _next_ block here?
I meant, if the first block with non-zero offset (block_seek) was bad,
then in the _next_ after it block we try at the same offset.
> > + /*
> > + * Data size we actually have to write: from the start of the block
> > + * to the start of the data, then count bytes ob data, and to the
> -------------------------------------------------------^ f
> > + * end of the block
> > + */
>
> Hm... sounds as if this was always exactly one full block, then?
or two, or three...
> > + write_total = (block_seek + count + blocklen - 1) & ~(blocklen - 1);
> > +
> > + /*
> > + * Support data anywhere within erase sectors: read out the complete
> > + * area to be erased, replace the environment image, write the whole
> > + * block back again.
> > + */
> > + if (write_total > count) {
> > + data = malloc (erase_len);
>
> My understanding is, that erase_len can be > block size. Is this
> correct?
Yes.
> I don't see where the actual size of the environment data is taken
> into considration?
in the "count" function parameter, which is then used to calculate
write_total.
> > + } else {
> > + /* Offset is block-aligned by construction here */
>
> What does "block-aligned by construction" mean?
It means, by the way I constructed (calculated) lengths above this place,
we land here only if offset is block-aligned.
> > + erase.length = erasesize;
> > +
> > + /* This only runs once on NOR flash */
>
> How comes that?
Because on NOR I set "erasesize" to the total length of the data plus
alignment.
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
More information about the U-Boot
mailing list