mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* fitimage: Allow match against config node name
@ 2022-09-16 14:36 Hans Christian Lønstad
  2022-09-16 17:26 ` Ahmad Fatoum
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Christian Lønstad @ 2022-09-16 14:36 UTC (permalink / raw)
  To: barebox

Support fitimage configuration nodes without populated compatible fields

Yocto fit image recipe does not populate the compatible field
in the generated ITS file configuration nodes.
Barebox is thus only able to load the default configuration
preventing the use of variant based bootloader update bundles.

If the compatible match fails, fall through using a global
variable boot.fitnode allowing a match against the configuration
node name.

This allows variant boards to pick the correct configuration.

---
common/image-fit.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/common/image-fit.c b/common/image-fit.c
index a410632d70..f92e813a8b 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -7,6 +7,7 @@

#define pr_fmt(fmt) "FIT: " fmt
#include <common.h>
+#include <environment.h>
#include <init.h>
#include <bootm.h>
#include <libfile.h>
@@ -663,6 +664,7 @@ static int fit_find_compatible_unit(struct device_node *conf_node,
struct device_node *barebox_root;
const char *machine;
int ret;
+ const char *config_node;

barebox_root = of_get_root_node();
if (!barebox_root)
@@ -680,6 +682,22 @@ static int fit_find_compatible_unit(struct device_node *conf_node,
}
}

+ /*
+ * If the match against compatible in config node does not match
+ * (or is missing as in Yocto fitimage recipe)
+ * check for matching node name using global.boot.fitnode
+ */
+ config_node = getenv("global.boot.fitnode");
+ if (config_node) {
+ for_each_child_of_node (conf_node, child) {
+ if (strcmp(child->name, config_node) == 0) {
+ *unit = child->name;
+ pr_info("matching node name unit '%s' found\n", *unit);
+ return 0;
+ }
+ }
+ }
+
default_unit:
pr_info("No match found. Trying default.\n");
if (of_property_read_string(conf_node, "default", unit) == 0)
-- 
2.34.1


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

end of thread, other threads:[~2022-09-17 11:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 14:36 fitimage: Allow match against config node name Hans Christian Lønstad
2022-09-16 17:26 ` Ahmad Fatoum
2022-09-17  6:51   ` Hans Christian Lønstad
2022-09-17 10:13     ` Ahmad Fatoum
2022-09-17 10:59       ` Hans Christian Lønstad

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