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 B42BFC433EF for ; Thu, 13 Jan 2022 06:40:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7B14C83281; Thu, 13 Jan 2022 07:40:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1642056013; bh=o2L8nbhLj8pqgC1MAAkqN0NpZNbPcS4T08AXd6Zj784=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=UUGOSMiHRXHoKqjfUrJmBSl/mjTK3Uguw0Dyu5EyCYW243Ve+YbVUDquyHtLvhE0r KYogPWeotH0tncmjmeEAqRs9MVnVDkrIAqKfItSZCih3Goifa3SSu2XYD2JE2m/w31 oEInET/R4RSALMZjyZNAIe+zbfxikA522jMdZa9adoab1Lwi/0XcAD3QiAZ3+2Gnig z4raU2TJRZzoJD+n8tU03EI9VS7VJ6wZe7Aztd/tQx719Fn8011yBQcf7YeZIilIPP yBMyEFiHsAUHHMhkEUL+roEUL+UReIpOWwgLNk/v82DRCNo2cAjzrvkuQnyyZBdTAg LS0Ry0Rjz3nrw== Received: by phobos.denx.de (Postfix, from userid 109) id B144983042; Thu, 13 Jan 2022 07:40:10 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (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 43F7F83281 for ; Thu, 13 Jan 2022 07:40:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:105:465:1:3:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4JZFD81gG0zQlLG; Thu, 13 Jan 2022 07:40:08 +0100 (CET) Message-ID: <33457b7d-0fd6-77d5-e551-bcb8b4339fd5@denx.de> Date: Thu, 13 Jan 2022 07:40:04 +0100 MIME-Version: 1.0 Subject: Re: [PATCH u-boot-marvell v2 11/20] arm: mvebu: Correctly set LOAD_ADDRESS for U-Boot SPL binary in kwbimage Content-Language: en-US To: =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= , Chris Packham Cc: u-boot@lists.denx.de References: <20211221155416.8557-1-pali@kernel.org> <20220112172054.5961-1-pali@kernel.org> <20220112172054.5961-12-pali@kernel.org> From: Stefan Roese In-Reply-To: <20220112172054.5961-12-pali@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed 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.2 at phobos.denx.de X-Virus-Status: Clean On 1/12/22 18:20, Pali Rohár wrote: > U-Boot SPL for mvebu platform is not compiled as position independent. > Therefore it is required to instruct BootROM to load U-Boot SPL at the > correct address. Loading of kwbimage binary code at specific address can be > now achieved by the new LOAD_ADDRESS token as part of BINARY command in > kwbimage config file. > > Update mvebu Makefile to put value of $(CONFIG_SPL_TEXT_BASE) into > LOAD_ADDRESS token when generating kwbimage.cfg from kwbimage.cfg.in. > > It is required to update regex for sed to find replacement tokens at any > position on a line in kwbimage config file and not only at the beginning of > the line. This is because LOAD_ADDRESS is specified at the end of line > containing the BINARY command. > > It looks like all Armada boards set CONFIG_SPL_TEXT_BASE to value > 0x40004030 or 0x40000030. Why this value? It is because main kwbimage > header is at address 0x40004030 or 0x40000000 and it is 32 bytes long. > After the main header there is the binary header, which consist of 1 byte > for type, 3 bytes for size, 1 byte for number of arguments, 3 reserved > bytes and then 4 bytes for each argument. After these arguments comes the > executable code. > > So arguments start at address 0x40004028 or 0x40000028. Before commit > e6571f38c943 ("arm: mvebu: Remove dummy BIN header arguments for SPL > binary") there were two (dummy) arguments, which resulted in load address > of 0x40004030 or 0x40000030, always. After that commit (which removed dummy > arguments), load address stayed same due to the 128-bit alignment done by > mkimage. > > This patch now reflects the dependency between $(CONFIG_SPL_TEXT_BASE), > load address and dummy kwbimage arguments, and allows the user to adjust > $(CONFIG_SPL_TEXT_BASE) config option to some other value. > > For unsupported values, when mkimage/kwbimage cannot set chosen load address > as specified by $(CONFIG_SPL_TEXT_BASE), the build process now fails, > instead of silently generating non-working kwbimage. > > Removal of this alignment between $(CONFIG_SPL_TEXT_BASE) and LOAD_ADDRESS > can only be done by compiling U-Boot SPL as position independent. But this > currently is not possible for 32-bit ARM version of U-Boot SPL. > > Signed-off-by: Pali Rohár > Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Thanks, Stefan > --- > arch/arm/mach-mvebu/Makefile | 5 ++++- > arch/arm/mach-mvebu/kwbimage.cfg.in | 4 ++-- > 2 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile > index 17006c9df9b0..9ace049c9d7c 100644 > --- a/arch/arm/mach-mvebu/Makefile > +++ b/arch/arm/mach-mvebu/Makefile > @@ -38,6 +38,9 @@ else ifneq ($(CONFIG_ARMADA_375)$(CONFIG_ARMADA_38X)$(CONFIG_ARMADA_39X),) > KWB_CFG_CPU = A9 > endif > > +KWB_REPLACE += LOAD_ADDRESS > +KWB_CFG_LOAD_ADDRESS = $(CONFIG_SPL_TEXT_BASE) > + > KWB_REPLACE += BOOT_FROM > ifneq ($(CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI),) > KWB_CFG_BOOT_FROM=spi > @@ -67,7 +70,7 @@ KWB_CFG_SEC_FUSE_DUMP = a38x > endif > > quiet_cmd_kwbcfg = KWBCFG $@ > -cmd_kwbcfg = sed -ne '$(foreach V,$(KWB_REPLACE),s/^\#@$(V)/$(V) $(KWB_CFG_$(V))/;)p' \ > +cmd_kwbcfg = sed -ne '$(foreach V,$(KWB_REPLACE),s/\#@$(V)/$(V) $(KWB_CFG_$(V))/;)p' \ > <$< >$(dir $@)$(@F) > > $(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \ > diff --git a/arch/arm/mach-mvebu/kwbimage.cfg.in b/arch/arm/mach-mvebu/kwbimage.cfg.in > index 8e720daf4820..603e8863450c 100644 > --- a/arch/arm/mach-mvebu/kwbimage.cfg.in > +++ b/arch/arm/mach-mvebu/kwbimage.cfg.in > @@ -11,5 +11,5 @@ VERSION 1 > # Boot Media configurations > #@BOOT_FROM > > -# Binary Header (bin_hdr) with DDR3 training code > -BINARY spl/u-boot-spl.bin > +# Include U-Boot SPL with DDR3 training code into Binary Header > +BINARY spl/u-boot-spl.bin #@LOAD_ADDRESS > Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de