From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15F80C5DF81 for ; Sun, 23 Aug 2026 19:13:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 146D96061B; Sun, 23 Aug 2026 19:13:16 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id BvreYZNWCVcC; Sun, 23 Aug 2026 19:13:15 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=u-boot-bounces@lists.u-boot-project.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.u-boot-project.org; s=default; t=1787512395; bh=xrZG7wDzg1OPOlkGsN3qPsnmrhJM3L3d3++zM0dvXuQ=; h=Date:From:To:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=ZD84bq6yN1vNk/w3EUGHhasv11LGo0cUoGCaHTGExaAxZf0d7qVF1xy7Xc10QGn50 /TodE+KTCPqRWHvMl8dsp0UEWxtJ43sa5c5btQBbU8pFmglCCNGSXrOAZzIedF7793 9CjdNCMvYpCm3o/tlygUpdEZii8bm1rbKuKgxWa9KTtfTMm0odf4DJUd9u0p+6tFDT h90XbStGu0X8EHHWjKX56kvop/+5yTxJlvEQ9qiQZPipSIqJmv8KLpGq6qyXnlmeTZ HaTgGJm5iqsoxGH7LDhBXJCjOrjeD3I5lkfQkWDhDRYY8Tt6cIGrWWsc2RuLpqxIns VsNNFJ4WD/3XQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id 0BC366061D; Sun, 23 Aug 2026 19:13:15 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists1.osuosl.org (Postfix) with ESMTP id A73F0386 for ; Sun, 23 Aug 2026 19:13:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 8D86C80C44 for ; Sun, 23 Aug 2026 19:13:13 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id THp7SuV87SyV for ; Sun, 23 Aug 2026 19:13:12 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a07:2ec0:3002::65; helo=pidgin.makrotopia.org; envelope-from=daniel@makrotopia.org; receiver= Authentication-Results: smtp1.osuosl.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [IPv6:2a07:2ec0:3002::65]) by smtp1.osuosl.org (Postfix) with ESMTPS id 5FCEA80C31 for ; Sun, 23 Aug 2026 19:13:11 +0000 (UTC) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.99) (envelope-from ) id 1wyDce-000000001ip-2507; Sun, 23 Aug 2026 19:12:48 +0000 Date: Sun, 23 Aug 2026 20:12:43 +0100 From: Daniel Golle To: Tom Rini , Simon Glass , Daniel Golle , Dario Binacchi , Michael Trimarchi , Frieder Schrempf , Quentin Schulz , Marek Vasut , "Lucien.Jheng" , Casey Connolly , Michal Simek , Johan Jonker , Aristo Chen , Nora Schiffer , Rasmus Villemoes , Weijie Gao , Peng Fan , Vincent Jardin , Neil Armstrong , Randolph Sapp , Miquel Raynal , Richard Genoud , u-boot@lists.u-boot-project.org, openwrt-devel@lists.openwrt.org Subject: [PATCH 0/9] boot: add imagemap on-demand image loading from storage Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-BeenThere: u-boot@lists.u-boot-project.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.u-boot-project.org This series adds "imagemap", a small layer for reading FIT images directly from storage on demand instead of copying the whole image into RAM first. It keeps a translation table of the byte ranges already loaded, so a header probe, signature verification and the final load can reuse a single read, and it hooks transparently into fit_image_load() so all existing verification and decompression paths run unchanged for both RAM- and storage-backed images. An imagemap device is created over a partition of a block device. That covers more than raw disks: an MTD partition is reached through mtdblock and a UBI volume through ubiblock, each exposed as a named block-device partition, so imagemap carries no storage-specific code of its own. NAND bad-block handling and wear-levelling stay with UBI, as they do elsewhere in U-Boot; on NOR a partition is read linearly with end-to-end integrity guaranteed by the FIT hash or signature. To make those two paths reachable and testable, the first patches fill in the missing block devices: a non-NAND MTD master now gets an mtd_blk device automatically (patch 1), and attaching UBI now binds a ubi_blk device on any flash (patch 3, which makes the SPI-NAND-only eager binding redundant, dropped in patch 4). The read path is built on the SPL struct spl_load_info abstraction and a new spl_load_region() helper. imagemap is full-U-Boot only; the SPL FIT loader is unaffected. Testing (sandbox): "ut imagemap" (13 tests) covers the translation-table core plus real end-to-end reads of a NOR partition through mtd_blk and a UBI volume through ubiblock; a CONFIG_IMAGEMAP=n build is unaffected. On hardware it has been tested end-to-end on a BananaPi R3 (mt7986), booting a dm-verity-protected rootfs from every storage path the board exposes: eMMC and SD (block partition), SPI-NAND (UBI volume via ubiblock) and SPI-NOR (raw MTD partition via mtdblock). The first in-tree consumer, a bootmeth for OpenWrt-style FIT firmware, will follow as a separate series. This series began as part of a combined RFC that also carried the OpenWrt boot method and its bootdevs [1]. Following the review there it has been reworked substantially: - Build on U-Boot's existing SPL external-data loading path rather than a new abstraction: imagemap now uses struct spl_load_info and a new spl_load_region() helper (suggested by Marek Vasut). - Do not extend the bootm command with a storage source; on-demand loading hooks into fit_image_load() transparently, and the in-tree consumer is a bootstd boot method reached through bootflow/bootdev/bootmeth rather than new bootm syntax (per Tom Rini). - Move the storage-backed path out of the long fit_image_load() into its own helper, gated with if()/tools_build() instead of an inline #if (per Simon Glass). - Collapse the three storage-specific backends (block, MTD and UBI) into a single block backend: NOR is read through mtd_blk and SPI-NAND through UBI/ubiblock, so imagemap holds no storage-specific code. - Send the on-demand loading core on its own; the OpenWrt boot method, the MTD/UBI bootdevs and board enablement follow as separate series once this lands. In order to test imagemap end-to-end with the intended bootmeth user I'm still relying on the downstream install-uuid mechanism of [2], which [3] could supersede. Both have stalled right now. [1] https://lore.kernel.org/u-boot/cover.1771275704.git.daniel@makrotopia.org/ [2] https://github.com/open-source-firmware/flat-image-tree/pull/40 [3] https://github.com/open-source-firmware/flat-image-tree/pull/44 Based on u-boot/next. Daniel Golle (9): mtd: bind an mtd_blk device for non-NAND MTD masters mtd: nand: sandbox: forbid sub-page writes cmd: ubi: create a ubi_blk device when attaching UBI mtd: nand: spi: drop the eager ubi_blk binding boot: add imagemap on-demand loading from storage boot: fit: support on-demand loading in fit_image_load() configs: sandbox: enable imagemap and its storage backends test: boot: add imagemap unit tests doc: imagemap: document on-demand loading framework MAINTAINERS | 9 + arch/sandbox/dts/test.dts | 29 ++ boot/Kconfig | 16 + boot/Makefile | 2 + boot/bootm.c | 70 +++- boot/image-fit.c | 109 +++++- boot/imagemap.c | 451 +++++++++++++++++++++ cmd/ubi.c | 27 ++ configs/sandbox_defconfig | 6 + doc/develop/imagemap.rst | 100 +++++ doc/develop/index.rst | 1 + drivers/mtd/mtdcore.c | 24 ++ drivers/mtd/nand/raw/sand_nand.c | 2 + drivers/mtd/nand/spi/core.c | 3 - include/bootm.h | 2 + include/dm/uclass-id.h | 1 + include/image.h | 2 + include/imagemap.h | 136 +++++++ include/spl.h | 47 ++- test/boot/Makefile | 2 + test/boot/imagemap.c | 645 +++++++++++++++++++++++++++++++ test/cmd_ut.c | 2 + 22 files changed, 1671 insertions(+), 15 deletions(-) create mode 100644 boot/imagemap.c create mode 100644 doc/develop/imagemap.rst create mode 100644 include/imagemap.h create mode 100644 test/boot/imagemap.c base-commit: 8841b7b292c74864acf4ed0bd8ce05839252c1f2 -- 2.55.0