[U-Boot] [swupdate] Re: SWUpdate - U-Boot environment library dependency

Wolfgang Denk wd at denx.de
Wed Nov 21 11:38:14 UTC 2018


Dear Stefano,

In message <6b07725e-51ba-7309-1506-e7211487b947 at denx.de> you wrote:
>
> > One possible way to fix this is not to use a compiled in default
> > environment for the fw_env tools (or only use this as a very last
> > resort), but instead provide a configuration option to read the
> > default settings from a file.  In this case the user could provide
> > his own, board specific default environment.
>
> I tried this, but it is very difficult to maintain this in sync,
> specially in projects where the number of developers is > 1 (all
> projects). If the file does not correspond to the linked environment,
> strange behaviors are expected.
>
> Much better will be if u-boot generates in its build process this file.
> It becomes just another artifact like SPL or u-boot.img and we are sure
> that it is in sync.

I tend to disagree.  As mentioned, the original intent of the
default environment was only (!) to make sure that a working
baudrate setting for the console is available on boards where the
environment has never been initialized yet (fresh our of
production) or, but only as additional benefit, that have lost their
environment somehow.

Usually it is not good for any practical purposes - it is missing
any board specific settings like MAC adress, IP addresses, serial
numbers etc.

This was when booting from parallel NOR.

The whole paradigm was dropped when first implementations of SPL
became necessary to boot from NAND - they all had harcoded baud
rates, as they could not access the environment (often due to size
limitations).

My question is:  why do we need the default environment today?

It just consumes a couple of kB size, and does not bring any
measurable benefits.

> > - Why does building the U-Boot package not also create these
> >   libraries, either directly or as a separate package?
>
> Issue is that there is not a u-boot-dev package

Then why not create one?

> > - What prevents the creation of such a dev package that only builds
> >   the needed lib?
>
> I think Simon wants to prevent to rebuild u-boot.

You don't have to rebuild U-Boot - building the lib should be
sufficient.

> To be clear: the issue just raises if a board runs with default
> environment. User Space cannot know this environment because it is
> linked in the bootloader - the current way is to link the same
> environment in tools/env (that means, u-boot-fw-tools in OE).

And I ask again: what exactly would we lose if we drop the whole
default environment?  I mean, what would we lose that we have not
already given up elsewhere with nobody ever complaining about?

> There is no issue at all for boards that are not using default
> environment at all, that means they rely to have always a valid
> environment in flash.

I would be seriously surprised if a single board in real  life uses
the default environment, and only that, for normale operation.

> > Did anybody ever ask who actually _needs_ this compiled in default
> > environment? 
>
> Rather, quite all boards....see CONFIG_EXTRA_ENV in include/configs/*
> and the number of patches sent just to fix something in it.

You misunderstand.  This was not primarily intended for the
_default_ environment, but to _initialize_ the real environment.
In these olden days this would usually be placed insome smaller
sectors of the parallel NOR flash, and special (hand-tuned) linker
scripts would make sure that the respective data would be properly
placed in the U-Boot image.

At these times, a U-Boot image would usually contaim 3 copies of the
same data: two redundant copies of the normal, persistent
environment, embedded somehwere at "magic offsets" in the image,
plus the default environment (somehwere in the [read-only] data
segment, basically at an unknown address).

There would be a few boards that did not use embedded environments,
so other ways wewre selected to initialize it.

But the default environment was never ever intended to be used for
this purpose.

> UMHO the default environment should be like an extra image in u-boot,
> like an header added by mkimage, because there is no changes in code and
> behavior. Not to mention that CONFIG_EXTRA_ENV is really error prone
> with the requirement to put each line as a C string with trailing "\0".

It was 1:1 coding at the time, done by a handful of experts, when
the number of contributors was still single-digit.

I fully afree that it would be much nicer if we could just place it
as plain text (ideally even commented!) on some other file.

But then: there is no technical reason not to implement this.
Volunteers welcome!

> All recent boards, specially the one that switched to distro_, use the
> default environment. Thing is that there is no need to add an extra
> environment and the board can boot without any intervention by operator
> (or by factory) simply after flashing the bootloader.

This is a broken design, and should be fixed.  We don't need three
copies of the environment.  We should get rid of the "default"
environment and replace it with a better way to initialize the real
environment.

And yes, I really hate all these distro settings, because they are
inelegant and unflexible and the slightest change requires to rebuild
and reinstall the whole U-Boot image, when all you want to change is
just a variable setting.  This is CRAP!


IIUC, it should for example be possible to perform the initialization
of the normale environment by running the equivalent of "env import"
from some image (uImage or FIT image or even a plain text file
[though I'd not recommend the latter as it includes zero consistency
checking].


I mean: instead of complaining about the limitations of an
antediluvian construct and investing precious energy in creating
more and more ugly workarounds, we should think about ways to
replace this with a more flexible and more powerful method.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I think trash is the most important manifestation of culture we have
in my lifetime."                                      - Johnny Legend


More information about the U-Boot mailing list