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 2019AC433EF for ; Mon, 11 Jul 2022 18:32:47 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 05A698405F; Mon, 11 Jul 2022 20:32:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com 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; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="fXXuqLRM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 23F4F8402A; Mon, 11 Jul 2022 20:32:25 +0200 (CEST) Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B4BCA8402A for ; Mon, 11 Jul 2022 20:32:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qv1-xf35.google.com with SMTP id r12so975355qvm.3 for ; Mon, 11 Jul 2022 11:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0xA4vKk+EydtgD+wJihRwjA4uZa3zT0cpFWYi4ZfGeY=; b=fXXuqLRMTlkCAO0a8NwiKhlHM6EJlEtHwvmFjD29vMHPDp6kYRoPnvdcIG2/nSP2aD hOa7TRNxXztgskHwJ3qQSFIU/dhGHICB2uhUDU9Ra5abgdTtN4JPwq4Rde5Ho85ZVs7S ORe/CEK9YH7ekYmQrO2gDxEtVE1LET7pLHK2s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0xA4vKk+EydtgD+wJihRwjA4uZa3zT0cpFWYi4ZfGeY=; b=xGN87A2T7qLwx1uEYuy4Jja0Iu7SMavWbjidSYx63/7mr/lQ+tkWK3hM/swu742Bkg HTj7O+haAO1ufa1LExMVr8j2sOvveYVfBDuQ1oQL0I5EeEbk95jU4Rhl4eR+xOCmHKa/ QkN0JtYtQIsu0tNfGHd0YwCx+ft4mbynL1qsXUr0VhepoFboYYsrBDd2L8MXUP3ScJQl I/HV06xNCcdXyG7m6CYKPPGxYkJum3X4tic+9jAE2jXWEA2Qip84L2CXpo7bXSKZb+mh sMTVEGgU/cHXnygtufWs1J3bmrw9tLzIS5tMCYa2sRbV7mwqVRx56xD6u09erkaMTvXH m1XQ== X-Gm-Message-State: AJIora9x8wh+91fjZR1gIVAgkS+kwvNqMexSrbfXTpztyPaexfnNBbfw pSHv2qv+G7uHtuuG522I2tllcnYXCA9f8w== X-Google-Smtp-Source: AGRyM1vgEbg7OIk610T1DCCLpSPC3IXzXGOp2p59xZB1SSYgKgxlO8mTb123D7Si64PL83IgIQQvBw== X-Received: by 2002:a05:6214:c22:b0:472:f86e:47b2 with SMTP id a2-20020a0562140c2200b00472f86e47b2mr14380154qvd.102.1657564336987; Mon, 11 Jul 2022 11:32:16 -0700 (PDT) Received: from bill-the-cat.lan (cpe-65-184-195-139.ec.res.rr.com. [65.184.195.139]) by smtp.gmail.com with ESMTPSA id q15-20020ac8734f000000b0031eb9508ccbsm1214346qtp.70.2022.07.11.11.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 11:32:16 -0700 (PDT) From: Tom Rini To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Simon Glass Subject: [PATCH 3/3] doc: environment: Further expand on Image locations and provide example Date: Mon, 11 Jul 2022 14:32:13 -0400 Message-Id: <20220711183213.1933852-3-trini@konsulko.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711183213.1933852-1-trini@konsulko.com> References: <20220711183213.1933852-1-trini@konsulko.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Start by elaborating on what some of our constraints tend to be with image location values, and document where these external constraints can come from. Provide a new subsection, an example based on the TI ARMv7 OMAP2PLUS families of chips, that gives sample values and explains why we use these particular values. This is based on what is in include/configs/ti_armv7_common.h as of fb3ad9bd923d ("TI: Add, use a DEFAULT_LINUX_BOOT_ENV environment string") as this contains just the values referenced in this document now and not some of the further additions that are less generic. Cc: Heinrich Schuchardt Cc: Simon Glass Signed-off-by: Tom Rini --- Changes in v2: - Largely rewrite both of the sections. Add more words to explain what kind of general constraints there are. Try and make it clear the TI example is one for ARMv7. We need examples for other architectures still, as follow-up patches. --- doc/usage/environment.rst | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/doc/usage/environment.rst b/doc/usage/environment.rst index 30b08b281879..6f1dd1c3a879 100644 --- a/doc/usage/environment.rst +++ b/doc/usage/environment.rst @@ -404,6 +404,56 @@ device tree blob fdtfile fdt_addr_r fdt_addr ramdisk ramdiskfile ramdisk_addr_r ramdisk_addr ================= ============== ================ ============== +When setting the RAM addresses for `kernel_addr_r`, `fdt_addr_r` and +`ramdisk_addr_r` there are several types of constraints to keep in mind. The +one type of constraint is payload requirement. For example, a device tree MUST +be loaded at an 8-byte aligned address as that is what the specification +requires. In a similar manner, the operating system may define restrictions on +where in memory space payloads can be. This is documented for example in Linux, +with both the `Booting ARM Linux`_ and `Booting AArch64 Linux`_ documents. +Finally, there are practical constraints. We do not know the size of a given +payload a user will use but each payload must not overlap or it will corrupt +the other payload. A similar problem can happen when a payload ends up being in +the OS BSS area. For these reasons we need to ensure our default values here +are both unlikely to lead to failure to boot and sufficiently explained so that +they can be optimized for boot time or adjusted for smaller memory +configurations. + +On different architectures we will have different constraints. It is important +that we follow whatever documented requirements are available to best ensure +forward compatibility. What follows are examples to highlight how to provide +reasonable default values in different cases. + +Texas Instruments OMAP2PLUS (ARMv7) example +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +On these families of processors we are on a 32bit ARMv7 core. As booting some +form of Linux is our most common payload we will also keep in mind the +documented requirements for booting that Linux provides. These values are also +known to be fine for booting a number of other operating systems (or their +loaders). In this example we define the following variables and values:: + + loadaddr=0x82000000 + kernel_addr_r=${loadaddr} + fdt_addr_r=0x88000000 + ramdisk_addr_r=0x88080000 + bootm_size=0x10000000 + +The first thing to keep in mind is that DRAM starts at 0x80000000. We set a +32MiB buffer from the start of memory as our default load address and set +``kernel_addr_r`` to that. This is because the Linux ``zImage`` decompressor +will typically then be able to avoid doing a relocation itself. It also MUST be +within the first 128MiB of memory. The next value is we set ``fdt_addr_r`` to +be at 128MiB offset from the start of memory. This location is suggested by the +kernel documentation and is exceedingly unlikely to be overwritten by the +kernel itself given other architectural constraints. We then allow for the +device tree to be up to 512KiB in size before placing the ramdisk in memory. We +then say that everything should be within the first 256MiB of memory so that +U-Boot can relocate things as needed to ensure proper alignment. We pick 256MiB +as our value here because we know there are very few platforms on in this +family with less memory. It could be as high as 768MiB and still ensure that +everything would be visible to the kernel, but again we go with what we assume +is the safest assumption. Automatically updated variables ------------------------------- @@ -472,3 +522,6 @@ Implementation -------------- See :doc:`../develop/environment` for internal development details. + +.. _`Booting ARM Linux`: https://www.kernel.org/doc/html/latest/arm/booting.html +.. _`Booting AArch64 Linux`: https://www.kernel.org/doc/html/latest/arm64/booting.html -- 2.25.1