Hi Daniel,

On Mon, 16 Feb 2026 at 14:23, Daniel Golle <[email protected]> wrote:
>
> Implement openwrt_boot() to boot a discovered OpenWrt FIT image:
>
> 1. Get the block interface name via blk_get_devtype() and construct
>    the dev_part_str (e.g. "0:3") from the block descriptor and
>    bootflow partition number
> 2. Initialise an image_loader for block devices via
>    image_loader_init_blk(), with alloc_ptr set to image_load_addr
> 3. Optionally read the 'bootconf' env variable and pass it as
>    '#config' in bmi.addr_img for FIT configuration selection
> 4. Call bootm_run() which runs the full bootm state machine:
>    START -> FINDOS -> FINDOTHER -> LOADOS -> OS_PREP -> OS_GO
>
> The image_loader handles on-demand reading of the FIT metadata and
> sub-images (kernel, FDT) directly from the raw partition. The
> existing cleanup call in bootm_run_states() releases the loader just
> before OS_GO. If bootm_run() returns (boot failure), cleanup is
> called explicitly.
>
> This completes the core block-device boot path for bootmeth_openwrt.
>
> Signed-off-by: Daniel Golle <[email protected]>
> ---
>  boot/bootmeth_openwrt.c | 37 ++++++++++++++++++++++++++++++++++++-
>  1 file changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/boot/bootmeth_openwrt.c b/boot/bootmeth_openwrt.c
> index 08c3f98957a..82f39c17d7f 100644
> --- a/boot/bootmeth_openwrt.c
> +++ b/boot/bootmeth_openwrt.c
> @@ -13,6 +13,8 @@
>  #include <bootm.h>
>  #include <bootmeth.h>
>  #include <dm.h>
> +#include <env.h>
> +#include <image.h>
>  #include <image-loader.h>
>  #include <malloc.h>
>  #include <mapmem.h>
> @@ -73,7 +75,40 @@ static int openwrt_read_bootflow(struct udevice *dev, 
> struct bootflow *bflow)
>
>  static int openwrt_boot(struct udevice *dev, struct bootflow *bflow)
>  {
> -       return log_msg_ret("nyi", -ENOSYS);
> +       struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
> +       const char *ifname = blk_get_devtype(bflow->blk);
> +       struct image_loader ldr = {};
> +       struct bootm_info bmi;
> +       char dev_part_str[32];
> +       char addr_img[64];
> +       const char *conf;
> +       int ret;
> +
> +       snprintf(dev_part_str, sizeof(dev_part_str), "%d:%d",
> +                desc->devnum, bflow->part);
> +
> +       ret = image_loader_init_blk(&ldr, ifname, dev_part_str);
> +       if (ret)
> +               return log_msg_ret("ldr", ret);
> +
> +       ldr.alloc_ptr = image_load_addr;
> +
> +       bootm_init(&bmi);
> +       bmi.loader = &ldr;
> +
> +       /* FIT config selection via #conf suffix */
> +       conf = env_get("bootconf");
> +       if (conf) {
> +               snprintf(addr_img, sizeof(addr_img), "#%s", conf);
> +               bmi.addr_img = addr_img;
> +       }
> +
> +       ret = bootm_run(&bmi);
> +
> +       /* Clean up if bootm_run() returned (i.e. boot failed) */
> +       image_loader_cleanup(&ldr);
> +
> +       return log_msg_ret("run", ret);
>  }
>
>  static int openwrt_bootmeth_bind(struct udevice *dev)
> --
> 2.53.0

This looks OK so far as it goes, but will need rework for the driver change.

Regards,
Simon

Reply via email to