mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] blspec: allow board files to overwrite config file settings
@ 2021-01-18 20:48 Marco Felsch
  2021-01-18 20:48 ` [PATCH 2/2] Documentation: blspec: Add blspec fixup documentation Marco Felsch
  2021-01-19 11:01 ` [PATCH 1/2] blspec: allow board files to overwrite config file settings Sascha Hauer
  0 siblings, 2 replies; 8+ messages in thread
From: Marco Felsch @ 2021-01-18 20:48 UTC (permalink / raw)
  To: barebox

This commit adds the support to overwrite and/or adapt blspec config
files by the following global variables:
  - global.blspec.fixup.devicetree
  - global.blspec.fixup.initrd
  - global.blspec.fixup.options
  - global.blspec.fixup.linux
  - global.blspec.fixup.devicetree-overlay.

Overwriting blspec-config's shouldn't be the normal case but there are
cases where this support is needed. One use-case can be a special
handling during update. E.g. the normal boot-flow don't need the initrd
but the update-flow uses it because the update system is on the initrd.
Another use-case could be a dynamic devicetree-overlay handling. E.g.
the board code dynamically checks which periphery boards are connected
and adds the required overlays dynamically.

A warning is printed if a already set option is overwritten to identify
unintended wrong boot behaviour early.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 common/blspec.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/common/blspec.c b/common/blspec.c
index a07343f427..b527731a27 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -210,12 +210,21 @@ err_out:
  */
 const char *blspec_entry_var_get(struct blspec_entry *entry, const char *name)
 {
+	const char *match, *fixup;
 	const char *str;
 	int ret;
 
 	ret = of_property_read_string(entry->node, name, &str);
 
-	return ret ? NULL : str;
+	/* Check user specific overrides */
+	match = basprintf("global.blspec.fixup.%s", name);
+	fixup = getenv_nonempty(match);
+	free((void *)match);
+
+	if (!ret && fixup)
+		pr_warn("Overwrite %s blspec entry by fixup\n", name);
+
+	return fixup ? fixup : (ret ? NULL : str);
 }
 
 static void blspec_entry_free(struct bootentry *be)
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-01-20 13:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 20:48 [PATCH 1/2] blspec: allow board files to overwrite config file settings Marco Felsch
2021-01-18 20:48 ` [PATCH 2/2] Documentation: blspec: Add blspec fixup documentation Marco Felsch
2021-01-19 11:01 ` [PATCH 1/2] blspec: allow board files to overwrite config file settings Sascha Hauer
2021-01-19 11:42   ` Marco Felsch
2021-01-20  9:03     ` Sascha Hauer
2021-01-20 10:54       ` Marco Felsch
2021-01-20 12:31         ` Michael Olbrich
2021-01-20 13:26           ` Marco Felsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox