[PATCH v2 3/4] bootflow: bootmeth_efi: Handle fdt not available.

Simon Glass sjg at chromium.org
Sat Nov 18 18:10:08 CET 2023


Hi Shantur,

On Fri, 17 Nov 2023 at 14:22, Shantur Rathore <i at shantur.com> wrote:
>
> While booting with efi, if fdt isn't available externally,
> just use the built-in one.
>
> Signed-off-by: Shantur Rathore <i at shantur.com>
> ---
>  boot/bootmeth_efi.c | 10 +++++++++-
>  include/bootflow.h  |  1 +
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
> index 5917458dc5..5e67afed88 100644
> --- a/boot/bootmeth_efi.c
> +++ b/boot/bootmeth_efi.c
> @@ -313,6 +313,7 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,
>                  */
>         } else {
>                 log_debug("No device tree available\n");
> +               bflow->flags |= BOOTFLOWF_USE_BUILTIN_FDT;
>         }
>
>         return 0;
> @@ -382,6 +383,7 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow)
>                 bflow->fdt_addr = fdt_addr;
>         } else {
>                 log_debug("No device tree available\n");
> +               bflow->flags |= BOOTFLOWF_USE_BUILTIN_FDT;
>         }
>
>         bflow->state = BOOTFLOWST_READY;
> @@ -443,7 +445,13 @@ static int distro_efi_boot(struct udevice *dev, struct bootflow *bflow)
>          * At some point we can add a real interface to bootefi so we can call
>          * this directly. For now, go through the CLI, like distro boot.
>          */
> -       snprintf(cmd, sizeof(cmd), "bootefi %lx %lx", kernel, fdt);
> +       if (bflow->flags & BOOTFLOWF_USE_BUILTIN_FDT) {
> +               log_debug("Booting with built-in fdt\n");
> +               snprintf(cmd, sizeof(cmd), "bootefi %lx", kernel);
> +       } else {
> +               snprintf(cmd, sizeof(cmd), "bootefi %lx %lx", kernel, fdt);
> +       }
> +

There is some code (not shown) in this function:

   /*
    * use the provided device tree if available, else fall back to
    * the control FDT
    */
   if (bflow->fdt_fname)

I believe that should use your flag as well. So instead of using
fdt_fname to indicate whether there is an fdt, we should use your new
flag.

>         if (run_command(cmd, 0))
>                 return log_msg_ret("run", -EINVAL);
>
> diff --git a/include/bootflow.h b/include/bootflow.h
> index fede8f22a2..3890cd4bc2 100644
> --- a/include/bootflow.h
> +++ b/include/bootflow.h
> @@ -49,6 +49,7 @@ enum bootflow_state_t {
>  enum bootflow_flags_t {
>         BOOTFLOWF_USE_PRIOR_FDT = 1 << 0,
>         BOOTFLOWF_STATIC_BUF    = 1 << 1,
> +       BOOTFLOWF_USE_BUILTIN_FDT       = 1 << 2,

Please update the comment for the enum to fully explain what it does

>  };
>
>  /**
> --
> 2.40.1
>

Regards,
Simon


More information about the U-Boot mailing list