Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2197011/?format=api
{ "id": 2197011, "url": "http://patchwork.ozlabs.org/api/patches/2197011/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/bc1fb5747051cd6462bf3158250a04ea8e83b14e.1771275704.git.daniel@makrotopia.org/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<bc1fb5747051cd6462bf3158250a04ea8e83b14e.1771275704.git.daniel@makrotopia.org>", "list_archive_url": null, "date": "2026-02-16T21:24:00", "name": "[RFC,17/20] boot: bootdev: add UBI boot device", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "6d7921ba4524f53fedddc147e5c764a5800da366", "submitter": { "id": 64091, "url": "http://patchwork.ozlabs.org/api/people/64091/?format=api", "name": "Daniel Golle", "email": "daniel@makrotopia.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/bc1fb5747051cd6462bf3158250a04ea8e83b14e.1771275704.git.daniel@makrotopia.org/mbox/", "series": [ { "id": 492351, "url": "http://patchwork.ozlabs.org/api/series/492351/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=492351", "date": "2026-02-16T21:21:14", "name": "boot: add OpenWrt boot method and on-demand FIT loading", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/492351/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2197011/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2197011/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)", "phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=makrotopia.org", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de; dmarc=none (p=none dis=none)\n header.from=makrotopia.org", "phobos.denx.de;\n spf=pass smtp.mailfrom=daniel@makrotopia.org" ], "Received": [ "from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fFG6K3Nr0z1xpl\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 17 Feb 2026 08:26:01 +1100 (AEDT)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 2AF3683D5D;\n\tMon, 16 Feb 2026 22:25:04 +0100 (CET)", "by phobos.denx.de (Postfix, from userid 109)\n id DC13883B8A; Mon, 16 Feb 2026 22:24:21 +0100 (CET)", "from pidgin.makrotopia.org (pidgin.makrotopia.org\n [IPv6:2a07:2ec0:3002::65])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 5460C83EF9\n for <u-boot@lists.denx.de>; Mon, 16 Feb 2026 22:24:19 +0100 (CET)", "from local\n by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256)\n (Exim 4.99) (envelope-from <daniel@makrotopia.org>)\n id 1vs64a-000000002pd-2aMS; Mon, 16 Feb 2026 21:24:04 +0000" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-1.9 required=5.0 tests=BAYES_00,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham\n autolearn_force=no version=3.4.2", "Date": "Mon, 16 Feb 2026 21:24:00 +0000", "From": "Daniel Golle <daniel@makrotopia.org>", "To": "Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,\n Quentin Schulz <quentin.schulz@cherry.de>,\n Daniel Golle <daniel@makrotopia.org>,\n Kory Maincent <kory.maincent@bootlin.com>,\n Mattijs Korpershoek <mkorpershoek@kernel.org>,\n Martin Schwan <m.schwan@phytec.de>, Anshul Dalal <anshuld@ti.com>,\n Ilias Apalodimas <ilias.apalodimas@linaro.org>,\n Sughosh Ganu <sughosh.ganu@arm.com>, Aristo Chen <jj251510319013@gmail.com>,\n\t=?utf-8?b?54mbIOW/l+Wujw==?= <Zone.Niuzh@hotmail.com>,\n Marek Vasut <marek.vasut+renesas@mailbox.org>,\n Heinrich Schuchardt <xypron.glpk@gmx.de>,\n Wolfgang Wallner <wolfgang.wallner@at.abb.com>,\n Frank Wunderlich <frank-w@public-files.de>,\n David Lechner <dlechner@baylibre.com>,\n Osama Abdelkader <osama.abdelkader@gmail.com>,\n Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,\n Michael Trimarchi <michael@amarulasolutions.com>,\n Miquel Raynal <miquel.raynal@bootlin.com>,\n Andrew Goodbody <andrew.goodbody@linaro.org>,\n Yegor Yefremov <yegorslists@googlemail.com>,\n Mike Looijmans <mike.looijmans@topic.nl>,\n Weijie Gao <weijie.gao@mediatek.com>,\n Alexander Stein <alexander.stein@ew.tq-group.com>,\n Neil Armstrong <neil.armstrong@linaro.org>,\n Mayuresh Chitale <mchitale@ventanamicro.com>,\n Paul HENRYS <paul.henrys_ext@softathome.com>, u-boot@lists.denx.de", "Cc": "John Crispin <john@phrozen.org>, Paul Spooren <mail@aparcar.org>", "Subject": "[RFC PATCH 17/20] boot: bootdev: add UBI boot device", "Message-ID": "\n <bc1fb5747051cd6462bf3158250a04ea8e83b14e.1771275704.git.daniel@makrotopia.org>", "References": "<cover.1771275704.git.daniel@makrotopia.org>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=utf-8", "Content-Disposition": "inline", "Content-Transfer-Encoding": "8bit", "In-Reply-To": "<cover.1771275704.git.daniel@makrotopia.org>", "X-Mailman-Approved-At": "Mon, 16 Feb 2026 22:25:02 +0100", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.39", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>", "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de", "X-Virus-Status": "Clean" }, "content": "Add a boot device driver for UBI (Unsorted Block Images) that enables\nbootstd to scan UBI volumes for FIT images.\n\nThe driver:\n- Has a hunt callback that auto-attaches UBI: walks the DT for the\n first partition with compatible = \"linux,ubi\", finds the matching\n MTD device, and calls ubi_part_from_mtd() to attach\n- Binds directly via bootdev_bind() as a child of the top-level MTD\n device, using a distinct name (\"ubibootdev\") to coexist with the\n MTD bootdev\n- Iterates UBI volumes using iter->part as an index\n- Reads the first bytes of each volume and checks for a valid FDT\n header via fdt_check_header()\n- Stores the UBI volume name in bflow->bootmeth_priv for the\n bootmeth's boot() to pass to image_loader_init_ubi()\n- Returns -ESHUTDOWN when all volumes are exhausted\n\nLike the MTD bootdev, calls bootmeth_check() first so that only\ncompatible bootmeths produce bootflows. Inert until bootmeth_openwrt\nis extended to accept UBI bootdevs.\n\nSigned-off-by: Daniel Golle <daniel@makrotopia.org>\n---\n boot/Kconfig | 9 +++\n boot/Makefile | 1 +\n boot/ubi_bootdev.c | 180 +++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 190 insertions(+)\n create mode 100644 boot/ubi_bootdev.c", "diff": "diff --git a/boot/Kconfig b/boot/Kconfig\nindex 63e373cc62d..75d40744e69 100644\n--- a/boot/Kconfig\n+++ b/boot/Kconfig\n@@ -594,6 +594,15 @@ config BOOTDEV_MTD\n \t This scans MTD partitions for uImage.FIT firmware images,\n \t enabling raw-flash boot via the OpenWrt boot method.\n \n+config BOOTDEV_UBI\n+\tbool \"UBI bootdev support\"\n+\tdepends on CMD_UBI\n+\tdepends on BOOTSTD\n+\thelp\n+\t Enable a boot device for UBI (Unsorted Block Images).\n+\t This scans UBI volumes for uImage.FIT firmware images,\n+\t enabling raw-flash boot via the OpenWrt boot method.\n+\n config BOOTMETH_OPENWRT\n \tbool \"Bootdev support for OpenWrt\"\n \tdepends on FIT\ndiff --git a/boot/Makefile b/boot/Makefile\nindex feeed4924dd..aa7968c3932 100644\n--- a/boot/Makefile\n+++ b/boot/Makefile\n@@ -73,6 +73,7 @@ obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_SIMPLE_OS) += vbe_simple_os.o\n \n obj-$(CONFIG_$(PHASE_)BOOTMETH_ANDROID) += bootmeth_android.o\n obj-$(CONFIG_$(PHASE_)BOOTDEV_MTD) += mtd_bootdev.o\n+obj-$(CONFIG_$(PHASE_)BOOTDEV_UBI) += ubi_bootdev.o\n obj-$(CONFIG_$(PHASE_)BOOTMETH_OPENWRT) += bootmeth_openwrt.o\n \n obj-$(CONFIG_IMAGE_LOADER) += image-loader.o\ndiff --git a/boot/ubi_bootdev.c b/boot/ubi_bootdev.c\nnew file mode 100644\nindex 00000000000..03131a4ee1b\n--- /dev/null\n+++ b/boot/ubi_bootdev.c\n@@ -0,0 +1,180 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+/*\n+ * UBI boot device\n+ *\n+ * Copyright (C) 2026 Daniel Golle <daniel@makrotopia.org>\n+ */\n+\n+#define LOG_CATEGORY UCLASS_BOOTSTD\n+\n+#include <bootdev.h>\n+#include <bootflow.h>\n+#include <bootmeth.h>\n+#include <dm.h>\n+#include <dm/ofnode.h>\n+#include <malloc.h>\n+#include <mtd.h>\n+#include <ubi_uboot.h>\n+#include <linux/libfdt.h>\n+\n+static int ubi_bootdev_get_bootflow(struct udevice *dev,\n+\t\t\t\t struct bootflow_iter *iter,\n+\t\t\t\t struct bootflow *bflow)\n+{\n+\tstruct ubi_device *ubi;\n+\tstruct ubi_volume *vol;\n+\tstruct mtd_info *ubi_mtd, *top_mtd, *part;\n+\tchar buf[40];\n+\tchar dname[60];\n+\tint ubi_part_idx = 0;\n+\tint n = 0;\n+\tint i, ret;\n+\n+\tret = bootmeth_check(bflow->method, iter);\n+\tif (ret)\n+\t\treturn log_msg_ret(\"chk\", ret);\n+\n+\tubi = ubi_devices[0];\n+\tif (!ubi)\n+\t\treturn log_msg_ret(\"ubi\", -ENODEV);\n+\n+\t/* Count volumes so the scanning framework knows the bound */\n+\tfor (i = 0; i < ubi->vtbl_slots; i++) {\n+\t\tif (ubi->volumes[i])\n+\t\t\tn++;\n+\t}\n+\tif (n)\n+\t\titer->max_part = n - 1;\n+\n+\tn = 0;\n+\n+\t/* Walk to the iter->part'th UBI volume */\n+\tfor (i = 0; i < ubi->vtbl_slots; i++) {\n+\t\tvol = ubi->volumes[i];\n+\t\tif (!vol)\n+\t\t\tcontinue;\n+\t\tif (n == iter->part)\n+\t\t\tgoto found;\n+\t\tn++;\n+\t}\n+\treturn -ESHUTDOWN;\n+\n+found:\n+\tret = ubi_volume_read(vol->name, buf, 0, sizeof(buf));\n+\tif (ret)\n+\t\treturn log_msg_ret(\"rd\", -EIO);\n+\n+\tif (fdt_check_header(buf))\n+\t\treturn log_msg_ret(\"fdt\", -ENOENT);\n+\n+\t/*\n+\t * Find the MTD partition index hosting UBI so we can display\n+\t * a meaningful partition number in the bootflow listing.\n+\t */\n+\tubi_mtd = ubi->mtd;\n+\ttop_mtd = ubi_mtd;\n+\twhile (top_mtd->parent)\n+\t\ttop_mtd = top_mtd->parent;\n+\n+\tn = 0;\n+\tlist_for_each_entry(part, &top_mtd->partitions, node) {\n+\t\tif (part == ubi_mtd) {\n+\t\t\tubi_part_idx = n;\n+\t\t\tbreak;\n+\t\t}\n+\t\tn++;\n+\t}\n+\n+\t/* Device-style name and partition index for bootflow list display */\n+\tsnprintf(dname, sizeof(dname), \"%s.part_%x\", dev->name, ubi_part_idx);\n+\tbflow->name = strdup(dname);\n+\tbflow->part = ubi_part_idx;\n+\tbflow->fname = strdup(vol->name);\n+\tbflow->bootmeth_priv = strdup(vol->name);\n+\tbflow->state = BOOTFLOWST_MEDIA;\n+\n+\treturn bootmeth_read_bootflow(bflow->method, bflow);\n+}\n+\n+static int ubi_bootdev_bind(struct udevice *dev)\n+{\n+\tstruct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);\n+\n+\tucp->prio = BOOTDEVP_4_SCAN_FAST;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * ubi_bootdev_hunt() - attach UBI and bind a bootdev for it\n+ *\n+ * Walk the DT for the first partition with compatible = \"linux,ubi\",\n+ * find its MTD device, attach UBI via ubi_part_from_mtd(), then bind\n+ * a ubi_bootdev as a child of the top-level MTD DM device.\n+ */\n+static int ubi_bootdev_hunt(struct bootdev_hunter *info, bool show)\n+{\n+\tstruct udevice *bdev;\n+\tstruct mtd_info *mtd;\n+\tofnode node;\n+\tint ret;\n+\n+\tmtd_probe_devices();\n+\n+\tif (!ubi_devices[0]) {\n+\t\tofnode_for_each_compatible_node(node, \"linux,ubi\") {\n+\t\t\tmtd_for_each_device(mtd) {\n+\t\t\t\tif (ofnode_equal(mtd->flash_node, node))\n+\t\t\t\t\tgoto found;\n+\t\t\t}\n+\t\t}\n+\t\treturn -ENOENT;\n+found:\n+\t\tret = ubi_part_from_mtd(mtd);\n+\t\tif (ret)\n+\t\t\treturn log_msg_ret(\"att\", -ENOENT);\n+\t}\n+\n+\t/* Find the top-level MTD device for the attached UBI */\n+\tmtd = ubi_devices[0]->mtd;\n+\twhile (mtd->parent)\n+\t\tmtd = mtd->parent;\n+\n+\tif (!mtd->dev)\n+\t\treturn log_msg_ret(\"dev\", -ENODEV);\n+\n+\t/*\n+\t * Bind directly — bootdev_setup_for_dev() cannot be used here\n+\t * because the MTD bootdev may already occupy the single bootdev\n+\t * child slot.\n+\t */\n+\tret = bootdev_bind(mtd->dev, \"ubi_bootdev\", \"ubibootdev\", &bdev);\n+\tif (ret)\n+\t\treturn log_msg_ret(\"bd\", ret);\n+\n+\treturn 0;\n+}\n+\n+struct bootdev_ops ubi_bootdev_ops = {\n+\t.get_bootflow\t= ubi_bootdev_get_bootflow,\n+};\n+\n+static const struct udevice_id ubi_bootdev_ids[] = {\n+\t{ .compatible = \"u-boot,bootdev-ubi\" },\n+\t{ }\n+};\n+\n+U_BOOT_DRIVER(ubi_bootdev) = {\n+\t.name\t\t= \"ubi_bootdev\",\n+\t.id\t\t= UCLASS_BOOTDEV,\n+\t.ops\t\t= &ubi_bootdev_ops,\n+\t.bind\t\t= ubi_bootdev_bind,\n+\t.of_match\t= ubi_bootdev_ids,\n+};\n+\n+BOOTDEV_HUNTER(ubi_bootdev_hunter) = {\n+\t.prio\t\t= BOOTDEVP_4_SCAN_FAST,\n+\t.uclass\t\t= UCLASS_MTD,\n+\t.drv\t\t= DM_DRIVER_REF(ubi_bootdev),\n+\t.hunt\t\t= ubi_bootdev_hunt,\n+};\n", "prefixes": [ "RFC", "17/20" ] }