[RFC PATCH 14/20] boot: bootmeth: openwrt: implement read_bootflow for block devices
Simon Glass
sjg at chromium.org
Thu Feb 19 14:09:29 CET 2026
Hi Daniel,
On Mon, 16 Feb 2026 at 14:23, Daniel Golle <daniel at makrotopia.org> wrote:
>
> Implement openwrt_read_bootflow() to discover OpenWrt FIT images on
> raw block device partitions.
>
> For each partition bootstd offers, read the first block and check for
> a valid FDT header via fdt_check_header(). If the header is valid the
> partition likely contains a FIT image and the bootflow is marked
> BOOTFLOWST_READY.
>
> Full FIT validation, configuration resolution, and sub-image loading
> are all deferred to boot() which uses image_loader — keeping the scan
> path fast and avoiding large reads for embedded-data FIT images that
> can be many megabytes.
>
> Signed-off-by: Daniel Golle <daniel at makrotopia.org>
> ---
> boot/bootmeth_openwrt.c | 43 ++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 42 insertions(+), 1 deletion(-)
>
Reviewed-by: Simon Glass <simon.glass at canonical.com>
See below
> diff --git a/boot/bootmeth_openwrt.c b/boot/bootmeth_openwrt.c
> index 02bf543031b..08c3f98957a 100644
> --- a/boot/bootmeth_openwrt.c
> +++ b/boot/bootmeth_openwrt.c
> @@ -16,6 +16,10 @@
> #include <image-loader.h>
> #include <malloc.h>
> #include <mapmem.h>
> +#include <memalign.h>
> +#include <part.h>
> +#include <linux/libfdt.h>
> +#include <linux/sizes.h>
>
> static int openwrt_check(struct udevice *dev, struct bootflow_iter *iter)
> {
> @@ -27,7 +31,44 @@ static int openwrt_check(struct udevice *dev, struct bootflow_iter *iter)
>
> static int openwrt_read_bootflow(struct udevice *dev, struct bootflow *bflow)
> {
> - return log_msg_ret("nyi", -ENOENT);
> + struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
> + const char *part_name = NULL;
> + struct disk_partition info;
> + void *buf;
> + int ret;
> +
> + /* Get partition geometry */
> + ret = part_get_info(desc, bflow->part, &info);
> + if (ret)
> + return log_msg_ret("part", ret);
> +
> + part_name = (const char *)info.name;
> +
> + /* Read first block to probe for an FDT/FIT header */
> + buf = memalign(SZ_1K, desc->blksz);
Could you use ALLOC_CACHE_ALIGN_BUFFER() ?
> + if (!buf)
> + return log_msg_ret("mem", -ENOMEM);
> +
> + ret = blk_read(bflow->blk, info.start, 1, buf);
> + if (ret != 1) {
> + free(buf);
> + return log_msg_ret("rd", -EIO);
> + }
> +
> + /* Must start with a valid FDT header */
> + if (fdt_check_header(buf)) {
> + free(buf);
> + return -ENOENT;
> + }
> +
> + free(buf);
> +
> + /* Show the GPT partition label as Filename */
> + bflow->fname = strdup(part_name);
> +
> + bflow->state = BOOTFLOWST_READY;
At this point there is no indication that we actually have anything,
so I think this should move to a later patch.
> +
> + return 0;
> }
>
> static int openwrt_boot(struct udevice *dev, struct bootflow *bflow)
> --
> 2.53.0
Regards,
Simon
More information about the U-Boot
mailing list