Skip to contentSkip to conversation

bootstd: Replicate the dtb-filename quirks of distroboot

PATCH In review Simon Glass 2 participants 4 messages Feb 5, 2023 – Feb 22, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 bootstd: Replicate the dtb-filename quirks of distroboot

For EFI, the distro boot scripts search in three different directories for the .dtb file. The SOC-based filename fallback is supported only for 32-bit ARM.

Adjust the code to mirror this behaviour.

Also some boards can use a prior-stage FDT if one is not found in the normal way. Support this and show a warning in that case.

---

Changes in v3:
- Change the message from a warning to a statement

Changes in v2:
- Allow use of the prior-stage FDT if nothing else is found
- Warn about using a prior-stage FDT

 boot/bootflow.c     |  3 ++
 boot/bootmeth_efi.c | 70 +++++++++++++++++++++++++++++++++++++++------
 include/bootflow.h  | 14 +++++++++
 3 files changed, 78 insertions(+), 9 deletions(-)
boot/bootflow.c +3 -0
index 4999018e36e..0d809728716 100644
@@ -463,6 +463,9 @@ int bootflow_run_boot(struct bootflow_iter *iter, struct bootflow *bflow)
 
 	printf("** Booting bootflow '%s' with %s\n", bflow->name,
 	       bflow->method->name);
+	if (IS_ENABLED(CONFIG_OF_HAS_PRIOR_STAGE) &&
+	    (bflow->flags & BOOTFLOWF_USE_PRIOR_FDT))
+		printf("Using prior-stage device tree\n");
 	ret = bootflow_boot(bflow);
 	if (!IS_ENABLED(CONFIG_BOOTSTD_FULL)) {
 		printf("Boot failed (err=%d)\n", ret);
boot/bootmeth_efi.c +61 -9

113 lines not on this page · raw message

include/bootflow.h +14 -0
index e5fdf5f29d1..f20f575030f 100644
@@ -36,6 +36,18 @@ enum bootflow_state_t {
 	BOOTFLOWST_COUNT
 };
 
+/**
+ * enum bootflow_flags_t - flags for bootflows
+ *
+ * @BOOTFLOWF_USE_PRIOR_FDT: Indicates that an FDT was not found by the bootmeth
+ *	and it is using the prior-stage FDT, which is the U-Boot control FDT.
+ *	This is only possible with the EFI bootmeth (distro-efi) and only when
+ *	CONFIG_OF_HAS_PRIOR_STAGE is enabled
+ */
+enum bootflow_flags_t {
+	BOOTFLOWF_USE_PRIOR_FDT	= 1 << 0,
+};
+
 /**
  * struct bootflow - information about a bootflow
  *
@@ -68,6 +80,7 @@ enum bootflow_state_t {
  * @fdt_fname: Filename of FDT file
  * @fdt_size: Size of FDT file
  * @fdt_addr: Address of loaded fdt
+ * @flags: Flags for the bootflow (see enum bootflow_flags_t)
  */
 struct bootflow {
 	struct list_head bm_node;
@@ -90,6 +103,7 @@ struct bootflow {
 	char *fdt_fname;
 	int fdt_size;
 	ulong fdt_addr;
+	int flags;
 };
 
 /**
Signature · 1 line
2.39.1.519.gcb327c4b5f-goog
#1 lore raw
Quoted 8 lines · Simon Glass

For EFI, the distro boot scripts search in three different directories for the .dtb file. The SOC-based filename fallback is supported only for 32-bit ARM.

Adjust the code to mirror this behaviour.

Also some boards can use a prior-stage FDT if one is not found in the normal way. Support this and show a warning in that case.

The code now does _not_ warn, thanks, but the commit message is wrong. Will fixup when applying if there's no further feedback.

Signature · 1 line
Tom
#2 lore raw
In reply to Simon Glass
Quoted 11 lines · Simon Glass

For EFI, the distro boot scripts search in three different directories for the .dtb file. The SOC-based filename fallback is supported only for 32-bit ARM.

Adjust the code to mirror this behaviour.

Also some boards can use a prior-stage FDT if one is not found in the normal way. Support this and show a warning in that case.

As-is, sandbox fails to build with this, on master.

Signature · 1 line
Tom
#3 lore raw

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass

For EFI, the distro boot scripts search in three different directories for the .dtb file. The SOC-based filename fallback is supported only for 32-bit ARM.

Adjust the code to mirror this behaviour.

Quoted 7 lines
Quoted 5 lines

Also some boards can use a prior-stage FDT if one is not found in the normal way. Support this and show a warning in that case.

As-is, sandbox fails to build with this, on master.

I can't repeat this, but I updated the series with the commit-message change and will resend. The CI result is here:

https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/15309

Regards,
Simon

Quoted 3 lines

--
Tom