Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2197002/?format=api
{ "id": 2197002, "url": "http://patchwork.ozlabs.org/api/patches/2197002/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/47725c58588200f631c918a56b770454d5721954.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": "<47725c58588200f631c918a56b770454d5721954.1771275704.git.daniel@makrotopia.org>", "list_archive_url": null, "date": "2026-02-16T21:22:32", "name": "[RFC,08/20] boot: image-loader: add UBI volume backend", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "946ef95bf345ea63100f2ca6df59a95ff023900e", "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/47725c58588200f631c918a56b770454d5721954.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/2197002/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2197002/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 4fFG4R4kYWz1xwD\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 17 Feb 2026 08:24:23 +1100 (AEDT)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 0A09D83E36;\n\tMon, 16 Feb 2026 22:23:07 +0100 (CET)", "by phobos.denx.de (Postfix, from userid 109)\n id B710283D0F; Mon, 16 Feb 2026 22:22:57 +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 B9D168063E\n for <u-boot@lists.denx.de>; Mon, 16 Feb 2026 22:22:55 +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 1vs63A-000000002i5-1qz3; Mon, 16 Feb 2026 21:22:36 +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:22:32 +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 08/20] boot: image-loader: add UBI volume backend", "Message-ID": "\n <47725c58588200f631c918a56b770454d5721954.1771275704.git.daniel@makrotopia.org>", "References": "<cover.1771275704.git.daniel@makrotopia.org>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=us-ascii", "Content-Disposition": "inline", "In-Reply-To": "<cover.1771275704.git.daniel@makrotopia.org>", "X-Mailman-Approved-At": "Mon, 16 Feb 2026 22:23:05 +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 UBI volume storage backend for the image_loader framework.\n\nimage_loader_init_ubi() takes a volume name, ensures the UBI device\nis attached (auto-attaching if needed), and installs a .read() callback\nwrapping ubi_volume_read().\n\nAuto-attach works by scanning the device tree for the first MTD\npartition with compatible = \"linux,ubi\", then calling ubi_part() on\nthat partition. The partition name is resolved using the same\nprecedence as the MTD partition parser: the \"label\" property first,\nthen \"name\", then the node name. Since U-Boot only supports a single\nattached UBI device at a time, only the first matching partition is\nused. If a UBI device is already attached, the auto-attach step is\nskipped.\n\nUBI handles bad-block management and wear leveling internally, so the\nread callback is a straightforward passthrough. Note that\nubi_volume_read() returns positive errno values; the wrapper negates\nthem for the image_loader convention.\n\nGated by CONFIG_IMAGE_LOADER_UBI (depends on CMD_UBI && IMAGE_LOADER).\n\nSigned-off-by: Daniel Golle <daniel@makrotopia.org>\n---\n boot/Kconfig | 8 +++\n boot/Makefile | 1 +\n boot/image-loader-ubi.c | 112 ++++++++++++++++++++++++++++++++++++++++\n include/image-loader.h | 13 +++++\n 4 files changed, 134 insertions(+)\n create mode 100644 boot/image-loader-ubi.c", "diff": "diff --git a/boot/Kconfig b/boot/Kconfig\nindex 23848a0f57e..89832014af6 100644\n--- a/boot/Kconfig\n+++ b/boot/Kconfig\n@@ -1203,6 +1203,14 @@ config IMAGE_LOADER_MTD\n \t parallel NAND, etc.) using the image_loader framework.\n \t NAND bad blocks are skipped transparently.\n \n+config IMAGE_LOADER_UBI\n+\tbool \"UBI volume backend for image loader\"\n+\tdepends on IMAGE_LOADER && CMD_UBI\n+\thelp\n+\t Allows loading images from UBI volumes using the image_loader\n+\t framework. Auto-attaches the UBI device from the device tree\n+\t if not already attached.\n+\n config DISTRO_DEFAULTS\n \tbool \"(deprecated) Script-based booting of Linux distributions\"\n \tselect CMDLINE\ndiff --git a/boot/Makefile b/boot/Makefile\nindex 1dde16db694..7d1d4a28106 100644\n--- a/boot/Makefile\n+++ b/boot/Makefile\n@@ -76,6 +76,7 @@ obj-$(CONFIG_$(PHASE_)BOOTMETH_ANDROID) += bootmeth_android.o\n obj-$(CONFIG_IMAGE_LOADER) += image-loader.o\n obj-$(CONFIG_IMAGE_LOADER_BLK) += image-loader-blk.o\n obj-$(CONFIG_IMAGE_LOADER_MTD) += image-loader-mtd.o\n+obj-$(CONFIG_IMAGE_LOADER_UBI) += image-loader-ubi.o\n \n obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_ABREC) += vbe_abrec.o vbe_common.o\n obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_ABREC_FW) += vbe_abrec_fw.o\ndiff --git a/boot/image-loader-ubi.c b/boot/image-loader-ubi.c\nnew file mode 100644\nindex 00000000000..64901a13378\n--- /dev/null\n+++ b/boot/image-loader-ubi.c\n@@ -0,0 +1,112 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+/*\n+ * UBI volume backend for image_loader\n+ *\n+ * Copyright (C) 2026 Daniel Golle <daniel@makrotopia.org>\n+ */\n+\n+#include <dm/ofnode.h>\n+#include <image-loader.h>\n+#include <log.h>\n+#include <malloc.h>\n+#include <mtd.h>\n+#include <ubi_uboot.h>\n+\n+struct image_loader_ubi_priv {\n+\tchar *vol_name;\n+};\n+\n+/**\n+ * ubi_auto_attach() - attach UBI if not already attached\n+ *\n+ * If no UBI device is currently attached, walk the device tree for the\n+ * first MTD partition node with compatible = \"linux,ubi\", find the\n+ * corresponding MTD device by matching flash_node, and attach UBI to\n+ * it via ubi_part_from_mtd().\n+ *\n+ * Since U-Boot only supports a single attached UBI device at a time,\n+ * only the first matching partition is used.\n+ *\n+ * Return: 0 on success or if already attached, negative errno on failure\n+ */\n+static int ubi_auto_attach(void)\n+{\n+\tstruct mtd_info *mtd;\n+\tofnode node;\n+\n+\t/* Already attached? */\n+\tif (ubi_devices[0])\n+\t\treturn 0;\n+\n+\tmtd_probe_devices();\n+\n+\tofnode_for_each_compatible_node(node, \"linux,ubi\") {\n+\t\tmtd_for_each_device(mtd) {\n+\t\t\tif (ofnode_equal(mtd->flash_node, node))\n+\t\t\t\tgoto found;\n+\t\t}\n+\t}\n+\n+\tlog_err(\"image_loader_ubi: no MTD device for \\\"linux,ubi\\\" node\\n\");\n+\treturn -ENODEV;\n+\n+found:\n+\tif (ubi_part_from_mtd(mtd)) {\n+\t\tlog_err(\"image_loader_ubi: failed to attach UBI on \\\"%s\\\"\\n\",\n+\t\t\tmtd->name);\n+\t\treturn -EIO;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int image_loader_ubi_read(struct image_loader *ldr, ulong src,\n+\t\t\t\t ulong size, void *dst)\n+{\n+\tstruct image_loader_ubi_priv *priv = ldr->priv;\n+\tint ret;\n+\n+\tret = ubi_volume_read(priv->vol_name, dst, src, size);\n+\t/* ubi_volume_read() returns positive errno values on error */\n+\treturn ret ? -ret : 0;\n+}\n+\n+static void image_loader_ubi_cleanup(struct image_loader *ldr)\n+{\n+\tstruct image_loader_ubi_priv *priv = ldr->priv;\n+\n+\tfree(priv->vol_name);\n+\tfree(priv);\n+}\n+\n+int image_loader_init_ubi(struct image_loader *ldr, const char *vol_name)\n+{\n+\tstruct image_loader_ubi_priv *priv;\n+\tint ret;\n+\n+\tret = ubi_auto_attach();\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (!ubi_find_volume(vol_name)) {\n+\t\tlog_err(\"image_loader_ubi: volume \\\"%s\\\" not found\\n\",\n+\t\t\tvol_name);\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tpriv = malloc(sizeof(*priv));\n+\tif (!priv)\n+\t\treturn -ENOMEM;\n+\n+\tpriv->vol_name = strdup(vol_name);\n+\tif (!priv->vol_name) {\n+\t\tfree(priv);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tldr->read = image_loader_ubi_read;\n+\tldr->cleanup = image_loader_ubi_cleanup;\n+\tldr->priv = priv;\n+\n+\treturn 0;\n+}\ndiff --git a/include/image-loader.h b/include/image-loader.h\nindex 7ccf901d37d..a036e98982f 100644\n--- a/include/image-loader.h\n+++ b/include/image-loader.h\n@@ -172,4 +172,17 @@ int image_loader_init_blk(struct image_loader *ldr, const char *ifname,\n */\n int image_loader_init_mtd(struct image_loader *ldr, const char *name);\n \n+/**\n+ * image_loader_init_ubi() - Initialise loader for a UBI volume\n+ *\n+ * Ensures a UBI device is attached (auto-attaching from the device\n+ * tree if needed), verifies the named volume exists, then installs a\n+ * .read() callback wrapping ubi_volume_read().\n+ *\n+ * @ldr:\tThe image loader to initialise\n+ * @vol_name:\tUBI volume name\n+ * Return: 0 on success, negative errno on failure\n+ */\n+int image_loader_init_ubi(struct image_loader *ldr, const char *vol_name);\n+\n #endif /* __IMAGE_LOADER_H */\n", "prefixes": [ "RFC", "08/20" ] }