@@ -829,6 +829,42 @@ is called twice.
}
+Bootloader handler
+------------------
+
+The bootloader handler allows to set bootloader's environment with a file. The file shold have the format:
+
+::
+
+ # Comments are allowed using the hash char
+
+ varname=value
+
+Empty lines are skipped. This simplifies the update of the whole environment instead of setting each variable inside the
+"bootenv" section in sw-description. The property *nooverride* allows to skip variables that are already set in sw-description. If
+not set, variables set in bootenv are overwritten.
+
+
+::
+
+ images: (
+ {
+ filename = "uEnv.txt";
+ type = "bootloader";
+ properties: {
+ nooverride = "true";
+ }
+ }
+ );
+
+ bootenv: (
+ {
+ name = "bootenv01key";
+ value = "SOME VALUE";
+ });
+
+In the example above, bootenv01key is not overwritten by a value in uEnv.txt because the flag "nooverride" is set.
+
Archive handler
---------------
@@ -33,6 +33,7 @@ static int install_boot_environment(struct img_type *img,
char *buf;
char filename[MAX_IMAGE_FNAME];
struct stat statbuf;
+ bool no_override = false; /* do not override variables in bootenv */
if (snprintf(filename, sizeof(filename), "%s%s", get_tmpdirscripts(),
img->fname) >= (int)sizeof(filename)) {
@@ -75,6 +76,7 @@ static int install_boot_environment(struct img_type *img,
return -ENOMEM;
}
+ no_override = strtobool(dict_get_value(&img->properties, "nooverride"));
while (fgets(buf, MAX_BOOT_SCRIPT_LINE_LENGTH, fp)) {
char **pair = NULL;
unsigned int cnt;
@@ -90,6 +92,17 @@ static int install_boot_environment(struct img_type *img,
pair = string_split(buf, '=');
cnt = count_string_array((const char **)pair);
+ /*
+ * Skip if a variable was already parsed in the bootenv
+ * section, in that case it is already present in the dictionary.
+ * This avoid to override with the value in file
+ */
+ if (cnt && no_override && dict_get_value(img->bootloader, pair[0])) {
+ TRACE("Variable %s already set, skipping..", pair[0]);
+ free_string_array(pair);
+ continue;
+ }
+
switch (cnt) {
case 2:
TRACE("name = %s value = %s", pair[0], pair[1]);
The handler sets all variable found in the file, independently if they were also set in the bootenv section of sw-description. Add a "nooverride" flag to avoid that variables set in sw-description can be overwritten. Add documentation for the handler. Signed-off-by: Stefano Babic <sbabic@denx.de> Reported-by: Frieder Schrempf <fschrempf@gmail.com> --- Changes since V1: - make code readable (F. Schrempf) doc/source/handlers.rst | 36 ++++++++++++++++++++++++++++++++++++ handlers/boot_handler.c | 13 +++++++++++++ 2 files changed, 49 insertions(+)