[RFC PATCH 13/20] boot: bootmeth: add OpenWrt boot method skeleton

Daniel Golle daniel at makrotopia.org
Mon Feb 16 22:23:17 CET 2026


Add the initial bootmeth_openwrt driver with:

- UCLASS_BOOTMETH driver, compatible "u-boot,openwrt"
- check(): accept block devices via bootflow_iter_check_blk()
- bind(): set BOOTMETHF_ANY_PART so bootstd iterates all partitions
  without requiring a filesystem
- read_bootflow(): stub returning -ENOENT
- boot(): stub returning -ENOSYS
- Kconfig: CONFIG_BOOTMETH_OPENWRT depending on FIT, BOOTSTD,
  BOOTM_STORAGE

This is the foundation for booting OpenWrt-style uImage.FIT firmware
images stored directly on raw storage partitions. The bootmeth will
delegate actual image loading to the existing bootm storage path via
image_loader.

Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 boot/Kconfig            | 13 +++++++++
 boot/Makefile           |  1 +
 boot/bootmeth_openwrt.c | 65 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+)
 create mode 100644 boot/bootmeth_openwrt.c

diff --git a/boot/Kconfig b/boot/Kconfig
index efc06f3cd1a..d8c7b8360ac 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -585,6 +585,19 @@ config BOOTMETH_CROS
 
 	  Note that only x86 devices are supported at present.
 
+config BOOTMETH_OPENWRT
+	bool "Bootdev support for OpenWrt"
+	depends on FIT
+	depends on BOOTSTD
+	depends on BOOTM_STORAGE
+	help
+	  Enables support for booting OpenWrt-style uImage.FIT firmware
+	  images stored directly on raw storage (block device partitions,
+	  MTD partitions, or UBI volumes). The boot method loads the FIT
+	  metadata, selectively reads only the kernel and FDT sub-images
+	  from storage, and skips filesystem sub-images that Linux maps
+	  directly from flash.
+
 config BOOTMETH_EXTLINUX
 	bool "Bootdev support for extlinux boot"
 	select PXE_UTILS
diff --git a/boot/Makefile b/boot/Makefile
index 7d1d4a28106..7b42358eb0c 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -72,6 +72,7 @@ obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_SIMPLE_FW) += vbe_simple_fw.o
 obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_SIMPLE_OS) += vbe_simple_os.o
 
 obj-$(CONFIG_$(PHASE_)BOOTMETH_ANDROID) += bootmeth_android.o
+obj-$(CONFIG_$(PHASE_)BOOTMETH_OPENWRT) += bootmeth_openwrt.o
 
 obj-$(CONFIG_IMAGE_LOADER) += image-loader.o
 obj-$(CONFIG_IMAGE_LOADER_BLK) += image-loader-blk.o
diff --git a/boot/bootmeth_openwrt.c b/boot/bootmeth_openwrt.c
new file mode 100644
index 00000000000..02bf543031b
--- /dev/null
+++ b/boot/bootmeth_openwrt.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootmethod for OpenWrt
+ *
+ * Copyright (C) 2026 Daniel Golle <daniel at makrotopia.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <blk.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootm.h>
+#include <bootmeth.h>
+#include <dm.h>
+#include <image-loader.h>
+#include <malloc.h>
+#include <mapmem.h>
+
+static int openwrt_check(struct udevice *dev, struct bootflow_iter *iter)
+{
+	if (bootflow_iter_check_blk(iter))
+		return log_msg_ret("blk", -EOPNOTSUPP);
+
+	return 0;
+}
+
+static int openwrt_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+{
+	return log_msg_ret("nyi", -ENOENT);
+}
+
+static int openwrt_boot(struct udevice *dev, struct bootflow *bflow)
+{
+	return log_msg_ret("nyi", -ENOSYS);
+}
+
+static int openwrt_bootmeth_bind(struct udevice *dev)
+{
+	struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
+
+	plat->desc = "OpenWrt";
+	plat->flags = BOOTMETHF_ANY_PART;
+
+	return 0;
+}
+
+static struct bootmeth_ops openwrt_bootmeth_ops = {
+	.check		= openwrt_check,
+	.read_bootflow	= openwrt_read_bootflow,
+	.boot		= openwrt_boot,
+};
+
+static const struct udevice_id openwrt_bootmeth_ids[] = {
+	{ .compatible = "u-boot,openwrt" },
+	{ }
+};
+
+U_BOOT_DRIVER(bootmeth_openwrt) = {
+	.name		= "bootmeth_openwrt",
+	.id		= UCLASS_BOOTMETH,
+	.of_match	= openwrt_bootmeth_ids,
+	.ops		= &openwrt_bootmeth_ops,
+	.bind		= openwrt_bootmeth_bind,
+};
-- 
2.53.0


More information about the U-Boot mailing list