@@ -34,6 +34,7 @@
DECLARE_GLOBAL_DATA_PTR;
#endif /* !USE_HOSTCC*/
+#include <env.h>
#include <bootm.h>
#include <image.h>
#include <bootstage.h>
@@ -2128,6 +2129,9 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
puts("OK\n");
}
+#if !defined(USE_HOSTCC)
+ env_import_fit_conf(fit, cfg_noffset);
+#endif
bootstage_mark(BOOTSTAGE_ID_FIT_CONFIG);
noffset = fit_conf_get_prop_node(fit, cfg_noffset, prop_name,
@@ -748,6 +748,16 @@ config ENV_FDT_PATH
help
The initial value of the env_fdt_path variable.
+config ENV_IMPORT_FIT_CONF
+ bool "Amend environment by FIT configuration node properties"
+ depends on OF_CONTROL
+ help
+ If selected, after the environment has been loaded from its
+ persistent location, the "env,*" properties in the conf-node
+ of FIT image are used to update the run-time environment. This
+ can be useful in order to transport signed environment variables
+ to the kernel cmdline.
+
config ENV_APPEND
bool "Always append the environment with new data"
help
@@ -24,6 +24,7 @@
#include <dm/ofnode.h>
#include <net.h>
#include <watchdog.h>
+#include <fdt_support.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -661,3 +662,30 @@ void env_import_fdt(void)
}
}
#endif
+
+#define FIT_CONF_ENV_PROPERTY_PREFIX "env,"
+void env_import_fit_conf(const void *fdt, int conf_node)
+{
+ int offset, len;
+ const char *name;
+ const void *value;
+ const struct fdt_property *property;
+
+ if (!CONFIG_IS_ENABLED(ENV_IMPORT_FIT_CONF))
+ return;
+
+ fdt_for_each_property_offset(offset, fdt, conf_node) {
+ property = fdt_get_property_by_offset(fdt, offset, NULL);
+
+ name = fdt_get_string(fdt, fdt32_to_cpu(property->nameoff), NULL);
+ if (strncmp(name, FIT_CONF_ENV_PROPERTY_PREFIX,
+ sizeof(FIT_CONF_ENV_PROPERTY_PREFIX) - 1))
+ continue;
+
+ value = fdt_getprop(fdt, conf_node, name, &len);
+ /* Get the actual variable name "env,somename" -> "somename" */
+ name += sizeof(FIT_CONF_ENV_PROPERTY_PREFIX) - 1;
+
+ env_set(name, value);
+ }
+}
@@ -382,4 +382,15 @@ void env_import_fdt(void);
static inline void env_import_fdt(void) {}
#endif
+/**
+ * env_import_fit_conf() - Import environment values from FIT configuration node
+ *
+ * This imports environment variables from FIT configuration node. Each
+ * property name starting with an "env,"-prefix is imported as variable where
+ * the variable name is the suffix of the property name.
+ *
+ * Example: env,somevalue = "foobar" --> somevalue=foobar
+ */
+void env_import_fit_conf(const void *fdt, int conf_node);
+
#endif