env: Add the ability to merge the saved env with the default.
PATCH 1/1 env: Add the ability to merge the saved env with the default.
This is a useful mechanism any time you have a way to update the saved environment outside of u-boot. This can be a tool like fw_setenv or could be a tool like we use in Chrome OS that modifies the variables in a binary image before flashing (see factory_setup/update_firmware_vars.py in
http://git.chromium.org/git/chromiumos/platform/factory-utils).
--- common/env_common.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-)
common/env_common.c +24 -0
@@ -34,6 +34,19 @@DECLARE_GLOBAL_DATA_PTR ; +/* +* Create a saved enviroment with this env variable set to "1" to merge the +* saved environment on top of the default environment. The idea is that your +* saved environment would just contain variables that you'd like to override +* from the default so that as you update u-boot (w/ potential changes to the +* default) you get all the updates. +* +* This is really most useful when you have a tool like fw_setenv to manage +* your saved environment. Using 'saveenv' to save your environment will saved +* the _merged_ environment (AKA it won't unmerge things). +*/ +#define MERGE_WITH_DEFAULT "merge_with_default" +/************************************************************************ * Default settings to be used when no valid environment is found */
@@ -208,7 +221,18 @@ int env_import(const char *buf, int check) }if (himport_r (&env_htab, (char *)ep->data,ENV_SIZE ,'\0' ,0 )) { +char *merge_val; + gd->flags |=GD_FLG_ENV_READY ; + merge_val =getenv (MERGE_WITH_DEFAULT ); + +if (merge_val !=NULL && merge_val[0 ] !='0' ) { +set_default_env ("" ); +himport_r (&env_htab, (char *)ep->data,ENV_SIZE ,'\0' , +H_NOCLEAR ); +hdelete_r (MERGE_WITH_DEFAULT , &env_htab); +puts ("Merged saved with default environment\n\n" ); + }return 1 ; }
Signature · 1 line
1.7.7.3
PATCH 1/1 env: Add the ability to merge the saved env with the default.
Quoted 9 lines · On Tuesday 14 February 2012 18:30:55 Doug Anderson wrote:
Create a saved enviroment with this env variable set to "1" to merge the saved environment on top of the default environment. The idea is that your saved environment would just contain variables that you'd like to override from the default so that as you update u-boot (w/potential changes to the default) you get all the updates.
This is really most useful when you have a tool like
fw_setenvto manage your saved environment. Using 'saveenv' to save your environment will saved the _merged_ environment (AKA it won't unmerge things).
this is kind of a crappy interface. also, doesn't the existing env import do this ?
* env import [-d] [-t | -b | -c] addr [size]
* -d: delete existing environment before importing;
* otherwise overwrite / append to existion definitions
so if we "imported" the default, we'd get this ?
i think someone recently was doing work on default env handling. but wasn't following it too closely.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120305/645b28a7/attachment.pgp>
PATCH 1/1 env: Add the ability to merge the saved env with the default.
Mike,
Quoted 2 lines · Mike Frysinger
this is kind of a crappy interface.
Agreed.
Quoted 8 lines
also, doesn't the existing
env import
do this ?
* env import [-d] [-t | -b | -c] addr [size]
* -d: delete existing environment before importing;
* otherwise overwrite / append to existion definitionsso if we "imported" the default, we'd get this ?
It's not quite possible to just import the default from the saved for two reasons:
1. I don't know of any way to import the default. It's not stored at any well-known address or with any well-known size.
2. The order of precedence would be a little different (default would override saved).
...but I think you're right that using "env import" is the better way to go. I can always have the default boot command load the "overrides" into memory and the import them. That works just fine for us.
Thank you for your review and suggestion!
Please consider this patch abandoned.
-Doug
PATCH 1/1 env: Add the ability to merge the saved env with the default.
Dear Doug Anderson,
Quoted 5 lines · In message <CAD=FV=Ws+FuCqUXRd3-PJS-2y5PTspgegMftvTOQqhK=96y9MQ@mail.gmail.com>…
It's not quite possible to just import the default from the saved for two reasons:
1. I don't know of any way to import the default. It's not stored at any well-known address or with any well-known size.
Then save it to a well-known address. env reset followed by env export should be a reasonably straughtforward way to get there.
Quoted 2 lines
2. The order of precedence would be a little different (default would override saved).
I'm not sure I understand what you mean. You can chose if you import the saved defaults before or after your private settings.
Quoted 7 lines
...but I think you're right that using "env import" is the better way to go. I can always have the default boot command load the "overrides" into memory and the import them. That works just fine for us.
Thank you for your review and suggestion!
Please consider this patch abandoned.
Done. Thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel 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 Es sind ?berhaupt nur die Dummk?pfe, die sich den Befehlen der M?ch- tigen widersetzen. Um sie zu ruinieren ist es genug, ihre Befehle treu zu erf?llen. - Peter Hacks: "Die sch?ne Helena"
PATCH 1/1 env: Add the ability to merge the saved env with the default.
In reply to Doug AndersonQuoted 17 lines · On Tuesday 06 March 2012 12:07:10 you wrote:
Quoted 8 lines · Mike Frysinger
also, doesn't the existing
env import
do this ?* env import [-d] [-t | -b | -c] addr [size]
* -d: delete existing environment before importing;
* otherwise overwrite / append to existion definitionsso if we "imported" the default, we'd get this ?
It's not quite possible to just import the default from the saved for two reasons:
1. I don't know of any way to import the default. It's not stored at any well-known address or with any well-known size.
2. The order of precedence would be a little different (default would override saved).
Quoted 3 lines
...but I think you're right that using "env import" is the better way to go. I can always have the default boot command load the "overrides" into memory and the import them. That works just fine for us.
i think this thread is what i was remembering:
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/109115
with that in place, it should be easy to implement the functionality you desire on top of that right ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120306/c77f18d0/attachment.pgp>