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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03712C05027 for ; Wed, 1 Feb 2023 21:17:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 62DA785CC0; Wed, 1 Feb 2023 22:16:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=gmx.de header.i=@gmx.de header.b="Ho75x8iJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CAA4C85C4D; Wed, 1 Feb 2023 22:16:35 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A436385DFE for ; Wed, 1 Feb 2023 22:16:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1675286097; bh=rjOFeaCThZb+nwJ9UA1zfV/KzuScI38nXjgCV+hgPzg=; h=X-UI-Sender-Class:Date:From:To:CC:Subject:In-Reply-To:References; b=Ho75x8iJsb4cnxYPAh0NXl4CH+hgSgwNzigZqiuJ5fG6lxOv5VevXykglEPkazArs PLJ/yWq/rQjrB8J2YqaXVQQ1NEtu1T/SDAwN6D3ZoXWIEcZTEtJ4pujef/peuGOYvL PtxNO2pWb0vLkv7TmVkkQJaSZMqx53G97yovWWtV2lx9VokBdb0tGPPweG2fhIv17i HGParm/jaBrNSuAeflihnvoLQXzHmuGlijtVRmgqWyfRQ1uEtctcfuYWgJoRT5+jqc ajPOywMt8D2XcRsiudXYkJT6K+6imy4MefUfh6Ranm839Pl6TkRxs4J5J/MuIBP2uw luSmunH3MEWjA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [127.0.0.1] ([88.152.145.137]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mkpf3-1ovSM204uF-00mMW6; Wed, 01 Feb 2023 22:14:57 +0100 Date: Wed, 01 Feb 2023 22:14:55 +0100 From: Heinrich Schuchardt To: Tobias Waldekranz , sjg@chromium.org, ilias.apalodimas@linaro.org CC: u-boot@lists.denx.de Subject: Re: [PATCH 8/8] doc: blkmap: Add introduction and examples User-Agent: K-9 Mail for Android In-Reply-To: <20230201181016.4145834-9-tobias@waldekranz.com> References: <20230201181016.4145834-1-tobias@waldekranz.com> <20230201181016.4145834-9-tobias@waldekranz.com> Message-ID: <1D5180F7-CA9D-452C-BB71-DE61B130F78D@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:en98Ei06xcg9DLRJSIpchep6MG2bSA0sF0DXFbFjr6SsuVh/XD/ ZAYVdti7Vl3ZO55oiYAc8Mqd4xkz9qfq8lKJLYl1dv+VjPiLJxcFBVR9llsVD43agwG7oS2 UK1FZUPDedG2iQ90lVc7q5bBwkofHyS2cGl7FGhb1n40WNLg+uNrNlQ4sH6/p+sBfF6e/md VS/pcme0qgZI5irdT3V6g== UI-OutboundReport: notjunk:1;M01:P0:4REGNghLLTg=;ZP+r21FiuyhLbiqGLvzcTifSuSS bY1sk9ob0hx6Xqa347Qjv3x49rSn3lCXnNI0bJoJEelsiVZgIsPoovTa82JE6uDFHM+lKTu6D k7/vW4w/JPYcmcT9SCfSm+/lAjRIDZWLXTLOcVqsKCvu3D9m3uowUBxD+/aDVI93iIiPcrji8 HSv4q+mkTV5TIuef28JuFm3x2U7i6+y9kGilW0eZgaBTyc57gcr3ppEXwMi+qGrvfIBkb/jWz JLZIfLU36jNhMseY7Tu/6lsXeateE3L0kHuY4fQVc2moY/mdS/r5IRiz7zIiYazYMjh2rxA66 xHC2lP9UNHMdkQ0vLoJDQ/PB57/W2+sQ0Pv8I1zS1ariOxjF6L7tNLTwPYBnNk4kUMI6zjcyP TF4MUJbLhgiMptDtl12ZT5qo5JnA05D74euuC4fpQm513hKPzhOlYeIKY5Lmcnn0bEYeRIWIa T0mXlfyxKrBGtJYj7X6XWxndrb2ECYJybs7dewhU88j1kAvmr5iR1Y+t4oFtvCKiyta9HejLK wJ+WP5i0JjnEzX+kSxFhKbtM5lLl/896lJ+GTvN1Pi3P2rJZcdHhWdvXFwTEQF4xp5TDaxEKu R5Ncf27QYN8EebSp6l1ocw8Q24YXNnB/v3JvEg6pFFnejRPyBesVonD7PB8YBeyWC34LqV+FO f/NtT15XG19uf1WZo6v6bnkJ/dLdakQxGWADC79I0pqM1KIHLmw93XWoK1godIb26Q2lBCWKV 9J7UxlAjlJk5s3OHg43JWGx9fbObAR4eMLFENLjGBCLu27HwfNizpVZ8bN1P2DsgpitfxMBBo oUS6il5E43VzEkImCx77RC9FBiN0oWoZsYTJzJVOuZ41o0KY/2zkxAvbBmuKYvdYM6+cH/1UA Xft+TvqApPnwVF1EHBnT+cAo+2ywApfzcWujp1etXQPv2ZpQGtNtzEKdL2IrxbPAPeu6q+buc Dk0JUA== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Am 1=2E Februar 2023 19:10:16 MEZ schrieb Tobias Waldekranz : >Explain block maps by going through two common use-cases=2E > >Signed-off-by: Tobias Waldekranz >--- > MAINTAINERS | 1 + > doc/usage/blkmap=2Erst | 109 +++++++++++++++++++++++++++++++++++++++++++ > doc/usage/index=2Erst | 1 + > 3 files changed, 111 insertions(+) > create mode 100644 doc/usage/blkmap=2Erst > >diff --git a/MAINTAINERS b/MAINTAINERS >index c420c8e1f9=2E=2Ede0e41487d 100644 >--- a/MAINTAINERS >+++ b/MAINTAINERS >@@ -790,6 +790,7 @@ BLKMAP > M: Tobias Waldekranz > S: Maintained > F: cmd/blkmap=2Ec >+F: doc/usage/blkmap=2Erst > F: drivers/block/blkmap=2Ec > F: include/blkmap=2Eh > F: test/py/tests/test_blkmap=2Epy >diff --git a/doc/usage/blkmap=2Erst b/doc/usage/blkmap=2Erst >new file mode 100644 >index 0000000000=2E=2E1cf6d97c1b >--- /dev/null >+++ b/doc/usage/blkmap=2Erst >@@ -0,0 +1,109 @@ >+=2E=2E SPDX-License-Identifier: GPL-2=2E0+ >+=2E=2E >+=2E=2E Copyright (c) 2023 Addiva Elektronik >+=2E=2E Author: Tobias Waldekranz >+ >+Block Maps (blkmap) >+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >+ >+Block maps are a way of looking at various sources of data through the >+lens of a regular block device=2E It lets you treat devices that are not >+block devices, like RAM, as if they were=2E It also lets you export a >+slice of an existing block device, which does not have to correspond >+to a partition boundary, as a new block device=2E >+ >+This is primarily useful because U-Boot's filesystem drivers only >+operate on block devices, so a block map lets you access filesystems >+wherever they might be located=2E >+ >+The implementation is loosely modeled on Linux's "Device Mapper" >+subsystem, see `kernel documentation`_ for more information=2E >+ >+=2E=2E _kernel documentation: https://docs=2Ekernel=2Eorg/admin-guide/de= vice-mapper/index=2Ehtml >+ >+ >+Example: Netbooting an Ext4 Image >+--------------------------------- >+ >+Say that our system is using an Ext4 filesystem as its rootfs, where >+the kernel is stored in ``/boot``=2E This image is then typically stored >+in an eMMC partition=2E In this configuration, we can use something like >+``load mmc 0 ${kernel_addr_r} /boot/Image`` to load the kernel image >+into the expected location, and then boot the system=2E No problems=2E >+ >+Now imagine that during development, or as a recovery mechanism, we >+want to boot the same type of image by downloading it over the >+network=2E Getting the image to the target is easy enough: >+ >+:: >+ >+ dhcp ${ramdisk_addr_r} rootfs=2Eext4 >+ >+But now we are faced with a predicament: how to we extract the kernel >+image? Block maps to the rescue! >+ >+We start by creating a new device: >+ >+:: >+ >+ blkmap create 0 >+ >+Before setting up the mapping, we figure out the size of the >+downloaded file, in blocks: >+ >+:: >+ >+ setexpr fileblks ${filesize} + 0x1ff >+ setexpr fileblks ${filesize} / 0x200 >+ >+Then we can add a mapping to the start of our device, backed by the >+memory at `${loadaddr}`: >+ >+:: >+ >+ blkmap map 0 0 ${fileblks} mem ${fileaddr} This is way too complicated=2E Just accept the file size here=2E How can we handle images assuming a different block size then? >+ >+Now we can access the filesystem via the virtual device: >+ >+:: >+ >+ load blkmap 0 ${kernel_addr_r} /boot/Image >+ >+ >+Example: Accessing a filesystem inside an FIT image >+--------------------------------------------------- >+ >+In this example, an FIT image is stored in an eMMC partition=2E We would >+like to read the file ``/etc/version``, stored inside a Squashfs image >+in the FIT=2E Since the Squashfs image is not stored on a partition >+boundary, there is no way of accessing it via ``load mmc =2E=2E=2E``=2E >+ >+What we can to instead is to first figure out the offset and size of >+the filesystem: >+ >+:: >+ >+ mmc dev 0 >+ mmc read ${loadaddr} 0 0x100 >+ >+ fdt addr ${loadaddr} >+ fdt get value squashaddr /images/ramdisk data-position >+ fdt get value squashsize /images/ramdisk data-size >+ >+ setexpr squashblk ${squashaddr} / 0x200 >+ setexpr squashsize ${squashsize} + 0x1ff >+ setexpr squashsize ${squashsize} / 0x200 >+ >+Then we can create a block map that maps to that slice of the full >+partition: >+ >+:: >+ >+ blkmap create 0 >+ blkmap map 0 0 ${squashsize} linear mmc 0 ${squashblk} We are the requirements on alignment? Best regards Heinrich >+ >+Now we can access the filesystem: >+ >+:: >+ >+ load blkmap 0 ${loadaddr} /etc/version >diff --git a/doc/usage/index=2Erst b/doc/usage/index=2Erst >index 3804046835=2E=2E856a3da28e 100644 >--- a/doc/usage/index=2Erst >+++ b/doc/usage/index=2Erst >@@ -4,6 +4,7 @@ Use U-Boot > =2E=2E toctree:: > :maxdepth: 1 >=20 >+ blkmap > dfu > environment > fdt_overlays