All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guennadi Liakhovetski <lg@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 0/6] Support NAND in fw_printenv/fw_setenv
Date: Tue, 2 Sep 2008 01:33:50 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0809020104080.8933@axis700.grange> (raw)
In-Reply-To: <20080901224153.96351242FF@gemini.denx.de>

On Tue, 2 Sep 2008, Wolfgang Denk wrote:

> In message <Pine.LNX.4.64.0809011028550.4686@axis700.grange> you wrote:
> > 
> > 1. do not use the union
> > 
> > well, I would still prefer to use it and I hope I will be allowed to do so 
> > in a separate NAND-tool. I agree, it would be better to use the definition 
> > from the environment.h directly. But:
> 
> There is no such thing as a separate NAND tool - this mkes zero sense.
> There shall be one tool that supports both NOR and NAND (and soon
> probably DataFlash and OneNAND and ... ).
> 
> > 2. do not use single.crc in redundant case
> > 
> > This is done only at two places, yes, I realise, this is not very clean, 
> 
> Indeed. But the problem goes away automatically whenyou get rid of the
> union.

I'll try to explain again _why_ i introduced the union and why I still 
don't see a good replacement for it.

As you know, in the tool we have to decide at run-time whether we are 
dealing  with a single environment copy or with current / redundant 
configuration. With NAND support when _writing_ environment to NAND you 
have to write page at a time, which means, at this point we _must_ have 
the image in a contiguous buffer in RAM. And the image can have one of the 
two possible formats - with and without the "flags" byte. In principle I 
see only three possibilities to implement this:

(a) work with arbitrary non-contiguous data in RAM as before, and copy it 
into an additional buffer just before writing to NAND

advantage: can keep the current struct

disadvantage: extra malloc

(b) use a plain data buffer, and, if needed, use the first byte in it for 
flags

advantage: no extra malloc, no (explicit) union

disadvantage: confusing, have to work with byte-offsets instead of struct 
/ union members, and, in fact, this is the same as using a union, just 
implicit, calculating byte-offsets manually, instead of letting the 
compiler do it

(c) use a union

advantage: clean access to all environment fields without the use of 
byte-offsets

disadvantage: slightly more complex code

Please, just tell me which of these three you would prefer, or maybe there 
is a fourth possibility I am still overseeing.

You also asked about the extra "char *data" pointer in the struct 
environment, whether there is no danger that a different compiler version 
will break it. This pointer uses no magic - it is just a plain simple 
pointer, I use it to point to data inside the union to avoid having to 
check every time whether we have the redundant environment or not. So, I 
check it only once at initialisation time, set this pointer, and then just 
use it to access the data buffer inside the image (union). No magic here.

> > 4. fix MTD_OLD
> > 
> > Would we still need this with NAND-only tool?
> 
> Yes of course we need it. I will not accept such thing as a NAND-only tool.

Ok. But NAND-support is not needed with MTD_OLD? So, if it cannot be 
compiled with older kernels, we may just disable it per ifdef?

> > 5. clarify back-up mode
> > 
> > This is actually a comment improvement, can do.
> 
> Actually the whole implementation needs to be explained.

Ok.

> > Shall I keep support for NOR in the separate NAND version or completely 
> > remove it? The "type == MTD_NORFLASH" code is quite small, so, removing it 
> 
> I don't understand why you come up with such an idea. There shall  be
> just  the  one  tool we have now, just with extended functionality. I
> just wanted to get rid of the futile attempts to make  the  one  huge
> change looking like a series af several big but incremental changes.

How would you like to make such a replacement then? If I produce a patch 
just from the current state to the final state, I think, it will look 
worse than the broken-down patch-series. Otherwise we could remove the 
current file and add a new one in two patches? This wouldn't be very good 
either - you'd have to change Makefiles etc. to keep the tree compilable.

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

  reply	other threads:[~2008-09-01 23:33 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-27 15:52 [U-Boot] [PATCH 0/6] Support NAND in fw_printenv/fw_setenv Guennadi Liakhovetski
2008-08-27 15:52 ` [U-Boot] [PATCH 1/6] Convert fw_env.c to use a single environment image union Guennadi Liakhovetski
2008-08-31 14:36   ` Wolfgang Denk
2008-08-31 15:57     ` Guennadi Liakhovetski
2008-08-31 18:57       ` Wolfgang Denk
2008-08-27 15:52 ` [U-Boot] [PATCH 2/6] Separate flash read and write operations Guennadi Liakhovetski
2008-08-31 14:58   ` Wolfgang Denk
2008-08-31 16:04     ` Guennadi Liakhovetski
2008-08-31 18:57       ` Wolfgang Denk
2008-08-31 19:45         ` Guennadi Liakhovetski
2008-08-31 19:56           ` Wolfgang Denk
2008-08-27 15:52 ` [U-Boot] [PATCH 3/6] "return" is not a function Guennadi Liakhovetski
2008-08-31 14:59   ` Wolfgang Denk
2008-08-31 16:10     ` Guennadi Liakhovetski
2008-08-31 18:57       ` Wolfgang Denk
2008-08-31 19:17         ` Guennadi Liakhovetski
2008-08-27 15:52 ` [U-Boot] [PATCH 4/6] Unify active vs. redundant environment variable naming Guennadi Liakhovetski
2008-08-31 15:04   ` Wolfgang Denk
2008-08-31 16:18     ` Guennadi Liakhovetski
2008-08-31 18:57       ` Wolfgang Denk
2008-08-31 19:27         ` Guennadi Liakhovetski
2008-08-31 19:44           ` Wolfgang Denk
2008-08-27 15:52 ` [U-Boot] [PATCH 5/6] Support environment anywhere within erase area Guennadi Liakhovetski
2008-08-31 18:57   ` Wolfgang Denk
2008-08-31 19:39     ` Guennadi Liakhovetski
2008-08-31 19:53       ` Wolfgang Denk
2008-08-27 15:52 ` [U-Boot] [PATCH 6/6] Support environment in NAND Guennadi Liakhovetski
2008-08-29  9:29   ` [U-Boot] [PATCH 6/6 v2] " Guennadi Liakhovetski
2008-08-31 18:57   ` [U-Boot] [PATCH 6/6] " Wolfgang Denk
2008-08-31 21:53     ` Guennadi Liakhovetski
2008-08-31 20:21 ` [U-Boot] [PATCH 0/6] Support NAND in fw_printenv/fw_setenv Wolfgang Denk
2008-08-31 20:37   ` Guennadi Liakhovetski
2008-08-31 20:55     ` Wolfgang Denk
2008-09-01  9:08       ` Guennadi Liakhovetski
2008-09-01  9:31         ` Guennadi Liakhovetski
2008-09-01 22:42           ` Wolfgang Denk
2008-09-01 22:41         ` Wolfgang Denk
2008-09-01 23:33           ` Guennadi Liakhovetski [this message]
2008-09-02  0:13             ` Wolfgang Denk
2008-09-02 16:00   ` Guennadi Liakhovetski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0809020104080.8933@axis700.grange \
    --to=lg@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.