Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59190C433F5 for ; Fri, 10 Sep 2021 16:28:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5ECB361167 for ; Fri, 10 Sep 2021 16:28:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5ECB361167 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 550B7836AE; Fri, 10 Sep 2021 18:28:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (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 (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="BUzYTvsY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 79F57836B1; Fri, 10 Sep 2021 18:28:43 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (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 09563836AD for ; Fri, 10 Sep 2021 18:28:39 +0200 (CEST) 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.net; s=badeba3b8450; t=1631291317; bh=o0Hcju0oq7jMAcVcHu2br8OWDe1gHSfUeL6HR8WNwts=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=BUzYTvsY1Xr+LiU0jdJ0UGvhoPQOVPCXeKObgKAZQzj9HWUWBEOHnBi4iAZNNVRhC qIQU7HpR8lDWuh7omwX5lXk/0DXaK8O4oEbruM3Dsj8QWaeFti6By/6pMKzbQgDDLM MS+4oJaEn99/oZ1QyZydVevL4zeM798KIkC8Ezpk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.55] ([88.152.144.157]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MQMyZ-1mbjxl3AcD-00MLdd; Fri, 10 Sep 2021 18:28:36 +0200 Subject: Re: [PATCH v3 3/3] RFC: doc: Add documentation about devicetree usage To: Tom Rini Cc: Simon Glass , U-Boot Mailing List , Sean Anderson , Mark Kettenis , Ilias Apalodimas , =?UTF-8?Q?Fran=c3=a7ois_Ozog?= , Bill Mills , Marcel Ziswiler References: <20210909201033.755713-1-sjg@chromium.org> <20210909201033.755713-4-sjg@chromium.org> <20210910123420.GL12964@bill-the-cat> From: Heinrich Schuchardt Message-ID: Date: Fri, 10 Sep 2021 18:28:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210910123420.GL12964@bill-the-cat> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:3SX3deG7epD8JWXtU0SZX0tGX+WS2tbJ+hCgLgoqH55NdfyZyDJ 9cIz/PVD5p9k6zB0EJFy11xxbg5VR/NsIsk+OFxiuE7iPB9UhOL/0V1rOqpWCxKPcayzX+q 8WIsTc6KEtBVCzAO4iRKzbGRMKmMq9FaK/nNp8S2OM/eBkOMQvRnOMwryEMrED2wak5B4Wp QWb2R8kkIceLn9FlOTG8g== X-UI-Out-Filterresults: notjunk:1;V03:K0:KNbfuq7oers=:wpkUrI43fMSMfyc1yEPzIN CFswhCfRLmKBsKTSRXc3h1LR57cAJVgpVOu4SzY2jWEggZjUlndcMtmr5MGMY/INA3rhEGFUE lghBI1yKlFMiapJSRH2n4V66GOJF9FcRmb0ozmxbEOtUsdJxtAzeEPYVkfsW5uU1kAPNFmS35 an+xEDCqh8Ul2jTceHaSQIlpRaK4swGZTonPp21LTfaHgJxQpbmdDlBZHMvWxPAhe0gFMpduX VaPHVqGxqq3GLFbV91Js0fMVgaSm4FRiUBM2EjlWzAXZQWGkYAW5KzbP+v8zALdftzDZjMI3K rQ8a+AklDWUznjQPh8s+vx/wU+UBnLiwWX4XD1xqfVHe7spdkigcKw5aqo0A50By+OIgy34zf +BkL5EytF3XY+ImbEGWVCvBiaYIO9XsU4BRdiBrfpcoJ4pRBC/Pe0BnDenzik85BCzUIgsrQ5 7y26CpSKucBBo1UXBnUwvTaSMFTpT0h5cqZnkuBKv6b443hPEnoQ6noF3ISceoiEC61pMXpee y68qGlYnNF5LGh3mfWwOJquU2PbcD49LzdLwEl0zaFNdhsBHebZkwsWoKYFzdr/hZhwuxHqi1 EYu0cqxrTzLqVu7Mady+GUK5Y3PqL3BGrb1dH9YGw80k5k+sC4WDgY0NqLLijm5hTriE9Sv7s WHpOowq3oBmAhYmMK8/TOuPHSyYUjMZiDHnvd4kKDsH/VLylJrU5Chn87jWjp/srThR8Z3izd On2rhS64A3VmgepXGGMbr1LwlTvI3PQvoB4AoeTllVPvcHK7e1yDSu1NGTHZ53kn+z4J/su9O qWcxpWTQ9i22fHn+vIUZjg79WdLPGjgdBLzQ636KD849Ojdk6C5FwNAU7sxFjbWAdoVXT3m9m /3kqdD/kq2Wo5/GwdtfKwW+kndAzE0P2ALQia9odoe/WwPlqBDFzachc9K8ph91q+d2mkDsq8 RLpl/kygQ/H9Oqw3kmT9PfRzqv8DsyOHFlvg8hYMF09zTu2JoP5EGCk6TRkR74VJb5ox4yj6v NIJRhpzD6PbtKmkfW6ZTGrI6XrwSvBbqtaX2p+GE7RpumK8S/qU3DZQyt6OFcHpIHO+UdvrBc YR1MhavFqdZLNU= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On 9/10/21 2:34 PM, Tom Rini wrote: > On Fri, Sep 10, 2021 at 10:38:17AM +0200, Heinrich Schuchardt wrote: >> >> >> On 9/9/21 10:10 PM, Simon Glass wrote: >>> At present some of the ideas and techniques behind devicetree in U-Boo= t >>> are assumed, implied or unsaid. Add some documentation to cover how >>> devicetree is build, how it can be modified and the rules about using >>> the various CONFIG_OF_... options. >>> >>> Signed-off-by: Simon Glass >>> Reviewed-by: Marcel Ziswiler >>> --- >>> >>> Changes in v3: >>> - Fix typos linst suppled receive EFL >>> - Drop 'and' before 'self-defeating' >>> - Reword mention of control of QEMU's devicetree generation >>> - Add mention of dropping CONFIG_OF_BOARD >>> - Clarify the 'Once this bug is fixed' paragraph a bit >>> - Expand ways that CONFIG_OF_PRIOR_STAGE can support the U-Boot device= tree >>> - Add a note at the top explaining that his patch covers 'now', not 'f= uture' >>> - Add note 'Note: Some boards use a devicetree in U-Boot which does no= t match' >>> >>> Changes in v2: >>> - Fix typos per Sean (thank you!) and a few others >>> - Add a 'Use of U-Boot /config node' section >>> - Drop mention of dm-verity since that actually uses the kernel cmdlin= e >>> - Explain that OF_BOARD will still work after these changes (in >>> 'Once this bug is fixed...' paragraph) >>> - Expand a bit on the reason why the 'Current situation' is bad >>> - Clarify in a second place that Linux and U-Boot use the same devicet= ree >>> in 'To be clear, while U-Boot...' >>> - Expand on why we should have rules for other projects in >>> 'Devicetree in another project' >>> - Add a comment as to why devicetree in U-Boot is not 'bad design' >>> - Reword 'in-tree U-Boot devicetree' to 'devicetree source in U-Boot' >>> - Rewrite 'Devicetree generated on-the-fly in another project' to cove= r >>> points raised on v1 >>> - Add 'Why does U-Boot have its nodes and properties?' >>> - Add 'Why not have two devicetrees?' >>> >>> doc/develop/index.rst | 1 + >>> doc/develop/package/devicetree.rst | 583 ++++++++++++++++++++++++++= +++ >>> doc/develop/package/index.rst | 1 + >>> 3 files changed, 585 insertions(+) >>> create mode 100644 doc/develop/package/devicetree.rst >>> >>> diff --git a/doc/develop/index.rst b/doc/develop/index.rst >>> index 83c929babda..d5ad8f9fe53 100644 >>> --- a/doc/develop/index.rst >>> +++ b/doc/develop/index.rst >>> @@ -36,6 +36,7 @@ Packaging >>> :maxdepth: 1 >>> >>> package/index >>> + package/devicetree >>> >>> Testing >>> ------- >>> diff --git a/doc/develop/package/devicetree.rst b/doc/develop/package/= devicetree.rst >>> new file mode 100644 >>> index 00000000000..b1bd310d906 >>> --- /dev/null >>> +++ b/doc/develop/package/devicetree.rst >>> @@ -0,0 +1,583 @@ >>> +.. SPDX-License-Identifier: GPL-2.0+ >>> + >>> +Updating the devicetree >>> +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>> + >>> +Note: This documentation describes how things are today, mostly, with= some >>> +mention of things that need to be fixed. It is not intended to point = the way to >>> +what might be done in the future. That should be the subject of discu= ssions on >>> +the mailing list. >>> + >>> +U-Boot uses devicetree for runtime configuration and storing required= blobs or >>> +any other information it needs to operate. It is possible to update t= he >>> +devicetree separately from actually building U-Boot. This provides a = good degree >>> +of control and flexibility for firmware that uses U-Boot in conjuncti= on with >>> +other project. >>> + >>> +There are many reasons why it is useful to modify the devicetree afte= r building >>> +it: >>> + >>> +- Configuration can be changed, e.g. which UART to use >>> +- A serial number can be added >>> +- Public keys can be added to allow image verification >>> +- Console output can be changed (e.g. to select serial or vidconsole) >>> + >>> +This section describes how to work with devicetree to accomplish your= goals. >>> + >>> +See also :doc:`../devicetree/control` for a basic summary of the avai= lable >>> +features. >>> + >>> + >>> +Devicetree source >>> +----------------- >>> + >>> +Every board in U-Boot must include a devicetree sufficient to build a= nd boot >>> +that board on suitable hardware (or emulation). This is specified usi= ng the >>> +`CONFIG DEFAULT_DEVICE_TREE` option. >>> + >>> + >>> +Current situation (August 2021) >>> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> + >>> +As an aside, at present U-Boot allows `CONFIG_DEFAULT_DEVICE_TREE` to= be empty, >>> +e.g. if `CONFIG_OF_BOARD` or `CONFIG_OF_PRIOR_STAGE` are used. This h= as >>> +unfortunately created an enormous amount of confusion and some wasted= effort. >>> +This was not intended and this bug will be fixed soon. >>> + >>> +Some of the problems created are: >>> + >>> +- It is not obvious that the devicetree is coming from another projec= t >>> + >>> +- There is no way to see even a sample devicetree for these platform = in U-Boot, >>> + so it is hard to know what is going on, e.g. which devices are typi= cally >>> + present >>> + >>> +- The other project may not provide a way to support U-Boot's require= ments for >>> + devicetree, such as the /config node. Note: On the U-Boot mailing l= ist, this >>> + was only discovered after weeks of discussion and confusion >>> + >>> +- For QEMU specifically, consulting two QEMU source files is required= , for which >>> + there are no references in U-Boot documentation. The code is genera= ting a >>> + devicetree, with some control from command-line args, but it is not= clear >>> + how to add properties required by U-Boot. >>> + >>> +Specifically on the changes in U-Boot: >>> + >>> +- `CONFIG_OF_BOARD` was added in rpi_patch_ for Raspberry Pi, which d= oes have >>> + an in-tree devicetree, but this feature has since been used for boa= rds that >>> + don't >>> +- `CONFIG_OF_PRIOR_STAGE` was added in bcm_patch_ as part of a larger= Broadcom >>> + change with a tag indicating it only affected one board, so the cha= nge in >>> + behaviour was not noticed at the time. It has since been used by RI= SC-V qemu >>> + boards. >>> + >>> +Note: It is not clear that we actually need both of these. Possibly >>> +`CONFIG_OF_BOARD` can be dropped. >>> + >>> +Once this bug is fixed, CONFIG_OF_BOARD and CONFIG_OF_PRIOR_STAGE wil= l override >> >> What does "bug" refer to? Above you describe the current design not a b= ug. > > The bug is that we have two options to provide seemingly the same > functionality. Is there a functional difference between CONFIG_OF_BOARD > and CONFIG_OF_PRIOR_STAGE ? > >>> +(at runtime) the devicetree supplied with U-Boot, but will otherwise = use >>> +CONFIG_OF_SEPARATE for the in-tree build. So these two will become op= tions, >>> +moving out of the 'choice' in `dts/Kconfig`. To be clear, the devicet= ree in the >>> +U-Boot tree may be largely for documentation and build-testing purpos= es, if at >>> +runtime the devicetree if provided by another project. But the in-tre= e >>> +devicetree is packaged with U-Boot as a fallback if it does not get o= ne from a >>> +prior stage at runtime. This does not create two devicetrees that nee= d to be >>> +merged, or anything like that. If the prior stage provides one, it is= used as >>> +is, with the one provided by U-Boot being ignored. >>> + >>> +This means that there is a basic devicetree build in the U-Boot tree,= for >>> +build-testing, consistency and documentation purposes, but at runtime= U-Boot can >>> +accept its devicetree from another source. >> >> The incoming devicetree may not contain any U-Boot specific stuff. So >> don't you need the buildtime devicetree for all of this information at >> runtime? E.g. you were requesting to move certificate blobs into the >> build-time devicetree. > > This is wrong because (a) no, there's no functional reason the prior > stage cannot populate / be pre-populated with what we need and (b) we're > documenting what we have today. > The problem is not functional but organizational. The prior boot stage may be burnt into PROM while U-Boot is on an SD-card. Don't expect that on a board where you could install EDK II or U-Boot or anything else the prior boot stage cares about U-Boot. How could a prior boot stage possibly know years ahead what is not even yet supported in U-Boot when the prior boot stage is created? Best regards Heinrich